Skip to content

Instantly share code, notes, and snippets.

@nchevobbe
Created June 30, 2020 15:53
Show Gist options
  • Save nchevobbe/cad11b7cf646703735fe3bda39e33326 to your computer and use it in GitHub Desktop.
Save nchevobbe/cad11b7cf646703735fe3bda39e33326 to your computer and use it in GitHub Desktop.
get repo information in prompt fast
prompt_hg() {
local HG_ROOT
find_hg_root() {
local dir="$( pwd )"
while test $dir != "/"; do
if test -f $dir'/.hg/dirstate'; then
HG_ROOT=$dir"/.hg"
return 0
fi
dir="$( dirname $dir )"
done
return 1
}
if find_hg_root; then
if test -f "$HG_ROOT/bookmarks.current"; then
if test -f "$HG_ROOT/histedit-state"; then
prompt_segment yellow black
echo -n ""
else
prompt_segment green black
echo -n ""
fi
echo -n " $(cat "$HG_ROOT/bookmarks.current")"
else
if test -f "$HG_ROOT/histedit-state"; then
prompt_segment yellow black
echo -n ""
else
prompt_segment green black
fi
echo -n "$(hexdump -n 20 -e '1/1 "%02x"' $HG_ROOT/dirstate | cut -c-12)"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment