I'm trying to speed up my zsh theme prompt and hg checks are a bit slower than git's. That result in a slower prompt to show when using the hg plugin.
For git we use git rev-parse --is-inside-work-tree which is the standard and pretty fast.
For hg I've tried to find a similar command but nothing is as fast:
hg --cwd $PWD roothg summaryhg roothg -q stat
All these commands work but are not as efficient as git rev-parse --is-inside-work-tree.
Also tried this little script which is the best one currently. Anything I can do to speed this script even more?
is_dir_hg() {
local root="$(pwd -P)"
while [[ $root && ! -d $root/.hg ]]
do
root="${root%/*}"
done
echo "$root"
}
Note that the solution must detect hg directory even when we're not in the root directory.