Skip to content

Instantly share code, notes, and snippets.

@tao12345666333
Created July 22, 2014 14:49
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 tao12345666333/4a81478aa5db7c30e94e to your computer and use it in GitHub Desktop.
Save tao12345666333/4a81478aa5db7c30e94e to your computer and use it in GitHub Desktop.
show git branch in bash shell
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
PS1="[\[\e[1;35m\]\u\[\e[1;32m\]\w\[\e[0m\]] \[\e[0m\]\[\e[1;36m\]\$(git_branch)\[\e[0;33m\]\$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment