function path_search --description "Search your path for an executable" set --local loc (echo $PATH | tr ' ' '\n' | eval "fzf --prompt='[find:path] '") if test (count $loc) = 1 set --local cmd (rg --files -L $loc | rev | cut -d'/' -f1 | rev | tr ' ' '\n' | eval "fzf --preview='head -20 $loc/{}' --prompt='[find:exe] '") if test (count $cmd) = 1 echo $cmd else path_search end end end