Reputation: 33225
I am trying to set up Fish shell completion for my project.
Following some tutorials, I added the following line in my ~/.config/fish/config.fish
:
complete -x -c j -a '(shonenjump --complete (commandline -t))'
In which shonenjump
is the name of the executable of my project, and j
is a shell function wrapping the binary.
I can't get completion to work, but if I repeat this command in the newly created session, it works.
Any idea how to get it right?
Upvotes: 0
Views: 802
Reputation: 15924
Setting up completions like this doesn't mark the completion file as loaded, so after, fish will still try to autoload the completion file.
And there is a completion file for a thing called "j", shipped with fish, and it explicitly erases the completions that are already set up, which ordinarily isn't necessary, but going by the commit message that tool sets broken completions, so this fixes them.
So once you press tab, fish loads that file, which erases your completions and installs its custom ones.
The way to set up completions in fish is to create your own completion file called "j.fish" in your ~/.config/fish/completions/ directory.
Or, since your tool isn't the same "j" that is apparently also known as "autojump", just call it something else.
Upvotes: 2