openSUSE Lizards

Authors
Adam Jurkiewicz
Adrian Schröter (7)
Agustin Chavarria (2)
Akhil Laddha
Alex Barrios (1)
Alex Minton
Alexander Naumov (1)
Alexander Orlovskyy (3)
Alexey Eromenko
Alin M Elena (4)
Andrea Florio (17)
Andreas Jaeger (45)
Andreas Stieger (2)
Andreas van dem Helge
Andrej Semen
Andrew Wafaa (27)
Arvin Schnell (6)
Bernhard Wiedemann
Bharath Acharya
Bonnie Kurniawan
Brian G. Merrell
Bruno Friedmann (2)
Carl Fletcher (1)
Casual Programmer
Chang ChiaChin
Christoph Thiel
Christopher Hobbs (15)
Ciaran Farrell (2)
Claes Backstrom
Coly Li
Cristian Rodríguez
Daniel Bornkessel
David Bailey
David C. Rankin
Dean Hilkewich
Dinar Valeev (5)
Dirk Müller (1)
Dmitry Serpokryl (7)
Duncan Mac-Vicar
Enrique Herrera Noya
Eugene Pivnev
FabioMux (1)
Federico Lucifredi (2)
Frank Lee
Gabriele Mohr
Gerrit Beine
Helman Rene Taleno Martinez
Helmut Schaa
Henne (9)
Herbert Graeber
Holgi (2)
Hubert Mantel (1)
Ioan Vancea
J. Daniel Schmidt (1)
Jaime Andrés Vélez Osorio
James Tremblay (7)
Jan Blunck (4)
Jan Loeser (2)
Jan Madsen (1)
Jan Nieuwenhuizen
Jan-Christoph Bornschlegel (3)
Jan-Simon Möller (19)
Javier Llorente (3)
Jigish Gohil (27)
Jiri Srain (1)
Jiří Suchomel (1)
Johan Kotze (5)
John Terpstra
Joop Boonen
José Oramas M. (2)
Josef Reidinger (8)
Juergen Weigert (1)
Julio Vannini (9)
Justin Haygood
Kálmán Kéménczy
Kayo Hamid
Kevin Yeaux (11)
Klaas Freitag (31)
Klara Cihlarova
Klaus Kämpf
Klaus Singvogel
kl_eisbaer (10)
Lars Marowsky-Bree
Li Bin
Ludwig Nussel (7)
M. Edward (Ed) Borasky
M. Edwin Zakaria
M. Hill
Manuel Trujillo
Marcos David
Marcus Hüwe (10)
Marcus Meissner (1)
Marcus Moeller (1)
Marcus Schaefer (3)
Martin Lasarsch (8)
Martin Mohring (8)
Martin Schmiderer
Martin Schmidkunz
Masim "Vavai" Sugianto (20)
Matt Sealey
Mauro Parra-Miranda
Michael Andres (1)
Michael Löffler (4)
Michael Skiba
Michal Marek (3)
Michal Vyskocil (10)
Michal Zugec
Miguel Angel Barajas Hernandez (1)
Mingxi Wu
mrdocs
Nikanth Karthikesan (2)
Oprea Lucian
Oswin Zulu
Peter Nixon
Peter Pöml (4)
Petr Mladek (42)
Petr Uzel (4)
Philipp Thomas
Pragnesh Radadiya
Raul Libório
Ravi Kumar
Ray Chen
Ray Wang (1)
Raymond Wooninck
Rémy Marquis (1)
Renato de Pontes Pereira
Ricardo Chung (2)
Ricardo Varas Santana (6)
Richard Bos (9)
Robert Lihm
Robert Schweikert (3)
Roland Haidl
Roman Drahtmueller
Rossana Motta (1)
Rupert Horstkötter (10)
Sascha Manns (45)
Savin Alex V.
Sebastian Schöbinger (4)
Stanislav Visnovsky (7)
Stefan Haas (1)
Stefan Hundhammer (5)
Stefan Schubert (4)
Steffen Winterfeldt (4)
Stephan Kulow (11)
Suman Manjunath
Suresh Jayaraman (1)
Susanne Oberhauser (2)
Syamsul Qamar Ngabito
Thomas Göttlicher (5)
Thomas Jones
Thomas Schraitle (16)
Thruth Wang
Tuukka (11)
Ulrich Hecht
Vincenzo Barranco
Wilken Gottwalt
Will Stephenson (4)
Xin Wei Hu
Yuri Tsarev





 

Zypper: Improved bash completion and practical usage

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading ... Loading ...
Thursday, February 12th, 2009 by Josef Reidinger Digg!

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 --
--auto-agree-with-licenses --from
--capability --name
--debug-solver --no-force-resolution
--dry-run --no-recommends
--force --repo
--force-resolution --type

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 --
--cache-dir --plus-repo
--disable-repositories --quiet
--disable-system-resolvables --raw-cache-dir
--help --reposd-dir
--no-abbrev --root
--no-cd --rug-compatible
--no-gpg-checks --table-style
--non-interactive --verbose
--no-refresh --version
--no-remote --xmlout

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.


9 Comments

Comment by Anonymous
2009-02-12 11:02:59

hm, i´d appreciate improving to remove orphaned packages

Comment by Spyhawk
2009-02-12 12:44:44

The orphaned feature is already planned. It’s tracked in openFATE, see https://features.opensuse.org/300758

 
 
Comment by apokryphos
2009-02-12 22:03:09

Nice improvements, using them now, thanks!

Comment by Josef Reidinger
2009-02-12 22:19:42

Thanks, I am glad to hear it

 
 
Comment by Jagg
2009-02-13 08:44:34

Nice… thanks!

(your “file”-link is wrong, http://http//git.opens..... )

Comment by Josef Reidinger
2009-02-13 11:28:25

thanks, I fixed it.

 
 
Comment by Felipe Alvarez
2009-02-18 04:43:40

Exciting news. I like this kind of progress. Let’s just hope that it is working as it should when 11.2 comes out.

Comment by Josef Reidinger
2009-02-18 10:53:31

You can try some testing release of 11.2 and try it, if it works as you expect. I can improve it during testing phase, but cannot after release.

 
 
Comment by Marcel Witte
2009-03-04 23:25:49

Nice feature!
This is one feature I bedrugde ubuntu-users about (aptitude still has it, even for package-names)

But it isn’t working with sudo before zypper
Also it doesn’t work in shell-mode (“zypper sh”)

 

Sorry, the comment form is closed at this time.