Skip to content

Instantly share code, notes, and snippets.

@loginx
Created November 1, 2013 04:39
Show Gist options
  • Save loginx/7261019 to your computer and use it in GitHub Desktop.
Save loginx/7261019 to your computer and use it in GitHub Desktop.
Current git branch info in bash prompt.
# Insert this in ~/.bashrc or ~/.bash_login
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " ("${ref#refs/heads/}")"
}
export PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\$(parse_git_branch) \$\[\033[00m\] "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment