Created
May 3, 2011 13:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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