Because no one reported any bugs to perl-Bootloader, I have some free time. I use it to improve bash completion for zypper, because I find current one have some really annoying things. In short now completion work also for zypper global options, hint also for short version of commands and help name of repo, service and lock, if you use command which takes that as argument. Next few paragraphs contain practical examples how it help improve your command line productivity, how to get it to your system and also some notes how I implement it.
At first how you can try it. It is really easy, in 11.2 it will be part of package, 11.1 contain only old bash-completion (created by Marek Stopka), so you must download this file and save it as /etc/bash_completion.d/zypper.sh. After bash restart (simple type ‘bash’ to get new shell) you can enjoy new bash completion.
First change is that automatic hints works for all commands – long or short version and also on different zypper version (it is dynamic generated), so if you are not what is exactly name of option just use tab.
zofie:/home/jreidinger # zypper in --
Improvement is also that it work also after first option (before it hint only first option after command. Now it also help you with global zypper option, so if you don’t yet write command you can type — and get all global options.
zofie:/home/jreidinger # zypper --
What I find quite useful is that now you get hint also for repository, service or lock. I have quite long repository names and it is really annoying write it. So I usually use zypper lr to get number and then use that number instead repository name, as it is less typing. Now you can get help (problem is with names with spaces, I reported it):
zofie:/home/jreidinger # zypper ref repo-
repo-debug repo-non-oss repo-oss repo-source repo-update
So I hope you enjoy this improvements and I welcome any idea how improve it in comments.
Last paragraph is some notes about implementation. At first for compare you can look at original bash complete from marek stopka here. First what you can see, is that I remove static generating options help and create it dynamic. This really improve maintenance of this script. Only part which is static is special command handling like commands with repository, service or lock arguments. Second change is that now commands is recognized also if user use short option (e.g. when user type zypper mr and want hint for repository). This is quite easy change, as I only change awk output and remove comma between long and short version of command. Next change is more backward study of user line to find what command is typed. As you can see in original is study only previous argument. This causes problem when user want more options or use option and want help for argument. After my rewrite script is shorted by 20% and has better functionality and maintainability.
Both comments and pings are currently closed.