Skip to content

Instantly share code, notes, and snippets.

@ghprince
Created January 27, 2015 05:50
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 ghprince/d8712f3fbec580b7f29a to your computer and use it in GitHub Desktop.
Save ghprince/d8712f3fbec580b7f29a to your computer and use it in GitHub Desktop.
svn prompt in bashrc
function in_svn() {
if $(svn info >/dev/null 2>&1); then
return 0
fi
return 1
}
function get_svn_project_and_branch() {
svn info 2> /dev/null | \
awk -F/ \
'/^URL:/ { \
for (i=0; i<=NF; i++) { \
if ($i == "branches" || $i == "tags" ) { \
printf "%s:%s", $(i-1), $(i+1); \
break;\
}; \
if ($i == "trunk") { printf "%s:trunk", $(i-1); break; } \
} \
}'
}
function svn_prompt() {
if in_svn; then
echo "($(get_svn_project_and_branch))"
fi
}
export PS1="\$(svn_prompt)\n[\\u:\\W]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment