Skip to content

Instantly share code, notes, and snippets.

@lpiepiora
Last active December 24, 2015 15:58
Show Gist options
  • Save lpiepiora/6824037 to your computer and use it in GitHub Desktop.
Save lpiepiora/6824037 to your computer and use it in GitHub Desktop.
Display git branch in a shell
# See unpushed commits
# git log --branches --not --remotes --simplify-by-decoration --decorate --oneline
# Comment in the above and uncomment this below for a color prompt
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "["${ref#refs/heads/}"]"
}
GREEN="\[\033[01;32m\]"
YELLOW="\[\033[0;33m\]"
WHITE="\[\033[00m\]"
BLUE="\[\033[01;34m\]"
PS1="${debian_chroot:+($debian_chroot)}$GREEN\u@\h$YELLOW\$(parse_git_branch)$WHITE:$BLUE\w$WHITE\\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment