Skip to content

Instantly share code, notes, and snippets.

@m3talsmith
Created September 9, 2010 20:30
Show Gist options
  • Save m3talsmith/572497 to your computer and use it in GitHub Desktop.
Save m3talsmith/572497 to your computer and use it in GitHub Desktop.
# -- git parsed prompt --
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="${debian_chroot:+($debian_chroot)}\[\033[0;34m\]\u@\h\[\033[00m\]:\[\033[0;36m\]\W\[\033[00m\]\$(parse_git_branch) $"
# -- #
@Abica
Copy link

Abica commented Sep 10, 2010

I use the __git_ps1 command to do roughly the same thing. Here's mine: export PS1='[\e[1;32m]\u[\e[1;31m]:[\e[1;36m]\W[\e[1;37m]$(__git_ps1 " (%s)")[\e[0m]λ '

Of course that requires you to source ~/git-completion.bash. That file is pacakged with git source in contrib/completion/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment