68
68
# When using zoxide with --no-cmd, alias these internal functions as desired.
69
69
#
70
70
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
-
76
71
# Jump to a directory using only keywords.
77
72
function __zoxide_z
78
73
set -l argc (builtin count $argv)
@@ -84,8 +79,6 @@ function __zoxide_z
84
79
__zoxide_cd $argv[1]
85
80
else if test $argc -eq 2 -a $argv[1] = --
86
81
__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
89
82
else
90
83
set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
91
84
and __zoxide_cd $result
@@ -100,13 +93,12 @@ function __zoxide_z_complete
100
93
if test (builtin count $tokens) -le 2 -a (builtin count $curr_tokens) -eq 1
101
94
# If there are < 2 arguments, use `cd` completions.
102
95
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.
106
98
set -l query $tokens[2..-1]
107
99
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
110
102
end
111
103
end
112
104
complete --command __zoxide_z --no-files --arguments '(__zoxide_z_complete)'
0 commit comments