Created
January 27, 2015 05:50
-
-
Save ghprince/d8712f3fbec580b7f29a to your computer and use it in GitHub Desktop.
svn prompt in bashrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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