mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2025-02-10 23:18:30 +00:00
fish: Jump to directory from interactive selector (experimental)
This commit is contained in:
parent
878b41c937
commit
1ef6d5b8fc
@ -68,11 +68,6 @@ end
|
|||||||
# When using zoxide with --no-cmd, alias these internal functions as desired.
|
# When using zoxide with --no-cmd, alias these internal functions as desired.
|
||||||
#
|
#
|
||||||
|
|
||||||
if test -z $__zoxide_z_prefix
|
|
||||||
set __zoxide_z_prefix 'z!'
|
|
||||||
end
|
|
||||||
set __zoxide_z_prefix_regex ^(string escape --style=regex -- $__zoxide_z_prefix)
|
|
||||||
|
|
||||||
# Jump to a directory using only keywords.
|
# Jump to a directory using only keywords.
|
||||||
function __zoxide_z
|
function __zoxide_z
|
||||||
set -l argc (builtin count $argv)
|
set -l argc (builtin count $argv)
|
||||||
@ -84,8 +79,6 @@ function __zoxide_z
|
|||||||
__zoxide_cd $argv[1]
|
__zoxide_cd $argv[1]
|
||||||
else if test $argc -eq 2 -a $argv[1] = --
|
else if test $argc -eq 2 -a $argv[1] = --
|
||||||
__zoxide_cd -- $argv[2]
|
__zoxide_cd -- $argv[2]
|
||||||
else if set -l result (string replace --regex -- $__zoxide_z_prefix_regex '' $argv[-1]); and test -n $result
|
|
||||||
__zoxide_cd $result
|
|
||||||
else
|
else
|
||||||
set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
|
set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
|
||||||
and __zoxide_cd $result
|
and __zoxide_cd $result
|
||||||
@ -100,13 +93,12 @@ function __zoxide_z_complete
|
|||||||
if test (builtin count $tokens) -le 2 -a (builtin count $curr_tokens) -eq 1
|
if test (builtin count $tokens) -le 2 -a (builtin count $curr_tokens) -eq 1
|
||||||
# If there are < 2 arguments, use `cd` completions.
|
# If there are < 2 arguments, use `cd` completions.
|
||||||
complete --do-complete "'' "(builtin commandline --cut-at-cursor --current-token) | string match --regex -- '.*/$'
|
complete --do-complete "'' "(builtin commandline --cut-at-cursor --current-token) | string match --regex -- '.*/$'
|
||||||
else if test (builtin count $tokens) -eq (builtin count $curr_tokens); and ! string match --quiet --regex -- $__zoxide_z_prefix_regex. $tokens[-1]
|
else if test (builtin count $tokens) -eq (builtin count $curr_tokens)
|
||||||
# If the last argument is empty and the one before doesn't start with
|
# If the last argument is empty, use interactive selection.
|
||||||
# $__zoxide_z_prefix, use interactive selection.
|
|
||||||
set -l query $tokens[2..-1]
|
set -l query $tokens[2..-1]
|
||||||
set -l result (command zoxide query --exclude (__zoxide_pwd) --interactive -- $query)
|
set -l result (command zoxide query --exclude (__zoxide_pwd) --interactive -- $query)
|
||||||
and builtin echo $__zoxide_z_prefix$result
|
and __zoxide_cd $result
|
||||||
builtin commandline --function repaint
|
and builtin commandline --function cancel-commandline repaint
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
complete --command __zoxide_z --no-files --arguments '(__zoxide_z_complete)'
|
complete --command __zoxide_z --no-files --arguments '(__zoxide_z_complete)'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user