From fffbde266fb65e9cc8718d1550193fcb6217538e Mon Sep 17 00:00:00 2001 From: Sean Patrick Hagen Date: Fri, 17 Jun 2022 12:41:49 -0700 Subject: [PATCH] Better "find directory", copied from hg code --- functions/fish_prompt.fish | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index d8aa618..61d7ee5 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -853,26 +853,21 @@ function __bobthefish_prompt_golang -S -d 'Display current Go information' [ "$theme_display_go" = 'no' ] and return - set -l cwd (pwd) - set -l dir (pwd) + + set -l dir $real_pwd set -l found_gomod 0 set -l gomod_version "0" set -l gomod_file # find the closest go.mod - while not test "$dir" = "/" - set gomod_file "$dir/go.mod" - - if test -f "$gomod_file" - set found_gomod 1 + while not [ -z "$d" ] + if [ -e $d/go.mod ] grep "^go\ " "$gomod_file" | read __ gomod_version - break end - cd $dir/.. - set dir (pwd) + [ "$d" = "/" ] + and return end - cd $cwd # no go.mod, not in a go project, don't display the prompt if test "$found_gomod" -eq "0"