Skip to content

Instantly share code, notes, and snippets.

@InFog
Created May 3, 2011 13:40
Show Gist options
  • Save InFog/953341 to your computer and use it in GitHub Desktop.
Save InFog/953341 to your computer and use it in GitHub Desktop.
Exibir os branches do Git e do Mercurial (hg) no prompt do Bash
# Adicione essas funções ao final do seu arquivo ~/.bashrc
# Branches do Git
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[GIT:\1\]/'
}
# Branches do Mercurial
parse_hg_branch() {
thisbranch=`hg branch 2> /dev/null`
if [ -n "$thisbranch" ]
then
echo " [HG:$thisbranch]"
fi
}
# Colocando tudo na PS1
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;37m\]\w\[\033[00;35m\]$(parse_git_branch)$(parse_hg_branch)\[\033[00m\] \$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment