Skip to content

Instantly share code, notes, and snippets.

@mylesjao
Created June 6, 2014 02:54
Show Gist options
  • Save mylesjao/c63d57e92590f99c728b to your computer and use it in GitHub Desktop.
Save mylesjao/c63d57e92590f99c728b to your computer and use it in GitHub Desktop.
show current git branch in shell
#show current git branch in shell
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
PS1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\[\033[0m\]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment