Interactive completion doesn't work with j<SPACE><TAB> on fish, but z<SPACE><TAB> works
My config.fish contains:
zoxide init fish --cmd j | source
This correctly redefines j and ji as the commands. However, if I try using j query<SPACE><TAB>, it works for the first time and generates a path starting with z\#. But if I try the same query again, pressing <TAB> makes fish complete the previous invocation instead of opening the interactive window. ji still works correctly.
E.g.
> j place <TAB>
# Brings up interactive window. After selection:
> j place z\#/Users/oyarsa/place
# Going back to home and trying again:
> j place <TAB>
> j place z\#/Users/oyarsa/place
Everything works correctly with the default commands.
PS: I've already checked #372 and #341, and I don't think this ticket is a duplicate.
My first guess is there might be a conflicting definition for your j function. What's the output of complete j?
❯ complete j
complete --no-files j -a '(__zoxide_z_complete)'
This seems to only happen with j. I tested with --cmd x, f, k, etc., and it works properly. I used autojump before zoxide, but it's not installed anymore, and I couldn't find any traces of it in fish's configuration:
❯ rg '\bj\b' ~/.config/fish/
/Users/oyarsa/.config/fish/config.fish
13:zoxide init fish --cmd j | source
Could you check if this file exists?
/usr/share/fish/completions/j.fish
There's a /opt/homebrew/share/fish/completions/j.fish (I'm on an M1 Mac), but I removed it and am still getting the same problem.
FWIW, both autojump, fish and zoxide were installed with brew.
I've got the same problem
- fish: 3.5.1 on MacOS M1 installed with homebrew
- zoxide 0.8.2
Fish comes with a completion in /opt/homebrew/share/fish/completions/j.fish:
function __history_completions --argument-names limit
if string match -q "" -- "$limit"
set limit 25
end
set -l tokens (commandline --current-process --tokenize)
history --prefix (commandline) | string replace -r \^$tokens[1]\\s\* "" | head -n$limit
end
# erase the stock autojump completions, which are no longer needed with this
complete -c j -e
complete -k -c j -a '(__history_completions 25)' -f
and running complete j was returning
❯❯❯ complete j
complete -k --no-files j -a '(__history_completions 25)'
So I had to remove the bundled complete it in my config.fish:
# init zoxide
complete -e j
zoxide init --cmd j fish | source
Now it seems that the zoxide complete gets initialized properly:
❯❯❯ complete j
complete --no-files j -a '(__zoxide_z_complete)'
Running the __zoxide_z_complete function directly starts fzf as expected.
I used to have autojump installed as well.
I tried adding complete -e j and complete -c j -e before the zoxide init file, and it still doesn't work. The weirdest thing is that when I first start the shell, I get
> complete j
complete --no-files j -a '(__zoxide_z_complete)'
But if I try using j, like j dev<SPC><TAB>, the next time I get this:
> complete j
complete -k --no-files j -a '(__history_completions 25)'
Note that the completion doesn't work in the first place.
If, however, I enter this directly:
> complete --no-files j -a '(__zoxide_z_complete)' -f
The completion works one time, then fails again. Even if I run the same command, it still doesn't work.
It's weird how every other key works, but j. Is there a way to completely flush whatever completion for j is in the system?
Sorry for the delay in response. Have you tried asking about this on the Fish issue tracker?
Closing this due to inactivity. Feel free to reopen / create a new issue if required.