Skip to content

Instantly share code, notes, and snippets.

@rwarren
Created February 18, 2016 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwarren/e8005fe380e529ce297d to your computer and use it in GitHub Desktop.
Save rwarren/e8005fe380e529ce297d to your computer and use it in GitHub Desktop.
Mercurial .bashrc mod for prompt showing bookmark/rev and incoming state
# 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