diff options
author | Maarten Bezemer <maarten.bezemer@gmail.com> | 2012-02-22 10:09:28 +0100 |
---|---|---|
committer | Junichi Uekawa <dancer@netfort.gr.jp> | 2012-03-09 07:06:14 +0900 |
commit | 3531748071ead7740ab1492d6e422cd3f4fae951 (patch) | |
tree | c8fc2b79f726de52e2af8a083d63badffd57591f /bash_completion.d | |
parent | 3fa99931f655782ef9d80bc922175b073d620c68 (diff) | |
download | pbuilder-3531748071ead7740ab1492d6e422cd3f4fae951.tar pbuilder-3531748071ead7740ab1492d6e422cd3f4fae951.tar.gz |
Bug#660838: pbuilder: Add complete bash_autocompletion for all flags and arguments
Package: pbuilder
Version: 0.206
Severity: normal
Tags: patch
Currently, pbuidler only supports bash_completion for the commands (first argument) and filename completion for the .dsc file.
This patch adds additional support for all flags and filename/directory completion for flags that require this.
The patch is submitted (and accepted) to Ubuntu in two phases, see these bug reports:
- https://bugs.launchpad.net/ubuntu/+source/pbuilder/+bug/770529
- https://bugs.launchpad.net/ubuntu/+source/pbuilder/+bug/933339
Please consider to apply this patch.
Thanks in advance,
Maarten
*** bash_completion.debdiff
Diffstat (limited to 'bash_completion.d')
-rw-r--r-- | bash_completion.d/pbuilder | 70 |
1 files changed, 61 insertions, 9 deletions
diff --git a/bash_completion.d/pbuilder b/bash_completion.d/pbuilder index 1338411..2dd3a9c 100644 --- a/bash_completion.d/pbuilder +++ b/bash_completion.d/pbuilder @@ -7,21 +7,73 @@ # adapted to pbuilder, the license is GPLv2 or later. # Copyright 2007 Junichi Uekawa <dancer@debian.org> -have pbuilder && +have pbuilder && { _pbuilder() { - local cur options + local cur prev command i COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - options='--create --update --build --login --execute --dumpconfig' + _get_comp_words_by_ref cur prev - if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $( compgen -W "$options" | grep "^$cur" ) ) - elif [ "${COMP_WORDS[1]}" = --build ]; then - COMPREPLY=( $( compgen -o filenames -G "$cur*.dsc" ) ) + + if [[ $COMP_CWORD -eq 1 ]]; then + COMPREPLY=( $( compgen -W '--create --update --build --login --execute \ + --dumpconfig create update build login execute dumpconfig' -- "$cur" ) ) + return 0 + fi + + _expand || return 0 + + # find the last option flag + if [[ $cur != -* ]]; then + i=$COMP_CWORD + while [[ $prev != -* && $i != 2 ]]; do + i=$((i-1)) + prev=${COMP_WORDS[i-1]} + done fi + command=${COMP_WORDS[1]} + + case $prev in + --basetgz) + # tgz file completion + _filedir 'tgz' + return 0 + ;; + --configfile|--logfile) + # Any file + _filedir + return 0 + ;; + --buildplace|--buildresults) + # Any directory + _filedir -d + return 0 + ;; + *) + # Provide available flags + COMPREPLY=( $( compgen -W '--basetgz --buildplace --mirror --othermirror \ + --http-proxy --distribution --architecture --components --buildresult \ + --aptcache --removepackages --extrapackages --configfile --hookdir \ + --debemail --debbuildopts --logfile --pkgname-logfile --aptconfdir \ + --timeout --override-config --binary-arch --preserve-buildplace \ + --bindmounts --debug --twice --autocleanaptcache --compressprog \ + --debootstrapopts --save-after-login --save-after-exec --debootstrap' \ + -- "$cur" ) ) + if [[ $prev = @(--aptcache|--hookdir) ]]; then + # Optionally provide a directory + _filedir -d + fi + if [[ $cur != -* && $command == @(--build|build) ]]; then + # dsc file completion + _filedir "dsc" + fi + return 0 + ;; + esac + return 0 } -[ "$have" ] && complete -F _pbuilder -o filenames pbuilder +complete -F _pbuilder pbuilder +} |