public
Last active

git and svn tracking prompt

  • Download Gist
.bash_profile
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.