Skip to content

Instantly share code, notes, and snippets.

@raidzero
Created April 25, 2016 20:56
Show Gist options
  • Save raidzero/04255d3945d2a2118b70ed6a0c8d3de2 to your computer and use it in GitHub Desktop.
Save raidzero/04255d3945d2a2118b70ed6a0c8d3de2 to your computer and use it in GitHub Desktop.
show git branch in command prompt
function get_git_branch_prompt() {
echo " `git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\(\1\)\ /'`"
}
function git_prompt {
local __git_branch='`get_git_branch_prompt`'
export PS1="\@ \W\[\033[32m\]$__git_branch\[\033[00m\]\$ "
}
git_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment