fish-shell/share/functions/fish_print_hg_root.fish
Fabian Homborg c2970f9618 Reformat all files
This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.

If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
2019-05-05 12:09:25 +02:00

22 lines
506 B
Fish

function fish_print_hg_root
# If hg isn't installed, there's nothing we can do
if not command -sq hg
return 1
end
# Find an hg directory above $PWD
# without calling `hg root` because that's too slow
set -l root
set -l dir (pwd -P)
while test $dir != "/"
if test -f $dir'/.hg/dirstate'
echo $dir/.hg
return 0
end
# Go up one directory
set dir (string replace -r '[^/]*/?$' '' $dir)
end
return 1
end