summaryrefslogtreecommitdiff
path: root/home-config/fish/functions/__zoxide_z_complete.fish
diff options
context:
space:
mode:
authorRyan Schanzenbacher <ryan@rschanz.org>2024-04-12 23:09:46 -0400
committerRyan Schanzenbacher <ryan@rschanz.org>2024-04-12 23:09:46 -0400
commita8b7e972ead8df887f06537ccc017fe556f43fd3 (patch)
tree95f091f70a391b00b58062d1bf11b7860c53e178 /home-config/fish/functions/__zoxide_z_complete.fish
parent0c1f7cae6b111ab2d3bd39c85640349d7e621764 (diff)
added zoxide helper plugin
Diffstat (limited to 'home-config/fish/functions/__zoxide_z_complete.fish')
-rw-r--r--home-config/fish/functions/__zoxide_z_complete.fish15
1 files changed, 15 insertions, 0 deletions
diff --git a/home-config/fish/functions/__zoxide_z_complete.fish b/home-config/fish/functions/__zoxide_z_complete.fish
new file mode 100644
index 0000000..9e6196f
--- /dev/null
+++ b/home-config/fish/functions/__zoxide_z_complete.fish
@@ -0,0 +1,15 @@
1function __zoxide_z_complete
2 set --local tokens (commandline --current-process --tokenize)
3 set --local curr_tokens (commandline --cut-at-cursor --current-process --tokenize)
4
5 if test (count $tokens) -le 2 -a (count $curr_tokens) -eq 1
6 # If there are < 2 arguments, use `cd` completions.
7 __fish_complete_directories "$tokens[2]" ''
8 else if test (count $tokens) -eq (count $curr_tokens)
9 # If the last argument is empty, use interactive selection.
10 set --local query $tokens[2..-1]
11 set --local result (zoxide query --interactive -- $query)
12 commandline --current-process "$tokens[1] "(string escape $result)
13 commandline --function repaint
14 end
15end