I needed to know which source control url I was in when I was in a
working copy directory, so I made a perl script to help me out. I found
it useful, maybe somebody else will also.
The script is used by doing the following:
in your Bash startup script add (it's important to escape the
back-ticks, and it's important to use the name SVNURL because the script
uses that name also)
export PROMPT_COMMAND="export SVNURL=\`/path/to/script/svn_findurl.pl`"
add $SVNURL to your $PS1 value
from my .bashrc
export PROMPT_COMMAND="export SVNURL=\`svn_parseinfo.pl\`"
export PS1='\[\033]0;\w\007\033[32m\]\A \[\033[33m\w\033[0m\] $SVNURL
$ '
put the script somewhere on your path.
The script is
#!/bin/perl
$temp = $ENV{"TEMP"};
$curdir = $ENV{"PWD"};
if (-d ".svn")
{
if (open(OLDDIR,"<$temp/oldsvndir"))
{
$olddir = <OLDDIR>;
close(OLDDIR);
}
if ($olddir eq $curdir)
{
print $ENV{"SVNURL"};
}
else
{
open(SVN,"svn info |") || die "unable to locate svn";
while (<SVN>)
{
if (/^Revision:\s+(\S+)/)
{
$revision=$1;
}
elsif (/^Url:\s+(\S+)/)
{
$url=$1
}
elsif (/^Last Changed Rev:\s+(\S+)/)
{
$lastchangerev=$1;
}
}
close(SVN);
print "($url\@$revision-$lastchangerev)";
open(OLDDIR,">$temp/oldsvndir") || die "unable to open
$temp/oldsvndir";
print OLDDIR "$curdir";
close(OLDDIR);
}
}
else
{
open(OLDDIR,">$temp/oldsvndir") || die "unable to open
$temp/oldsvndir";
print OLDDIR "$curdir";
close(OLDDIR);
print "";
}
Richard
Received on Thu Feb 13 21:23:22 2003