Skip to content

Instantly share code, notes, and snippets.

@dmitrinesterenko
Created September 25, 2014 14:56
Show Gist options
  • Save dmitrinesterenko/273b879db94e32f79e0e to your computer and use it in GitHub Desktop.
Save dmitrinesterenko/273b879db94e32f79e0e to your computer and use it in GitHub Desktop.
Shell addition to show current git branch
#find the current git branch (this could be done differently through git status)
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
GREEN="\[\033[0;32m\]"
WHITE="\[\e[1;0m\]"
#update the shell prompt line
PS1="$WHITE\$(date +%H:%M) \w$GREEN \$(parse_git_branch)$WHITE\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment