Fix find_file_up to accept multiple args

This commit is contained in:
Hans Larsen 2022-01-30 10:54:42 -08:00
parent ca9e78068a
commit cee1edb460

View File

@ -895,17 +895,19 @@ function __bobthefish_prompt_desk -S -d 'Display current desk environment'
set_color normal set_color normal
end end
function __bobthefish_prompt_find_file_up_re -S -d 'Find file(s) (as a regex), going up the parent directories' function __bobthefish_prompt_find_file_up -S -d 'Find file(s), going up the parent directories'
set -l dir "$argv[1]" set -l dir "$argv[1]"
set -l file "$argv[2]" set -l files $argv[2..]
if [ -z "$dir" ] if [ -z "$dir" ]
return 1 return 1
end end
while [ "$dir" ] while [ "$dir" ]
if string match -q -r "$dir/($file)\$" -- $dir/* for f in $files
return if [ -e "$dir/$f" ]
return
end
end end
set dir (__bobthefish_dirname "$dir") set dir (__bobthefish_dirname "$dir")
@ -919,7 +921,7 @@ function __bobthefish_prompt_node -S -d 'Display current node version'
if [ "$theme_display_node" = 'always' -o "$theme_display_nvm" = 'yes' ] if [ "$theme_display_node" = 'always' -o "$theme_display_nvm" = 'yes' ]
set should_show 1 set should_show 1
else if [ "$theme_display_node" = 'yes' ] else if [ "$theme_display_node" = 'yes' ]
__bobthefish_prompt_find_file_up_re "$PWD" '\.nvmrc|\.node-version|package\.json' __bobthefish_prompt_find_file_up "$PWD" package.json .nvmrc .node-version
and set should_show 1 and set should_show 1
end end