From f2bc669b217248d4fc3c99745220cb38c59c7ddc Mon Sep 17 00:00:00 2001 From: Charles Gould Date: Thu, 20 Feb 2020 02:19:12 -0500 Subject: [PATCH] fish: add path search function --- fish/functions/path_search.fish | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 fish/functions/path_search.fish diff --git a/fish/functions/path_search.fish b/fish/functions/path_search.fish new file mode 100644 index 0000000..c3ba689 --- /dev/null +++ b/fish/functions/path_search.fish @@ -0,0 +1,13 @@ +function path_search --description "Search your path for an executable" + set --local loc (echo $PATH | tr ' ' '\n' | eval "fzf $FZF_DEFAULT_OPTS --header='[find:path]'") + + if test (count $loc) = 1 + set --local cmd (rg --files -L $loc | rev | cut -d'/' -f1 | rev | tr ' ' '\n' | eval "fzf $FZF_DEFAULT_OPTS --header='[find:exe] => $loc'") + if test (count $cmd) = 1 + echo $cmd + else + path_search + end + end +end +