diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | completion/bash.in | 61 | ||||
-rw-r--r-- | completion/bash.patch | 19 | ||||
-rwxr-xr-x | completion/make.sh | 25 |
4 files changed, 38 insertions, 71 deletions
@@ -19,7 +19,7 @@ DIST = \ COPYING \ Makefile \ pakku.conf \ - completion/bash.in \ + completion/bash.patch \ completion/make.sh \ doc/asciidoc.conf \ ${MAN_PAGES:=.txt} \ @@ -77,7 +77,7 @@ all: \ ${TARGETS} \ ${TARGETS_NODIST} -completion/bash: completion/make.sh completion/bash.in +completion/bash: completion/make.sh completion/bash.patch @echo "GEN: $@" @(cd completion && ./make.sh) diff --git a/completion/bash.in b/completion/bash.in deleted file mode 100644 index 69dba61..0000000 --- a/completion/bash.in +++ /dev/null @@ -1,61 +0,0 @@ -make_import _arch_compgen - -make_import _arch_ptr2comp - -make_import _arch_incomp - -make_import _pacman_pkg - -make_import _pacman_file - -_pakku() { - local common core cur database files prev query remove sync upgrade o - COMPREPLY=() - _get_comp_words_by_ref cur prev - database=('asdeps asexplicit') - files=('list machinereadable owns search refresh regex' 'l o s x y') - query=('changelog check deps explicit file foreign groups info list owns - search unrequired upgrades' 'c e g i k l m o p s t u') - remove=('cascade dbonly nodeps assume-installed nosave print recursive unneeded' 'c n p s u') - sync=('asdeps asexplicit clean dbonly downloadonly force groups ignore ignoregroup - info list needed nodeps assume-installed print refresh recursive search sysupgrade - build keyserver noaur source' - 'c g i l n p s u w y z') - upgrade=('asdeps asexplicit force needed nodeps assume-installed print recursive' 'p') - common=('arch cachedir color config confirm dbpath debug gpgdir help hookdir logfile - noconfirm noprogressbar noscriptlet quiet root verbose' 'b d h q r v') - core=('database files help query remove sync upgrade version' 'D F Q R S U V h') - - for o in 'D database' 'F files' 'Q query' 'R remove' 'S sync' 'U upgrade'; do - _arch_incomp "$o" && break - done - - if [[ $? != 0 ]]; then - _arch_ptr2comp core - elif [[ ! $prev =~ ^-\w*[Vbhr] && - ! $prev = --@(cachedir|color|config|dbpath|help|hookdir|gpgdir|keyserver|logfile|root|version) ]] - then - [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common || - case ${o% *} in - D|R) - _pacman_pkg Qq;; - F) - _arch_incomp 'l list' && _pacman_pkg Slq; - ;; - Q) - { _arch_incomp 'g groups' && _pacman_pkg Qg sort; } || - { _arch_incomp 'p file' && _pacman_file; } || - _arch_incomp 'o owns' || _arch_incomp 'u upgrades' || - _pacman_pkg Qq;; - S) - { _arch_incomp 'g groups' && _pacman_pkg Sg; } || - { _arch_incomp 'l list' && _pacman_pkg Sl sort; } || - _arch_compgen "`pakku -Ssq "$cur" 2> /dev/null`";; - U) - _pacman_file;; - esac - fi - true -} - -complete -F _pakku -o default pakku diff --git a/completion/bash.patch b/completion/bash.patch new file mode 100644 index 0000000..5dde344 --- /dev/null +++ b/completion/bash.patch @@ -0,0 +1,19 @@ +--- a/bash ++++ b/bash +@@ -50,2 +50,3 @@ +- info list needed nodeps assume-installed print refresh recursive search sysupgrade' +- 'c g i l p s u w y') ++ info list needed nodeps assume-installed print refresh recursive search sysupgrade ++ build keyserver noaur source' ++ 'c g i l n p s u w y z') +@@ -64,1 +65,1 @@ +- ! $prev = --@(cachedir|color|config|dbpath|help|hookdir|gpgdir|logfile|root|version) ]] ++ ! $prev = --@(cachedir|color|config|dbpath|help|hookdir|gpgdir|keyserver|logfile|root|version) ]] +@@ -81,1 +82,1 @@ +- _pacman_pkg Slq;; ++ _arch_compgen "`pakku -Ssq "$cur" 2> /dev/null`";; +@@ -93,3 +94,1 @@ +-complete -F _pacman -o default pacman +-complete -F _makepkg -o default makepkg +-complete -F _pacman_key -o default pacman-key ++complete -F _pakku -o default pakku diff --git a/completion/make.sh b/completion/make.sh index dd00d05..51b0730 100755 --- a/completion/make.sh +++ b/completion/make.sh @@ -2,11 +2,20 @@ pacman_bash_completion='/usr/share/bash-completion/completions/pacman' -(IFS=; while read -r line; do - [ "${line:0:12}" = 'make_import ' ] && { - grep -Poz '(?<=\n)'"${line:12}"'\(\) \{\n(.*\n)*?\}' "$pacman_bash_completion" | - xargs -0 - } || { - echo "$line" - } -done) < 'bash.in' > 'bash' +function delete-shell-fn() { + perl -0777 -pe 's/\n'"$1"'\(\) *\{\n([^}].*\n)*\}\n*/\n\n/g;s/\n{3,}/\n\n/g' +} + +cat "$pacman_bash_completion" | +delete-shell-fn '_pacman_keyids' | +delete-shell-fn '_pacman_key' | +delete-shell-fn '_makepkg' | +sed 's/^_pacman() {$/_pakku() {/' \ +> 'bash' || { + rm 'bash' + exit 1 +} +patch -sNp1 -r - --no-backup-if-mismatch -i 'bash.patch' || { + rm 'bash' + exit 1 +} |