As I found some really cool stuff for adding git related information to the bash prompt, I’ve decided to do something similar for subversion. You can get the whole thing called subversion-prompt on a github repository.
I’ve cooked some bash functions to retrieve informations about the status of a directory relatively to subversion. With that, it is possible to have the following prompt session:
eric@ice-age:~$ nt eric@ice-age:~/nufw-svn/trunk/nufw[4779*]$ cd doc/ eric@ice-age:~/nufw-svn/trunk/nufw/doc$
Home directory is not a subversion managed directory and the prompt is standard. When going to my nufw subversion tree, the prompt warns me that current revision is 4779 and that I’ve done local modifications (star is present). If I go to the doc directory, the revision is still the same but as there is no star I’ve no local modifications pending.
You can also check the status against the remote repository. The result will be a star prefixing the release number if your source tree is not up-to-date:
eric@ice-age:~/nufw-svn/trunk/nufw[*4790]$ svn up U src/libs/nubase/config-parser.lex.l U src/libs/nubase/strings.c Actualisé à la révision 4791. eric@ice-age:~/nufw-svn/trunk/nufw$
Please note that prompt can take long to compute because of this.
To use this feature, you can get it from the github repository. Or simply click the following link to download it: subversion-prompt. Next step is to modify your .bashrc :
SVNP_HUGE_REPO_EXCLUDE_PATH="nufw-svn$|/tags$|/branches$" . ~/bin/subversion-prompt # set a fancy prompt PS1='\u@\h:\w$(__svn_stat)\$ '
You can even combine that feature with the original git feature. To do so, simply set:
PS1='\u@\h:\w$(__git_ps1 " (%s)")$(__svn_stat)\$ '
To check the status against the remote repository, you need to add
before sourcing subversion-prompt in your bashrc.
zsh lover will find an interesting alternative on this post.
4 thoughts on “Subversion aware prompt”
it would be nice if you wouldl upload your script again! i can not access it via the link maybe you could upload it to bitbucket or github:)
It’s already here: https://github.com/regit/subversion-prompt
I will refresh the link on the page just now.
that was quick:)
Thanks for posting this, it’s very helpful!
Anyone know how to tweak this to show the current branch name, no matter how far deeply I’m cd’d into one?