Skip to content

Instantly share code, notes, and snippets.

@evansde77
Created June 18, 2014 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evansde77/da20e3314f05ee95cb53 to your computer and use it in GitHub Desktop.
Save evansde77/da20e3314f05ee95cb53 to your computer and use it in GitHub Desktop.
How to show your git branch in your shell prompt
function parse_git_branch ()
{
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
BRANCH="("${ref#refs/heads/}")";
echo "${BRANCH}"
}
export PS1="[\t \W] \$(parse_git_branch) "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment