Skip to content

Instantly share code, notes, and snippets.

@DanPurdy
Created October 9, 2014 08:56
Show Gist options
  • Save DanPurdy/a704271dff1f25f189e3 to your computer and use it in GitHub Desktop.
Save DanPurdy/a704271dff1f25f189e3 to your computer and use it in GitHub Desktop.
Add this to your bash profile to have git branches and current directory highlighted in your terminal
function git-branch-name {
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
}
function git-branch-prompt {
local branch=`git-branch-name`
if [ $branch ]; then printf " [%s]" $branch; fi
}
PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment