Git branch and changes indicator for bash
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
__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