From e2a76ee024fcf5ac70ebdd6bf875dd3010c193cc Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Wed, 23 Sep 2015 22:55:52 +0300 Subject: Add pkgman and finddir support. diff --git a/completions/Makefile.am b/completions/Makefile.am index 99c283c..9279511 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -411,7 +411,10 @@ bashcomp_DATA = 2to3 \ _yum \ yum-arch \ zopfli \ - zopflipng + zopflipng \ + pkgman \ + finddir + EXTRA_DIST = $(bashcomp_DATA) diff --git a/completions/finddir b/completions/finddir new file mode 100644 index 0000000..cf7f6e4 --- /dev/null +++ b/completions/finddir @@ -0,0 +1,17 @@ +_finddir() +{ + local cur words + _init_completion || return + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-l -v' -- "$cur" ) ) + else + COMPREPLY=( $( compgen -W '$( finddir -l )' -- "$cur" ) ) + fi + + return 0 +} && +complete -F _finddir finddir diff --git a/completions/pkgman b/completions/pkgman new file mode 100644 index 0000000..f1f942f --- /dev/null +++ b/completions/pkgman @@ -0,0 +1,42 @@ +_pkgman() +{ + local cur words + _init_completion || return + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + local special i + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ ${words[i]} == @(install|uninstall) ]]; then + special=${words[i]} + fi + done + + if [[ -n $special ]]; then + case $special in + install) + COMPREPLY=( $( compgen -W "$( pkgman search -a -D | awk 'NR>2 { print $2 }' )" -- "$cur" ) ) + return 0 + ;; + uninstall) + COMPREPLY=( $( compgen -W "$( pkgman search -a -i | awk 'NR>2 { print $2 }' )" -- "$cur" ) ) + return 0 + ;; + *) + return 0 + ;; + esac + fi + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-h --help' -- "$cur" ) ) + else + COMPREPLY=( $( compgen -W 'full-sync install search \ + uninstall update add-repo drop-repo list-repos refresh \ + resolve-dependencies' -- "$cur" ) ) + fi + + return 0 +} && +complete -F _pkgman pkgman -- 2.2.2