Fix zypper completion in fish (shell)

So I’ve been playing around with some alternatives shells and I have just about settled on fish. My only issues are with completion for zypper. Specifically it doesn’t pull package​ names while bash does. Is there any way to get fish to properly complete for zypper?

Hi
It’s present, probably in /usr/share/completions?
https://github.com/fish-shell/fish-shell/blob/master/share/completions/zypper.fish

Copy it over (or source it) to ~./config/fish/completions

Thanks, but I do have basic completion of commands (though it’s missing some options like --no-allow-vendor-change) but I’m specifically talking about completing package names for removal/installation like bash does. fish does this on other systems (such as Debian with apt and Manjaro with pacman).

Hi
So looking at the zypper.fish file it needs some additional switches added for example for vendor change in the dup section add;


complete -c zypper -n '__fish_zypper_is_subcommand_dup' -l no-allow-vendor-change        --description 'Whether to allow changing the vendor of installed resolvables'

I did this in /root/.config/fish/completions/zypper.fish copied from the user share one, make changes, test and be a good oss user and push the changes upstream :wink:

I see completion in fish with the rm command if push tab twice (to show the list)?


zypper in pit<tab tab>
pithos  (Package)  pitivi  (Package)  pitivi-lang  (Package)

Thanks! That got me to the solution, though I don’t quite understand it. I had created a completion file just to add the --no-allow-vendor-change option. I assumed it was appending it to the existing completions because all of the other command completions were still working, but apparently it was breaking this functionality. I removed my custom completion file and while --no-allow-vendor-change is not present it’s fixed the package name completion. I’ll try copying the full file and adding --no-allow-vendor-change and see if that works.

Edit: I pulled the full file into my home directory and added the no-allow-vendor-change option and it works great. I would love to submit this fix but to be honest I don’t really know how to contribute to a project like that.

Hi
You can just login to the github project and raise an issue with the suggested addition to the file (zypper.fish) just as you tested.

Ask to add;


complete -c zypper -n '__fish_zypper_is_subcommand_dup' -l no-allow-vendor-change        --description 'Whether to allow changing the vendor of installed resolvables'

There are probably more if you run the command;


zypper dup --help

However, the developer may have omitted the ‘expert commands’ on purpose. In this case specify it’s the recommended openSUSE option to update on Tumbleweed so could be considered and exception…

Thanks, I went ahead and submitted the pull request including some info about how it is recommended for Tumbleweed.

Hi
Awesome, hopefully it won’t take long to get accepted and an update released so can be included.