Skip to content

Instantly share code, notes, and snippets.

@souenzzo
Created June 16, 2016 20:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save souenzzo/4a85b0ed9bee85cbab3851a88d0b804f to your computer and use it in GitHub Desktop.
Exibe branch no prompt do bash, muda de cor quando há mudanças não commitadas.
git_branch() {
GIT_STATUS="$(git status --porcelain 2> /dev/null)"
(( $? == 0 )) || return
if [[ -z "$GIT_STATUS" ]]; then
tput setaf 6
else
tput setaf 5
fi
git branch 2> /dev/null \
| awk '/^\*/{print "("$2")"}'
}
# PS1='[\u@\h \W]\$ '
PS1='\W$(git_branch) '
PS1='\[\e[1;32m\]'"$PS1"'\[\e[0m\]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment