Skip to content

Commit 1ef6d5b

Browse files
committed
fish: Jump to directory from interactive selector (experimental)
1 parent 878b41c commit 1ef6d5b

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

templates/fish.txt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ end
6868
# When using zoxide with --no-cmd, alias these internal functions as desired.
6969
#
7070

71-
if test -z $__zoxide_z_prefix
72-
set __zoxide_z_prefix 'z!'
73-
end
74-
set __zoxide_z_prefix_regex ^(string escape --style=regex -- $__zoxide_z_prefix)
75-
7671
# Jump to a directory using only keywords.
7772
function __zoxide_z
7873
set -l argc (builtin count $argv)
@@ -84,8 +79,6 @@ function __zoxide_z
8479
__zoxide_cd $argv[1]
8580
else if test $argc -eq 2 -a $argv[1] = --
8681
__zoxide_cd -- $argv[2]
87-
else if set -l result (string replace --regex -- $__zoxide_z_prefix_regex '' $argv[-1]); and test -n $result
88-
__zoxide_cd $result
8982
else
9083
set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
9184
and __zoxide_cd $result
@@ -100,13 +93,12 @@ function __zoxide_z_complete
10093
if test (builtin count $tokens) -le 2 -a (builtin count $curr_tokens) -eq 1
10194
# If there are < 2 arguments, use `cd` completions.
10295
complete --do-complete "'' "(builtin commandline --cut-at-cursor --current-token) | string match --regex -- '.*/$'
103-
else if test (builtin count $tokens) -eq (builtin count $curr_tokens); and ! string match --quiet --regex -- $__zoxide_z_prefix_regex. $tokens[-1]
104-
# If the last argument is empty and the one before doesn't start with
105-
# $__zoxide_z_prefix, use interactive selection.
96+
else if test (builtin count $tokens) -eq (builtin count $curr_tokens)
97+
# If the last argument is empty, use interactive selection.
10698
set -l query $tokens[2..-1]
10799
set -l result (command zoxide query --exclude (__zoxide_pwd) --interactive -- $query)
108-
and builtin echo $__zoxide_z_prefix$result
109-
builtin commandline --function repaint
100+
and __zoxide_cd $result
101+
and builtin commandline --function cancel-commandline repaint
110102
end
111103
end
112104
complete --command __zoxide_z --no-files --arguments '(__zoxide_z_complete)'

0 commit comments

Comments
 (0)