Skip to content

Instantly share code, notes, and snippets.

@sw17ch
Created August 29, 2012 15:46
Show Gist options
  • Save sw17ch/3514659 to your computer and use it in GitHub Desktop.
Save sw17ch/3514659 to your computer and use it in GitHub Desktop.
How I generate my prompt.
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