-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow non-consecutive characters in query #388
Comments
I'm don't think fzf's algorithm is a great fit for zoxide. The use case is entirely different: fzf is an interactive program:
zoxide, on the other hand:
|
Thanks for your feedback. I don't quite agree with your concerns, so let me elaborate. The user will know (or quickly learn) what characters he needs to type to get a unique match, so I don't think the number of matches would increase. And the idea was that this matching algorithm would be an alternative non-default strategy, so users could continue using zoxide like they are used to. If I expand my previous example to include the directories |
You could allow non-consecutive characters in queries when using |
For anyone looking to do this right now, I've managed to hack the shell functions to use Bash/Zshfunction __zoxide_z() {
if [[ "$#" -eq 0 ]]; then
__zoxide_cd ~
elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[- ][0-9]$ ]]; }; then
__zoxide_cd "$1"
elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then
\builtin local result="${@[-1]}"
__zoxide_cd "${result:${#__zoxide_z_prefix}}"
else
\builtin local IFS=' '
\builtin local result
result="$(\command zoxide query --list --exclude "$(__zoxide_pwd)" | \command fzf --no-sort --filter "$*" | \command head -n 1)" &&
__zoxide_cd "${result}"
fi
} Fishfunction __zoxide_z
set -l argc (count $argv)
set -l completion_regex '^'(string escape --style=regex $__zoxide_z_prefix)'(.*)$'
if test $argc -eq 0
__zoxide_cd $HOME
else if test "$argv" = -
__zoxide_cd -
else if test $argc -eq 1 -a -d $argv[1]
__zoxide_cd $argv[1]
else if set -l result (string match --groups-only --regex $completion_regex $argv[-1])
__zoxide_cd $result
else
set -l result (command zoxide query --list --exclude (__zoxide_pwd) | command fzf --no-sort --filter (string join " " $argv) | command head -n 1)
and __zoxide_cd $result
end
end |
Maybe I am missing something, but if I in my history have a directory like
framework
I would like to be able to typez fwk
to change to that directory. Sincefzf
generally allows for this kind of thing, I was expecting to be able to do that with zoxide, but I couldn't find any way. If I am not missing anything, then please consider this as an enhancement request for a corresponding option.The text was updated successfully, but these errors were encountered: