Skip to content

Instantly share code, notes, and snippets.

@smathy
Created July 21, 2009 23:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save smathy/151711 to your computer and use it in GitHub Desktop.
Save smathy/151711 to your computer and use it in GitHub Desktop.
git and svn tracking prompt
current_git_branch() {
git_exists=`git branch 2>/dev/null | sed -ne'/^\* /s///p'`
if [[ "$git_exists" != "" ]]; then
if [[ "$git_exists" == "(no branch)" ]]; then
git_exists="\e[31m\]$git_exists\e[0m\]"
fi
echo "$git_exists "
fi
unset git_exists
}
current_git_stash() {
git_stash=`git stash list 2>/dev/null | /usr/bin/wc -l | sed 's/ *//g'`
if [[ "$git_stash" != "" && $git_stash > 0 ]]; then
echo "[$git_stash] "
fi
unset git_stash
}
PROMPT_COMMAND='PS1="\t \[\e[32m\]$(current_git_branch)\[\e[0m\]\[\e[35m\]$(current_git_stash)\[\e[0m\]\[\e[33m\]\w\[\e[0m\] \[\e[1m\]\$\[\e[0m\] ";'$PROMPT_COMMAND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment