Created
February 18, 2016 20:38
-
-
Save rwarren/e8005fe380e529ce297d to your computer and use it in GitHub Desktop.
Mercurial .bashrc mod for prompt showing bookmark/rev and incoming state
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
# add hg info to the prompt if it exists... | |
in_hg() { | |
# returns 0 if in a hg repo, 1 if not | |
d=$PWD | |
# Check up the path (using bash string operators) looking for .hg | |
while [ "${d}" != "" ]; do | |
if [ -d "${d}/.hg" ]; then | |
HG_DIR=$d/.hg | |
return 0 | |
fi | |
d=${d%/*} | |
done | |
return 1 | |
} | |
C_BYELLOW="\e[0;93m" | |
C_BRED="\e[0;91m" | |
C_DEFAULT="\e[m" | |
hg_ps1() { | |
if in_hg; then | |
if [ -f $HG_DIR/bookmarks.current ]; then | |
HGP=`hg prompt "[${C_BYELLOW}{${C_BRED}{incoming}}{bookmark}${C_DEFAULT}]"` | |
else | |
HGP=`hg prompt "[${C_BYELLOW}{${C_BRED}{incoming}}r{rev}${C_DEFAULT}]"` | |
fi | |
printf $HGP | |
fi | |
} | |
PS1='$(hg_ps1)'$PS1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment