Skip to content

Instantly share code, notes, and snippets.

@tovbinm
Created February 23, 2012 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tovbinm/1889163 to your computer and use it in GitHub Desktop.
Save tovbinm/1889163 to your computer and use it in GitHub Desktop.
Git/SVN branch in bash
parse_git_branch () {
git symbolic-ref HEAD 2> /dev/null | sed 's#refs/heads/\(.*\)# \1#'
}
parse_svn_branch() {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' |
awk '{print " (svn::"$1")" }'
}
parse_svn_url() {
svn info 2>/dev/null | sed -ne 's#^URL: ##p'
}
parse_svn_repository_root() {
svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p'
}
export PS1="\[\e[0;36m\]\u@\h\[\e[00m\]:\[\e[1;33m\]\w\$(parse_svn_branch)\$(parse_git_branch)\$ \[\e[0m\]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment