Skip to content

Instantly share code, notes, and snippets.

@xthiago
Created January 16, 2014 12:27
Show Gist options
  • Save xthiago/8454196 to your computer and use it in GitHub Desktop.
Save xthiago/8454196 to your computer and use it in GitHub Desktop.
Exibir no bash o nome do branch do git (colorido)
function git_branch_name() {
git branch 2>/dev/null | grep -e '^*' | sed -E 's/^\* (.+)$/(\1) /'
}
function show_colored_git_branch_in_prompt() {
PS1="\[\033[01;32m\]\u@\h:\[\033[01;34m\]\w\[\033[31m\]\$(git_branch_name)\[\033[m\]$ "
}
show_colored_git_branch_in_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment