Skip to content

Instantly share code, notes, and snippets.

@FestivalBobcats
Created March 14, 2014 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FestivalBobcats/9550674 to your computer and use it in GitHub Desktop.
Save FestivalBobcats/9550674 to your computer and use it in GitHub Desktop.
Git branch and changes indicator for bash
__quiet() {
$1 2> /dev/null
}
parse_git_branch() {
__quiet 'git branch' | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
count_git_changes() {
count=$(__quiet 'git status -s' | wc -l)
if [ !$count == 0 ]; then
echo [ $count ]
fi
}
export PS1='\[\e[0;34m\]\W\[\e[0;36m\]$(parse_git_branch)\[\e[0;35m\]$(count_git_changes) \[\e[0;37m\]>\[\e[0m\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment