Created
August 29, 2012 15:46
-
-
Save sw17ch/3514659 to your computer and use it in GitHub Desktop.
How I generate my prompt.
This file contains 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 __svn_ps1 { | |
local d=$(svn info 2>&1 | grep -Po "/(branches|trunk).*$") | |
if [ -n "$d" ]; then | |
echo -en "[svn:$d]" | |
fi | |
} | |
function __git_ps1 { | |
local d=$(git st 2>&1| grep -Po "branch .*") | |
if [ -n "$d" ]; then | |
echo -en "[git:$d]" | |
fi | |
} | |
function __vcs_ps1 { | |
git=$(__git_ps1) | |
if [ -n "$git" ]; then | |
echo -en $git | |
else | |
svn=$(__svn_ps1) | |
if [ -n "$svn" ]; then | |
echo -en $svn | |
fi | |
fi | |
} | |
PS1="\[\e[0;32m\]\h\[\e[0m\]:\[\e[1;35m\]\W\[\e[0m\] \[\e[1;33m\]\$(__vcs_ps1)\[\e[0m\]\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment