diff --git a/share/functions/__fish_hg_prompt.fish b/share/functions/__fish_hg_prompt.fish index 458924e6c..6a9f00a96 100644 --- a/share/functions/__fish_hg_prompt.fish +++ b/share/functions/__fish_hg_prompt.fish @@ -21,34 +21,34 @@ set -g fish_prompt_hg_status_unmerged '!' set -g fish_prompt_hg_status_order added modified copied deleted untracked unmerged function __fish_hg_prompt --description 'Write out the hg prompt' - # If hg isn't installed, there's nothing we can do - # Return 1 so the calling prompt can deal with it - if not command -s hg >/dev/null - 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 - while test $dir != "/" - if test -f $dir'/.hg/dirstate' - set root $dir"/.hg" - break - end - # Go up one directory - set -l dir (string replace -r '[^/]*/?$' '' $dir) + # If hg isn't installed, there's nothing we can do + # Return 1 so the calling prompt can deal with it + if not command -s hg > /dev/null + return 1 end - if test -z "$root" - return 0 - end + # Find an hg directory above $PWD + # without calling `hg root` because that's too slow + set -l root + set -l dir $PWD + while test $dir != "/" + if test -f $dir'/.hg/dirstate' + set root $dir"/.hg" + break + end + # Go up one directory + set -l dir (string replace -r '[^/]*/?$' '' $dir) + end - # Read branch and bookmark + if test -z "$root" + return 0 + end + + # Read branch and bookmark set -l branch (cat $root/branch ^/dev/null; or echo default) - if set -l bookmark (cat $root/bookmarks.current ^/dev/null) - set branch "$branch|$bookmark" - end + if set -l bookmark (cat $root/bookmarks.current ^/dev/null) + set branch "$branch|$bookmark" + end echo -n '|' @@ -60,7 +60,7 @@ function __fish_hg_prompt --description 'Write out the hg prompt' echo -n "($branch)"'✓' set_color normal - # Handle modified or dirty (unknown state) + # Handle modified or dirty (unknown state) else set -l hg_statuses