From 5732da2af736c40cf693354485446ab4867ecb4d Mon Sep 17 00:00:00 2001 From: "Gabriel F. T. Gomes" Date: Wed, 7 Aug 2019 09:17:13 -0300 Subject: New upstream version 2.9 --- completions/.gitignore | 27 +++- completions/2to3 | 8 +- completions/7z | 62 ++++---- completions/Makefile.am | 137 ++++++++++++++--- completions/_adb | 69 +++++++++ completions/_cal | 6 +- completions/_chsh | 2 +- completions/_dmesg | 11 +- completions/_eject | 4 +- completions/_hexdump | 5 +- completions/_hwclock | 2 +- completions/_ionice | 6 +- completions/_look | 2 +- completions/_mock | 20 +-- completions/_modules | 12 +- completions/_mount | 65 ++++++++ completions/_mount.linux | 248 ++++++++++++++++++++++++++++++ completions/_nmcli | 78 +++++----- completions/_renice | 2 +- completions/_repomanage | 4 +- completions/_reptyr | 2 +- completions/_rfkill | 10 +- completions/_rtcwake | 8 +- completions/_su | 6 +- completions/_svn | 13 +- completions/_svnadmin | 12 +- completions/_svnlook | 10 +- completions/_udevadm | 22 ++- completions/_umount | 24 +++ completions/_umount.linux | 143 ++++++++++++++++++ completions/_xm | 224 +++++++++++++++++++++++++++ completions/_yum | 41 +++-- completions/a2x | 11 +- completions/abook | 12 +- completions/aclocal | 8 +- completions/acpi | 6 +- completions/adb | 66 -------- completions/add_members | 6 +- completions/alias | 6 +- completions/ant | 15 +- completions/apache2ctl | 2 +- completions/appdata-validate | 8 +- completions/apt-build | 12 +- completions/apt-cache | 21 +-- completions/apt-get | 74 +++++---- completions/aptitude | 20 +-- completions/arch | 6 +- completions/arp | 59 ++++++++ completions/arping | 8 +- completions/arpspoof | 2 +- completions/asciidoc | 22 +-- completions/aspell | 32 ++-- completions/autoconf | 6 +- completions/automake | 8 +- completions/autoreconf | 8 +- completions/autorpm | 4 +- completions/autoscan | 8 +- completions/avctrl | 4 +- completions/badblocks | 8 +- completions/bind | 18 +-- completions/bk | 6 +- completions/brctl | 10 +- completions/btdownloadheadless.py | 4 +- completions/bts | 52 +++---- completions/bzip2 | 17 +-- completions/cancel | 17 ++- completions/cardctl | 4 +- completions/ccache | 12 +- completions/ccze | 22 +-- completions/cfagent | 2 +- completions/cfrun | 10 +- completions/chage | 12 +- completions/change_pw | 4 +- completions/check_db | 2 +- completions/check_perms | 2 +- completions/checksec | 2 +- completions/chgrp | 4 +- completions/chkconfig | 10 +- completions/chmod | 40 +++++ completions/chown | 4 +- completions/chpasswd | 14 +- completions/chromium-browser | 35 +++++ completions/chronyc | 20 +-- completions/chrpath | 6 +- completions/cksfv | 6 +- completions/cleanarch | 4 +- completions/clisp | 4 +- completions/clone_member | 4 +- completions/complete | 31 ++-- completions/config_list | 4 +- completions/configure | 8 +- completions/convert | 136 ++++++++--------- completions/cowsay | 8 +- completions/cpan2dist | 12 +- completions/cpio | 28 ++-- completions/cppcheck | 22 +-- completions/crontab | 6 +- completions/cryptsetup | 22 ++- completions/curl | 50 +++---- completions/cvs | 132 ++++++++-------- completions/cvsps | 22 +-- completions/dd | 16 +- completions/deja-dup | 3 +- completions/desktop-file-validate | 2 +- completions/dhclient | 12 +- completions/dict | 31 ++-- completions/dnssec-keygen | 48 ++++++ completions/dnsspoof | 2 +- completions/dot | 18 +-- completions/dpkg | 42 +++--- completions/dpkg-source | 16 +- completions/dselect | 7 +- completions/dsniff | 2 +- completions/dumpdb | 4 +- completions/dumpe2fs | 6 +- completions/e2freefrag | 2 +- completions/ebtables | 37 ++--- completions/ecryptfs-migrate-home | 22 +++ completions/eog | 3 +- completions/ether-wake | 4 +- completions/evince | 9 +- completions/export | 7 +- completions/faillog | 8 +- completions/fbgs | 14 +- completions/fbi | 14 +- completions/feh | 62 ++++---- completions/file | 12 +- completions/file-roller | 9 +- completions/filefrag | 2 +- completions/filesnarf | 2 +- completions/find | 22 +-- completions/find_member | 4 +- completions/fio | 89 +++++++++++ completions/firefox | 46 ++++++ completions/flake8 | 10 +- completions/freeciv | 41 +++++ completions/freeciv-gtk2 | 30 ---- completions/freeciv-server | 2 +- completions/function | 12 +- completions/fusermount | 12 +- completions/gcc | 18 ++- completions/gcl | 4 +- completions/gdb | 18 +-- completions/genaliases | 2 +- completions/genisoimage | 6 +- completions/geoiplookup | 2 +- completions/getconf | 14 +- completions/getent | 25 ++-- completions/gkrellm | 2 +- completions/gm | 4 +- completions/gnatmake | 4 +- completions/gnokii | 68 ++++----- completions/gnome-mplayer | 7 +- completions/gnome-screenshot | 31 ++++ completions/gpasswd | 8 +- completions/gpg | 18 +-- completions/gpg2 | 18 +-- completions/gpgv | 46 ++++++ completions/gphoto2 | 14 +- completions/gprof | 11 +- completions/groupadd | 4 +- completions/groupdel | 4 +- completions/groupmems | 6 +- completions/groupmod | 6 +- completions/growisofs | 8 +- completions/grpck | 10 +- completions/gzip | 13 +- completions/hcitool | 96 ++++++------ completions/hddtemp | 12 +- completions/hid2hci | 4 +- completions/hostname | 6 +- completions/hping2 | 12 +- completions/htop | 12 +- completions/htpasswd | 6 +- completions/hunspell | 42 ++++++ completions/iconv | 19 ++- completions/id | 6 +- completions/idn | 10 +- completions/ifstat | 62 ++++++++ completions/iftop | 2 +- completions/ifup | 27 +++- completions/info | 12 +- completions/inject | 2 +- completions/inotifywait | 47 ++++++ completions/insmod | 4 +- completions/installpkg | 6 +- completions/interdiff | 6 +- completions/invoke-rc.d | 14 +- completions/ip | 81 +++++----- completions/iperf | 46 +++--- completions/ipmitool | 90 ++++++----- completions/ipsec | 39 +++-- completions/iptables | 31 ++-- completions/ipv6calc | 14 +- completions/iscsiadm | 22 +-- completions/isort | 41 +++++ completions/isql | 2 +- completions/iwconfig | 54 +++---- completions/iwlist | 6 +- completions/iwpriv | 8 +- completions/iwspy | 4 +- completions/jar | 2 +- completions/jarsigner | 12 +- completions/java | 56 +++---- completions/javaws | 2 +- completions/jpegoptim | 14 +- completions/jps | 2 +- completions/jq | 54 +++++++ completions/jshint | 6 +- completions/json_xs | 31 ++++ completions/jsonschema | 29 ++++ completions/k3b | 6 +- completions/kcov | 10 +- completions/kill | 2 +- completions/killall | 8 +- completions/kldload | 2 +- completions/kldunload | 2 +- completions/koji | 34 ++--- completions/ktutil | 18 +-- completions/larch | 4 +- completions/lastlog | 8 +- completions/ldapsearch | 83 +++++----- completions/ldapvi | 24 +-- completions/lftp | 12 +- completions/lftpget | 4 +- completions/lilo | 12 +- completions/links | 107 ++++++++++--- completions/lintian | 30 ++-- completions/lisp | 4 +- completions/list_admins | 2 +- completions/list_lists | 6 +- completions/list_members | 10 +- completions/list_owners | 4 +- completions/locale-gen | 32 ++++ completions/lpq | 6 +- completions/lpr | 8 +- completions/lrzip | 25 ++-- completions/lsof | 10 +- completions/lspci | 18 +-- completions/lsscsi | 6 +- completions/lsusb | 4 +- completions/lua | 2 +- completions/luac | 2 +- completions/luseradd | 16 +- completions/luserdel | 6 +- completions/lvm | 244 +++++++++++++++--------------- completions/lz4 | 11 +- completions/lzip | 18 +-- completions/lzma | 15 +- completions/lzop | 11 +- completions/macof | 2 +- completions/mailmanctl | 6 +- completions/make | 33 ++-- completions/makepkg | 34 ++++- completions/man | 29 ++-- completions/mc | 12 +- completions/mcrypt | 20 +-- completions/mdadm | 70 ++++----- completions/mdtool | 22 +-- completions/medusa | 12 +- completions/mii-diag | 6 +- completions/mii-tool | 14 +- completions/minicom | 27 ++-- completions/mkinitrd | 4 +- completions/mktemp | 6 +- completions/mmsitepass | 2 +- completions/modinfo | 21 +-- completions/modprobe | 46 +++--- completions/monodevelop | 2 +- completions/mount | 62 -------- completions/mount.linux | 245 ------------------------------ completions/mplayer | 102 +++++++------ completions/mr | 14 +- completions/msynctool | 20 +-- completions/mtx | 6 +- completions/munin-node-configure | 4 +- completions/munin-run | 6 +- completions/munin-update | 4 +- completions/munindoc | 4 +- completions/mussh | 10 +- completions/mutt | 34 ++--- completions/mypy | 57 +++++++ completions/mysql | 60 +++++--- completions/mysqladmin | 35 +++-- completions/nc | 34 +++-- completions/ncftp | 6 +- completions/nethogs | 4 +- completions/newlist | 2 +- completions/newusers | 5 +- completions/ngrep | 7 +- completions/nmap | 4 +- completions/nproc | 4 +- completions/nslookup | 14 +- completions/nsupdate | 40 +++++ completions/ntpdate | 14 +- completions/oggdec | 14 +- completions/op | 56 +++++++ completions/openssl | 26 ++-- completions/opera | 8 +- completions/optipng | 14 +- completions/p4 | 12 +- completions/pack200 | 16 +- completions/passwd | 5 +- completions/patch | 28 ++-- completions/pdftotext | 10 +- completions/perl | 46 +++--- completions/perlcritic | 51 +++++++ completions/perltidy | 12 +- completions/pgrep | 20 +-- completions/pidof | 6 +- completions/pine | 8 +- completions/ping | 34 +++-- completions/pkg-config | 13 +- completions/pkg-get | 5 +- completions/pkg_delete | 2 +- completions/pkgadd | 2 +- completions/pkgrm | 2 +- completions/pkgtool | 6 +- completions/pkgutil | 2 +- completions/plague-client | 4 +- completions/pm-hibernate | 2 +- completions/pm-is-supported | 4 +- completions/pm-powersave | 2 +- completions/pngfix | 7 +- completions/portinstall | 8 +- completions/portupgrade | 2 +- completions/postcat | 10 +- completions/postconf | 9 +- completions/postfix | 8 +- completions/postmap | 15 +- completions/postsuper | 30 ++-- completions/povray | 6 +- completions/prelink | 2 +- completions/protoc | 8 +- completions/psql | 65 ++++---- completions/puppet | 58 +++---- completions/pv | 13 +- completions/pwck | 2 +- completions/pwd | 4 +- completions/pwdx | 4 +- completions/pwgen | 6 +- completions/py.test | 71 --------- completions/pycodestyle | 4 +- completions/pydoc | 18 ++- completions/pydocstyle | 35 +++++ completions/pyflakes | 2 +- completions/pylint | 46 ++++-- completions/pytest | 86 +++++++++++ completions/python | 33 ++-- completions/pyvenv | 2 +- completions/qdbus | 4 +- completions/qemu | 57 ++++--- completions/qrunner | 4 +- completions/querybts | 33 ++-- completions/quota | 17 +-- completions/radvdump | 4 +- completions/rcs | 6 +- completions/rdesktop | 36 ++--- completions/remove_members | 4 +- completions/removepkg | 6 +- completions/reportbug | 83 ++++++---- completions/resolvconf | 2 +- completions/ri | 36 ++--- completions/rmlist | 2 +- completions/rmmod | 2 +- completions/route | 2 +- completions/rpcdebug | 15 +- completions/rpm | 109 +++++++------- completions/rpm2tgz | 2 +- completions/rpmcheck | 4 +- completions/rrdtool | 4 +- completions/rsync | 14 +- completions/sbcl | 4 +- completions/sbopkg | 14 +- completions/screen | 32 ++-- completions/scrub | 36 +++++ completions/sh | 10 +- completions/shellcheck | 51 +++++++ completions/sitecopy | 16 +- completions/slackpkg | 36 ++--- completions/slapt-get | 16 +- completions/slapt-src | 12 +- completions/smartctl | 72 ++++----- completions/smbclient | 124 ++++++++------- completions/snownews | 2 +- completions/sqlite3 | 13 +- completions/ss | 20 +-- completions/ssh | 308 ++++++++++++++++++++++---------------- completions/ssh-add | 6 +- completions/ssh-copy-id | 11 +- completions/ssh-keygen | 32 ++-- completions/sshmitm | 2 +- completions/sshow | 8 +- completions/strace | 34 ++--- completions/strings | 19 +-- completions/sudo | 34 +++-- completions/svk | 31 ++-- completions/sync_members | 6 +- completions/synclient | 8 +- completions/sysbench | 58 ++++--- completions/sysctl | 15 +- completions/tar | 61 ++++---- completions/tcpdump | 43 ++++-- completions/tcpkill | 4 +- completions/tcpnice | 4 +- completions/timeout | 8 +- completions/tipc | 78 +++++----- completions/tox | 15 +- completions/tracepath | 5 +- completions/tshark | 111 +++++++++----- completions/tune2fs | 38 ++--- completions/ulimit | 42 ++++++ completions/umount | 21 --- completions/umount.linux | 140 ----------------- completions/unace | 4 +- completions/unpack200 | 16 +- completions/unrar | 6 +- completions/unshunt | 2 +- completions/update-alternatives | 8 +- completions/update-rc.d | 16 +- completions/upgradepkg | 8 +- completions/urlsnarf | 8 +- completions/uscan | 10 +- completions/useradd | 20 +-- completions/userdel | 8 +- completions/usermod | 22 +-- completions/valgrind | 38 ++--- completions/vipw | 6 +- completions/vmstat | 10 +- completions/vncviewer | 30 ++-- completions/vpnc | 23 ++- completions/watch | 12 +- completions/webmitm | 2 +- completions/wget | 78 +++++----- completions/wine | 2 +- completions/withlist | 4 +- completions/wodim | 25 ++-- completions/wol | 12 +- completions/wsimport | 5 +- completions/wtf | 6 +- completions/wvdial | 4 +- completions/xdg-mime | 24 +-- completions/xdg-settings | 12 +- completions/xfreerdp | 52 +++++-- completions/xgamma | 22 +-- completions/xm | 222 --------------------------- completions/xmllint | 12 +- completions/xmlwf | 12 +- completions/xmms | 10 +- completions/xmodmap | 3 +- completions/xrandr | 29 ++-- completions/xrdb | 2 +- completions/xsltproc | 6 +- completions/xxd | 2 +- completions/xz | 27 ++-- completions/xzdec | 8 +- completions/ypmatch | 10 +- completions/yum-arch | 4 +- completions/zopfli | 7 +- completions/zopflipng | 8 +- 460 files changed, 6093 insertions(+), 4428 deletions(-) create mode 100644 completions/_adb create mode 100644 completions/_mount create mode 100644 completions/_mount.linux create mode 100644 completions/_umount create mode 100644 completions/_umount.linux create mode 100644 completions/_xm delete mode 100644 completions/adb create mode 100644 completions/arp create mode 100644 completions/chmod create mode 100644 completions/chromium-browser create mode 100644 completions/dnssec-keygen create mode 100644 completions/ecryptfs-migrate-home create mode 100644 completions/fio create mode 100644 completions/firefox create mode 100644 completions/freeciv delete mode 100644 completions/freeciv-gtk2 create mode 100644 completions/gnome-screenshot create mode 100644 completions/gpgv create mode 100644 completions/hunspell create mode 100644 completions/ifstat create mode 100644 completions/inotifywait create mode 100644 completions/isort create mode 100644 completions/jq create mode 100644 completions/json_xs create mode 100644 completions/jsonschema create mode 100644 completions/locale-gen delete mode 100644 completions/mount delete mode 100644 completions/mount.linux create mode 100644 completions/mypy create mode 100644 completions/nsupdate create mode 100644 completions/op create mode 100644 completions/perlcritic delete mode 100644 completions/py.test create mode 100644 completions/pydocstyle create mode 100644 completions/pytest create mode 100644 completions/scrub create mode 100644 completions/shellcheck create mode 100644 completions/ulimit delete mode 100644 completions/umount delete mode 100644 completions/umount.linux delete mode 100644 completions/xm (limited to 'completions') diff --git a/completions/.gitignore b/completions/.gitignore index c0b4c044..06f8d013 100644 --- a/completions/.gitignore +++ b/completions/.gitignore @@ -1,5 +1,5 @@ 7za -aclocal-1.1[012345] +aclocal-1.1[0123456] alpine alternatives animate @@ -8,7 +8,7 @@ aptitude-curses arm-koji asciidoc.py autoheader -automake-1.1[012345] +automake-1.1[0123456] autossh autoupdate bsdtar @@ -17,6 +17,8 @@ btdownloadgui.py c++ cc cdrecord +chrome +chromium ci ciptool civclient @@ -41,34 +43,49 @@ dpkg-reconfigure dropdb dropuser edquota +etherwake f77 f95 filebucket +freeciv-gtk2 +freeciv-gtk3 freeciv-sdl freeciv-xaw g++ +g++-[5678] g4 g77 g95 +gcc-[5678] +gccgo +gccgo-[5678] gcj geoiplookup6 gfortran +gfortran-[5678] gkrellm2 gmake gmplayer gnumake +google-chrome +google-chrome-stable gpc +gpgv2 hciattach hciconfig hd host hping hping3 +iceweasel identify ifdown +ifquery ifstatus import +inotifywatch insmod.static +iperf3 javac javadoc kplayer @@ -81,6 +98,7 @@ ldapmodify ldapmodrdn ldappasswd ldapwhoami +links2 lintian-info lusermod lvchange @@ -102,6 +120,7 @@ micropython mkisofs mogrify montage +mozilla-firefox mplayer2 msgsnarf muttng @@ -137,14 +156,16 @@ pvremove pvs pvscan pxz +py.test py.test-[23] pydoc3 pylint-[23] +pytest-[23] python2 python3 pypy pypy3 -pyvenv-3.[45] +pyvenv-3.[45678] qemu-kvm qemu-system-i386 qemu-system-x86_64 diff --git a/completions/2to3 b/completions/2to3 index 4dd29bf4..049ba65b 100644 --- a/completions/2to3 +++ b/completions/2to3 @@ -10,12 +10,12 @@ _2to3() return ;; -f|--fix|-x|--nofix) - COMPREPLY=( $( compgen -W \ - "$( $1 --list-fixes 2>/dev/null | command sed -e 1d )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + "$($1 --list-fixes 2>/dev/null | command sed -e 1d)" -- "$cur") ) return ;; -j|--processes) - COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) return ;; -o|--output-dir) @@ -27,7 +27,7 @@ _2to3() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/7z b/completions/7z index 5599b708..96a64f1f 100644 --- a/completions/7z +++ b/completions/7z @@ -6,7 +6,7 @@ _7z() _init_completion -n = || return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'a b d e l t u x' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'a b d e l t u x' -- "$cur") ) return fi @@ -15,7 +15,7 @@ _7z() case $cur in -ao*) - COMPREPLY=( $( compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}" ) ) + COMPREPLY=( $(compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}") ) return ;; -?(a)[ix]*) @@ -26,58 +26,54 @@ _7z() opt=${cur:0:2} cur=${cur:2} fi if [[ $cur != *[@\!]* ]]; then - COMPREPLY=( $( compgen -P$opt -W '@ ! r@ r-@ r0@ r! r-! r0!' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -P$opt -W '@ ! r@ r-@ r0@ r! r-! r0!' \ + -- "$cur") ) elif [[ $cur == ?(r@(-|0|))@* ]]; then - local x tmp - x=$( compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}" ) && - while read -r tmp; do - COMPREPLY+=( "$tmp" ) - done <<< "$x" + local IFS=$' \t\n' reset=$(shopt -po noglob); set -o noglob + COMPREPLY=( $(compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}") ) + $reset compopt -o filenames fi return ;; -mhe=*|-mhc=*|-ms=*|-mt=*) - COMPREPLY=( $( compgen -W 'on off' -- "${cur#*=}" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "${cur#*=}") ) return ;; -mx=*) - COMPREPLY=( $( compgen -W '0 1 3 5 7 9' -- "${cur#*=}" ) ) + COMPREPLY=( $(compgen -W '0 1 3 5 7 9' -- "${cur#*=}") ) return ;; -o*|-w?*) - local x tmp - x=$( compgen -P${cur:0:2} -S/ -d -- "${cur:2}" ) && - while read -r tmp; do - COMPREPLY+=( "$tmp" ) - done <<< "$x" + local IFS=$' \t\n' reset=$(shopt -po noglob); set -o noglob + COMPREPLY=( $(compgen -P${cur:0:2} -S/ -d -- "${cur:2}") ) + $reset compopt -o nospace -o filenames return ;; -r?*) - COMPREPLY=( $( compgen -P${cur:0:2} -W '- 0' -- "${cur:2}" ) ) + COMPREPLY=( $(compgen -P${cur:0:2} -W '- 0' -- "${cur:2}") ) return ;; -scs*) - COMPREPLY=( $( compgen -P${cur:0:4} -W 'UTF-8 WIN DOS' \ - -- "${cur:4}" ) ) + COMPREPLY=( $(compgen -P${cur:0:4} -W 'UTF-8 WIN DOS' \ + -- "${cur:4}") ) return ;; -ssc?*) - COMPREPLY=( $( compgen -P${cur:0:4} -W '-' -- "${cur:4}" ) ) + COMPREPLY=( $(compgen -P${cur:0:4} -W '-' -- "${cur:4}") ) return ;; -t*) if [[ $mode == w ]]; then - COMPREPLY=( $( compgen -P${cur:0:2} -W '7z bzip2 gzip swfc - tar wim xz zip' -- "${cur:2}" ) ) + COMPREPLY=( $(compgen -P${cur:0:2} -W '7z bzip2 gzip swfc + tar wim xz zip' -- "${cur:2}") ) else - COMPREPLY=( $( compgen -P${cur:0:2} -W '7z apm arj bzip2 cab + COMPREPLY=( $(compgen -P${cur:0:2} -W '7z apm arj bzip2 cab chm cpio cramfs deb dmg elf fat flv gzip hfs iso lzh lzma lzma86 macho mbr mslz mub nsis ntfs pe ppmd rar rpm squashfs swf swfc tar udf vhd wim xar xz z zip' \ - -- "${cur:2}" ) ) + -- "${cur:2}") ) fi return ;; @@ -87,9 +83,9 @@ _7z() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}= + COMPREPLY=( $(compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}= -o -p -r -scs -sfx -si -slp -slt -so -ssc -t -u -v -w -x -y' \ - -- "$cur" ) ) + -- "$cur") ) [[ $COMPREPLY == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] || compopt -o nospace return @@ -99,15 +95,23 @@ _7z() _count_args = if [[ $args -eq 2 ]]; then _filedir_xspec unzip + # TODO: parsing 7z i output? + # - how to figure out if the format is input or output? + # - find string Formats:, read until next empty line + # - extensions start from column 26 + # - ignore everything in parens + # - terminate on two spaces + # - terminate on token containing anything [^a-z0-9] + # (assumption: extensions are all lowercase) [[ $mode == w ]] && _filedir '@(7z|bz2|swf|?(g)tar|?(t)[bglx]z|tb?(z)2|wim)' || - _filedir '@(7z|arj|bz2|cab|chm|cpio|deb|dmg|flv|gem|img|iso|lz[ah]|lzma?(86)|pmd|[rx]ar|rpm|sw[fm]|?(g)tar|taz|?(t)[bglx]z|tb?(z)2|vhd|wim|Z)' + _filedir '@(7z|arj|bz2|cab|chm|cpio|deb|dmg|flv|gem|img|iso|lz[ah]|lzma?(86)|msi|pmd|[rx]ar|rpm|sw[fm]|?(g)tar|taz|?(t)[bglx]z|tb?(z)2|vhd|wim|Z)' else if [[ ${words[1]} == d ]]; then local IFS=$'\n' - COMPREPLY=( $( compgen -W "$( printf '%s\n' $( $1 l ${words[2]} \ + COMPREPLY=( $(compgen -W "$(printf '%s\n' $($1 l ${words[2]} \ -slt 2>/dev/null | command sed -n '/^Path =/s/^Path = \(.*\)$/\1/p' \ - 2>/dev/null | tail -n+2 ) )" -- "$cur" ) ) + 2>/dev/null | tail -n+2))" -- "$cur") ) compopt -o filenames else _filedir diff --git a/completions/Makefile.am b/completions/Makefile.am index e442a9e6..94cca466 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -5,7 +5,7 @@ bashcomp_DATA = 2to3 \ abook \ aclocal \ acpi \ - adb \ + _adb \ add_members \ alias \ ant \ @@ -16,6 +16,7 @@ bashcomp_DATA = 2to3 \ apt-get \ aptitude \ arch \ + arp \ arping \ arpspoof \ asciidoc \ @@ -48,8 +49,10 @@ bashcomp_DATA = 2to3 \ _chfn \ chgrp \ chkconfig \ + chmod \ chown \ chpasswd \ + chromium-browser \ chronyc \ chrpath \ _chsh \ @@ -76,6 +79,7 @@ bashcomp_DATA = 2to3 \ dhclient \ dict \ _dmesg \ + dnssec-keygen \ dnsspoof \ dot \ dpkg \ @@ -87,6 +91,7 @@ bashcomp_DATA = 2to3 \ e2freefrag \ e2label \ ebtables \ + ecryptfs-migrate-home \ _eject \ eog \ ether-wake \ @@ -103,9 +108,11 @@ bashcomp_DATA = 2to3 \ filesnarf \ find \ find_member \ + fio \ + firefox \ flake8 \ freebsd-update \ - freeciv-gtk2 \ + freeciv \ freeciv-server \ function \ fusermount \ @@ -123,9 +130,11 @@ bashcomp_DATA = 2to3 \ gnatmake \ gnokii \ gnome-mplayer \ + gnome-screenshot \ gpasswd \ gpg \ gpg2 \ + gpgv \ gphoto2 \ gprof \ groupadd \ @@ -143,14 +152,17 @@ bashcomp_DATA = 2to3 \ hping2 \ htop \ htpasswd \ + hunspell \ _hwclock \ iconv \ id \ idn \ + ifstat \ iftop \ ifup \ info \ inject \ + inotifywait \ insmod \ installpkg \ interdiff \ @@ -163,6 +175,7 @@ bashcomp_DATA = 2to3 \ iptables \ ipv6calc \ iscsiadm \ + isort \ isql \ iwconfig \ iwlist \ @@ -172,9 +185,12 @@ bashcomp_DATA = 2to3 \ jarsigner \ java \ javaws \ + jq \ jpegoptim \ jps \ jshint \ + json_xs \ + jsonschema \ k3b \ kcov \ kill \ @@ -198,6 +214,7 @@ bashcomp_DATA = 2to3 \ list_members \ list_owners \ _look \ + locale-gen \ lpq \ lpr \ lrzip \ @@ -234,8 +251,8 @@ bashcomp_DATA = 2to3 \ modprobe \ _modules \ monodevelop \ - mount \ - mount.linux \ + _mount \ + _mount.linux \ mplayer \ mr \ msynctool \ @@ -246,6 +263,7 @@ bashcomp_DATA = 2to3 \ munin-update \ mussh \ mutt \ + mypy \ mysql \ mysqladmin \ nc \ @@ -259,8 +277,10 @@ bashcomp_DATA = 2to3 \ _nmcli \ nproc \ nslookup \ + nsupdate \ ntpdate \ oggdec \ + op \ openssl \ opera \ optipng \ @@ -270,6 +290,7 @@ bashcomp_DATA = 2to3 \ patch \ pdftotext \ perl \ + perlcritic \ perltidy \ pgrep \ pidof \ @@ -305,11 +326,12 @@ bashcomp_DATA = 2to3 \ pwd \ pwdx \ pwgen \ - py.test \ pycodestyle \ pydoc \ + pydocstyle \ pyflakes \ pylint \ + pytest \ python \ pyvenv \ qdbus \ @@ -343,7 +365,9 @@ bashcomp_DATA = 2to3 \ sbcl \ sbopkg \ screen \ + scrub \ sh \ + shellcheck \ sitecopy \ slackpkg \ slapt-get \ @@ -384,8 +408,9 @@ bashcomp_DATA = 2to3 \ tshark \ tune2fs \ _udevadm \ - umount \ - umount.linux \ + ulimit \ + _umount \ + _umount.linux \ unace \ unpack200 \ unrar \ @@ -418,7 +443,7 @@ bashcomp_DATA = 2to3 \ xfreerdp \ xgamma \ xhost \ - xm \ + _xm \ xmllint \ xmlwf \ xmms \ @@ -445,6 +470,7 @@ CLEANFILES = \ aclocal-1.13 \ aclocal-1.14 \ aclocal-1.15 \ + aclocal-1.16 \ alpine \ alternatives \ animate \ @@ -459,6 +485,7 @@ CLEANFILES = \ automake-1.13 \ automake-1.14 \ automake-1.15 \ + automake-1.16 \ autossh \ autoupdate \ bsdtar \ @@ -467,6 +494,8 @@ CLEANFILES = \ c++ \ cc \ cdrecord \ + chrome \ + chromium \ ci \ ciptool \ civclient \ @@ -491,34 +520,61 @@ CLEANFILES = \ dropdb \ dropuser \ edquota \ + etherwake \ f77 \ f95 \ filebucket \ + freeciv-gtk2 \ + freeciv-gtk3 \ freeciv-sdl \ freeciv-xaw \ g++ \ + g++-5 \ + g++-6 \ + g++-7 \ + g++-8 \ g4 \ g77 \ g95 \ + gcc-5 \ + gcc-6 \ + gcc-7 \ + gcc-8 \ + gccgo \ + gccgo-5 \ + gccgo-6 \ + gccgo-7 \ + gccgo-8 \ gcj \ geoiplookup6 \ gfortran \ + gfortran-5 \ + gfortran-6 \ + gfortran-7 \ + gfortran-8 \ gkrellm2 \ gmake \ gmplayer \ gnumake \ + google-chrome \ + google-chrome-stable \ gpc \ + gpgv2 \ hciattach \ hciconfig \ hd \ host \ hping \ hping3 \ + iceweasel \ identify \ ifdown \ + ifquery \ ifstatus \ import \ + inotifywatch \ insmod.static \ + iperf3 \ javac \ javadoc \ kplayer \ @@ -531,6 +587,7 @@ CLEANFILES = \ ldapmodrdn \ ldappasswd \ ldapwhoami \ + links2 \ lintian-info \ lusermod \ lvchange \ @@ -552,6 +609,7 @@ CLEANFILES = \ mkisofs \ mogrify \ montage \ + mozilla-firefox \ mplayer2 \ msgsnarf \ muttng \ @@ -587,6 +645,7 @@ CLEANFILES = \ pvs \ pvscan \ pxz \ + py.test \ py.test-2 \ py.test-3 \ pydoc3 \ @@ -594,10 +653,15 @@ CLEANFILES = \ pylint-3 \ pypy \ pypy3 \ + pytest-2 \ + pytest-3 \ python2 \ python3 \ pyvenv-3.4 \ pyvenv-3.5 \ + pyvenv-3.6 \ + pyvenv-3.7 \ + pyvenv-3.8 \ qemu-kvm \ qemu-system-i386 \ qemu-system-x86_64 \ @@ -666,7 +730,7 @@ symlinks: $(targetdir) $(DATA) $(LN_S) 7z $(targetdir)/$$file ; \ done for file in aclocal-1.10 aclocal-1.11 aclocal-1.12 aclocal-1.13 \ - aclocal-1.14 aclocal-1.15 ; do \ + aclocal-1.14 aclocal-1.15 aclocal-1.16 ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) aclocal $(targetdir)/$$file ; \ done @@ -683,7 +747,7 @@ symlinks: $(targetdir) $(DATA) $(LN_S) asciidoc $(targetdir)/$$file ; \ done for file in automake-1.10 automake-1.11 automake-1.12 automake-1.13 \ - automake-1.14 automake-1.15 ; do \ + automake-1.14 automake-1.15 automake-1.16 ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) automake $(targetdir)/$$file ; \ done @@ -711,6 +775,10 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) cardctl $(targetdir)/$$file ; \ done + for file in google-chrome google-chrome-stable chromium chrome; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) chromium-browser $(targetdir)/$$file ; \ + done for file in compgen ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) complete $(targetdir)/$$file ; \ @@ -732,13 +800,22 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) dpkg $(targetdir)/$$file ; \ done + for file in etherwake ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) ether-wake $(targetdir)/$$file ; \ + done for file in mailsnarf msgsnarf ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) filesnarf $(targetdir)/$$file ; \ done - for file in civclient freeciv-sdl freeciv-xaw ; do \ + for file in iceweasel mozilla-firefox ; do \ rm -f $(targetdir)/$$file && \ - $(LN_S) freeciv-gtk2 $(targetdir)/$$file ; \ + $(LN_S) firefox $(targetdir)/$$file ; \ + done + for file in civclient freeciv-gtk2 freeciv-gtk3 freeciv-sdl \ + freeciv-xaw ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) freeciv $(targetdir)/$$file ; \ done for file in civserver ; do \ rm -f $(targetdir)/$$file && \ @@ -748,7 +825,10 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) function $(targetdir)/$$file ; \ done - for file in cc c++ g++ gfortran f77 g77 f95 g95 gcj gpc ; do \ + for file in cc c++ g++ g++-5 g++-6 g++-7 g++-8 gfortran gfortran-5 \ + gfortran-6 gfortran-7 gfortran-8 f77 g77 f95 g95 gcj gpc \ + gccgo gccgo-5 gccgo-6 gccgo-7 gccgo-8 gcc-5 gcc-6 gcc-7 \ + gcc-8 ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) gcc $(targetdir)/$$file ; \ done @@ -764,6 +844,10 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) gkrellm $(targetdir)/$$file ; \ done + for file in gpgv2 ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) gpgv $(targetdir)/$$file ; \ + done for file in pigz ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) gzip $(targetdir)/$$file ; \ @@ -781,7 +865,7 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) hping2 $(targetdir)/$$file ; \ done - for file in ifdown ifstatus ; do \ + for file in ifdown ifquery ifstatus ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) ifup $(targetdir)/$$file ; \ done @@ -789,10 +873,18 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) info $(targetdir)/$$file ; \ done + for file in inotifywatch ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) inotifywait $(targetdir)/$$file ; \ + done for file in insmod.static ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) insmod $(targetdir)/$$file ; \ done + for file in iperf3 ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) iperf $(targetdir)/$$file ; \ + done for file in javac javadoc ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) java $(targetdir)/$$file ; \ @@ -806,6 +898,10 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) ldapsearch $(targetdir)/$$file ; \ done + for file in links2 ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) links $(targetdir)/$$file ; \ + done for file in lintian-info ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) lintian $(targetdir)/$$file ; \ @@ -900,9 +996,9 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) puppet $(targetdir)/$$file ; \ done - for file in py.test-2 py.test-3 ; do \ + for file in pytest-2 pytest-3 py.test py.test-2 py.test-3 ; do \ rm -f $(targetdir)/$$file && \ - $(LN_S) py.test $(targetdir)/$$file ; \ + $(LN_S) pytest $(targetdir)/$$file ; \ done for file in pydoc3 ; do \ rm -f $(targetdir)/$$file && \ @@ -916,7 +1012,8 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) python $(targetdir)/$$file ; \ done - for file in pyvenv-3.4 pyvenv-3.5 ; do \ + for file in pyvenv-3.4 pyvenv-3.5 pyvenv-3.6 pyvenv-3.7 \ + pyvenv-3.8 ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) pyvenv $(targetdir)/$$file ; \ done @@ -993,13 +1090,13 @@ symlinks: $(targetdir) $(DATA) all-local: targetdir = . all-local: symlinks -install-data-local: targetdir = $(DESTDIR)$(bashcompdir) -install-data-local: symlinks +install-data-hook: targetdir = $(DESTDIR)$(bashcompdir) +install-data-hook: symlinks check-local: ret=0 for file in $(bashcomp_DATA) ; do \ $${bashcomp_bash:-$${BASH:-bash}} \ - -O extglob -n $$file || ret=$$? ; \ + -O extglob -n $(srcdir)/$$file || ret=$$? ; \ done ; \ exit $$ret diff --git a/completions/_adb b/completions/_adb new file mode 100644 index 00000000..52b2cb96 --- /dev/null +++ b/completions/_adb @@ -0,0 +1,69 @@ +# adb completion -*- shell-script -*- + +# Use of this file is deprecated. Upstream completion is available in +# the Android SDK, use that instead. + +_adb_command_usage() +{ + COMPREPLY=( $(compgen -W \ + '$("$1" help 2>&1 | command grep "^ *\(adb \)\? *$2 " \ + | command sed -e "s/[]|[]/\n/g" | _parse_help -)' -- "$cur") ) +} + +_adb() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -s|-p|--algo|--key|--iv) + return + ;; + -f) + _filedir + return + ;; + esac + + local cmd i + for (( i=1; i < cword; i++ )); do + if [[ "${words[i]}" != -* && "${words[i-1]}" != -[sp] ]]; then + cmd="${words[i]}" + break + fi + done + + if [[ ! "$cmd" ]]; then + local tmp=() + if [[ ! $cur || $cur == -* ]]; then + tmp+=( $(compgen -W '$(_parse_help "$1" help)' -- "$cur") ) + fi + if [[ ! $cur || $cur != -* ]]; then + tmp+=( $($1 help 2>&1 | awk '$1 == "adb" { print $2 }') ) + tmp+=( devices connect disconnect sideload ) + fi + COMPREPLY=( $(compgen -W '${tmp[@]}' -- "$cur") ) + return + fi + + # TODO: more and better command completions + + _adb_command_usage "$1" $cmd + + case $cmd in + push|restore|sideload) + _filedir + ;; + forward) + COMPREPLY=( $(compgen -W \ + '$("$1" help 2>&1 | command sed -ne "s/^ *adb *forward *-/-/p" | \ + _parse_help -)' -- "$cur") ) + ;; + reboot) + COMPREPLY=( $(compgen -W 'bootloader recovery' -- "$cur") ) + ;; + esac +} && +complete -F _adb adb + +# ex: filetype=sh diff --git a/completions/_cal b/completions/_cal index dfe49903..9aefa704 100644 --- a/completions/_cal +++ b/completions/_cal @@ -11,7 +11,7 @@ _cal() case $prev in -m) if [[ $OSTYPE == *bsd* ]]; then - COMPREPLY=( $( compgen -W '{1..12}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..12}' -- "$cur") ) return fi ;; @@ -24,13 +24,13 @@ _cal() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi local args _count_args - [[ $args -eq 1 ]] && COMPREPLY=( $( compgen -W '{1..12}' -- "$cur" ) ) + [[ $args -eq 1 ]] && COMPREPLY=( $(compgen -W '{1..12}' -- "$cur") ) } && complete -F _cal cal ncal diff --git a/completions/_chsh b/completions/_chsh index 88e8522e..48473fe8 100644 --- a/completions/_chsh +++ b/completions/_chsh @@ -19,7 +19,7 @@ _chsh() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _allowed_users fi diff --git a/completions/_dmesg b/completions/_dmesg index 2ca7fdf1..1dff7db2 100644 --- a/completions/_dmesg +++ b/completions/_dmesg @@ -15,19 +15,18 @@ _dmesg() return ;; -f|--facility) - COMPREPLY=( $( compgen -W 'kern user mail daemon auth syslog lpr - news' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'kern user mail daemon auth syslog lpr + news' -- "$cur") ) return ;; -l|--level|-n|--console-level) - COMPREPLY=( $( compgen -W '{1..8}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") ) return ;; esac - local opts=$( _parse_help "$1" ) - [[ $opts ]] || opts=$( _parse_usage "$1" ) - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) } && complete -F _dmesg dmesg diff --git a/completions/_eject b/completions/_eject index 8f800f15..3c5838dc 100644 --- a/completions/_eject +++ b/completions/_eject @@ -13,13 +13,13 @@ _eject() return ;; -a|--auto|-i|--manualeject) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return elif [[ $prev == @(-d|--default) ]]; then return diff --git a/completions/_hexdump b/completions/_hexdump index ed5cb08b..a3c2a839 100644 --- a/completions/_hexdump +++ b/completions/_hexdump @@ -19,9 +19,8 @@ _hexdump() esac if [[ $cur == -* ]]; then - local opts="$( _parse_help "$1" )" - [[ $opts ]] || opts="$( _parse_usage "$1" )" - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + local opts="$(_parse_help "$1")" + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) return fi diff --git a/completions/_hwclock b/completions/_hwclock index 2d190283..86a29346 100644 --- a/completions/_hwclock +++ b/completions/_hwclock @@ -19,7 +19,7 @@ _hwclock() esac COMPREPLY=( - $( PATH="$PATH:/sbin" compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + $(PATH="$PATH:/sbin" compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _hwclock hwclock diff --git a/completions/_ionice b/completions/_ionice index 9b378ee8..1aa51f2a 100644 --- a/completions/_ionice +++ b/completions/_ionice @@ -37,11 +37,11 @@ _ionice() case $prev in -c) - COMPREPLY=( $( compgen -W '{0..3}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) return ;; -n) - COMPREPLY=( $( compgen -W '{0..7}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") ) return ;; -p) @@ -51,7 +51,7 @@ _ionice() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) return fi } && diff --git a/completions/_look b/completions/_look index 6ea41cce..074e924a 100644 --- a/completions/_look +++ b/completions/_look @@ -9,7 +9,7 @@ _look() _init_completion || return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur") ) fi } && complete -F _look -o default look diff --git a/completions/_mock b/completions/_mock index 9649d306..e596a4c4 100644 --- a/completions/_mock +++ b/completions/_mock @@ -13,12 +13,12 @@ _mock() for i in "${words[@]}" ; do [[ $count -eq $cword ]] && break - if [[ "$i" == --configdir ]] ; then + if [[ "$i" == --configdir ]]; then cfgdir="${words[((count+1))]}" - elif [[ "$i" == --configdir=* ]] ; then + elif [[ "$i" == --configdir=* ]]; then cfgdir=${i/*=/} fi - count=$((++count)) + (( count++ )) done case $prev in @@ -27,7 +27,7 @@ _mock() return ;; -r|--root) - COMPREPLY=( $( compgen -W "$( command ls $cfgdir )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(command ls $cfgdir)" -- "$cur") ) COMPREPLY=( ${COMPREPLY[@]/%.cfg/} ) return ;; @@ -44,21 +44,21 @@ _mock() # (e.g. ix86 chroot builds in x86_64 mock host) # This would actually depend on what the target root # can be used to build for... - COMPREPLY=( $( compgen -W "$( command rpm --showrc | \ - command sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p' )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(command rpm --showrc | \ + command sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p')" \ + -- "$cur") ) return ;; --enable-plugin|--disable-plugin) - COMPREPLY=( $( compgen -W "$plugins" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$plugins" -- "$cur") ) return ;; esac $split && return - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir '@(?(no)src.r|s)pm' diff --git a/completions/_modules b/completions/_modules index 9e48589b..36fffdf6 100644 --- a/completions/_modules +++ b/completions/_modules @@ -23,22 +23,22 @@ _module_list () { - local modules="$( command sed 's/:/ /g' <<<$LOADEDMODULES | sort )" + local modules="$(command sed 's/:/ /g' <<<$LOADEDMODULES | sort)" compgen -W "$modules" -- $1 } _module_path () { - local modules="$( command sed 's/:/ /g' <<<$MODULEPATH | sort )" + local modules="$(command sed 's/:/ /g' <<<$MODULEPATH | sort)" compgen -W "$modules" -- $1 } _module_avail () { - local modules="$( \ + local modules="$(\ module avail 2>&1 | \ command grep -E -v '^(-|$)' | \ - xargs printf '%s\n' | command sed -e 's/(default)//g' | sort )" + xargs printf '%s\n' | command sed -e 's/(default)//g' | sort)" compgen -W "$modules" -- $1 } @@ -53,8 +53,8 @@ _module () # First parameter on line -- we expect it to be a mode selection local options - options="$( module help 2>&1 | command grep -E '^[[:space:]]*\+' | \ - awk '{print $2}' | command sed -e 's/|/ /g' | sort )" + options="$(module help 2>&1 | command grep -E '^[[:space:]]*\+' | \ + awk '{print $2}' | command sed -e 's/|/ /g' | sort)" COMPREPLY=( $(compgen -W "$options" -- "$cur") ) diff --git a/completions/_mount b/completions/_mount new file mode 100644 index 00000000..494f97ba --- /dev/null +++ b/completions/_mount @@ -0,0 +1,65 @@ +# mount(8) completion -*- shell-script -*- + +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.28, use that instead. + +if [[ $OSTYPE == *linux* ]]; then + . "$BASH_SOURCE.linux" + return +fi + +# This will pull a list of possible mounts out of +# /etc/{,v}fstab, unless the word being completed contains a ':', which +# would indicate the specification of an NFS server. In that case, we +# query the server for a list of all available exports and complete on +# that instead. +# +_mount() +{ + local cur prev words cword + _init_completion -n : || return + + local sm host + + case $prev in + -t|--types) + _fstypes + return + ;; + esac + + [[ "$cur" == \\ ]] && cur="/" + + if [[ "$cur" == *:* ]]; then + for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do + [[ -x $sm ]] || continue + COMPREPLY=( $(compgen -W "$("$sm" -e ${cur%%:*} | \ + awk 'NR>1 {print $1}')" -- "${cur#*:}") ) + return + done + fi + + if [[ "$cur" == //* ]]; then + host=${cur#//} + host=${host%%/*} + if [[ -n $host ]]; then + COMPREPLY=( $(compgen -P "//$host" -W \ + "$(smbclient -d 0 -NL $host 2>/dev/null | + command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | + command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \ + -- "${cur#//$host}") ) + fi + elif [[ -r /etc/vfstab ]]; then + # Solaris + COMPREPLY=( $(compgen -W "$(awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab)" -- "$cur") ) + elif [[ ! -e /etc/fstab ]]; then + # probably Cygwin + COMPREPLY=( $(compgen -W "$($1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}')" -- "$cur") ) + else + # probably BSD + COMPREPLY=( $(compgen -W "$(awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab)" -- "$cur") ) + fi +} && +complete -F _mount -o default -o dirnames mount + +# ex: filetype=sh diff --git a/completions/_mount.linux b/completions/_mount.linux new file mode 100644 index 00000000..c74aaec6 --- /dev/null +++ b/completions/_mount.linux @@ -0,0 +1,248 @@ +# mount(8) completion -*- shell-script -*- + +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.28, use that instead. + +_mount() +{ + local cur prev words cword + _init_completion -n =: || return + + local split=false + case "$prev" in + -t|--types) + # find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1 + # FIXME: no + if [[ "$cur" == ?*,* ]]; then + prev="${cur%,*}" + cur="${cur##*,}" + split=true + fi + COMPREPLY=( $(compgen -W 'auto adfs affs autofs btrfs cifs coda + cramfs davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus + hpfs iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g + proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs + udf ufs umsdos usbfs vfat xfs' -- "$cur") ) + _fstypes + $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) + return + ;; + --bind|-B|--rbind|-R) + _filedir -d + return + ;; + -p|--pass-fd) + COMPREPLY=( $(compgen -W '{0..9}') ) + compopt -o nospace + return + ;; + -L) + COMPREPLY=( $(cd "/dev/disk/by-label/" 2>/dev/null || return; \ + compgen -f -- "$cur") ) + return + ;; + -U) + COMPREPLY=( $(cd "/dev/disk/by-uuid/" 2>/dev/null || return; \ + compgen -f -- "$cur") ) + return + ;; + -O|--test-opts) + # argument required but no completions available + return + ;; + -o|--options) + local fstype=auto # default fstype + for (( i=${#words[@]}-1; i>0; i-- )); do + if [[ "${words[i]}" == -@(t|-types)* ]]; then + if [[ "${words[i]}" == *=* ]]; then + [[ "${words[i]}" == ?*,* ]] && break + fstype="${words[i]#-*=}" + else + [[ "${words[i+1]}" == ?*,* ]] && break + fstype="${words[i+1]}" + fi + break + fi + done + # no is not a real fstype, reset to "auto" + [[ "$fstype" == no?* ]] && fstype=auto + # split options list + if [[ "$cur" == ?*,* ]]; then + prev="${cur%,*}" + cur="${cur##*,}" + split=true + fi + # no completion if $cur is opt=smth + [[ "$cur" == *=* ]] && return + # mount options + COMPREPLY=( $(compgen -W 'loop {,a}sync {,no}atime {,no}auto + {,fs,def,root}context= defaults {,no}dev {,no}diratime dirsync + {,no}exec group {,no}iversion {,no}mand _netdev nofail + {,no}relatime {,no}strictatime {,no}suid owner remount ro rw + {,no}user users' -- "$cur") ) + case "$fstype" in + adfs|auto) + COMPREPLY+=( $(compgen -W '{u,g}id= {own,oth}mask=' -- "$cur") ) + ;;& + affs|auto) + COMPREPLY+=( $(compgen -W '{u,g}id= set{u,g}id= mode= protect + usemp verbose prefix= volume= reserved= root= bs= + {,no,usr,grp}quota' -- "$cur") ) + ;;& + btrfs|auto) + COMPREPLY+=( $(compgen -W 'degraded subvol= subvolid= device= + nodatasum nodatacow nobarrier max_inline= alloc_start= + thread_pool= compress= compress-force= ssd noacl notreelog + flushoncommit metadata_ratio= {,no}space_cache clear_cache + user_subvol_rm_allowed autodefrag inode_cache' -- "$cur") ) + ;;& + cifs|auto) + COMPREPLY+=( $(compgen -W 'user= password= credentials= {u,g}id= + force{u,g}id port= servern= netbiosname= {file,dir}_mode= + ip= domain= guest iocharset {,no}setuids {,no,dyn}perm + directio {,no}mapchars {,no}intr hard soft noacl nocase sec= + nobrl sfu {,no}serverino nounix nouser_xattr {r,w}size= + rwpidforward backup{u,g}id cache=' -- "$cur") ) + ;;& + davfs|auto) + COMPREPLY+=( $(compgen -W 'conf= {file,dir}_mode= {u,g}id= + username=' -- "$cur") ) + ;;& + ext[2-4]|auto) + COMPREPLY+=( $(compgen -W '{,no}acl bsddf minixdf check= debug + errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota + nobh nouid32 oldalloc orlov res{u,g}id= sb= + {,no}user_xattr' -- "$cur") ) + ;;& + ext[34]|auto) + COMPREPLY+=( $(compgen -W 'journal= journal_dev= norecovery + noload data= barrier= commit=' -- "$cur") ) + ;;& + ext4|auto) + COMPREPLY+=( $(compgen -W 'journal_checksum journal_async_commit + nobarrier inode_readahead= stripe= {,no}delalloc abort + {max,min}_batch_time= journal_ioprio= {,no}auto_da_alloc + {,no}discard nouid32 resize {,no}block_validity + dioread_{,no}lock max_dir_size_kb= i_version' -- "$cur") ) + ;;& + msdos|umsdos|vfat|auto) + COMPREPLY+=( $(compgen -W 'blocksize= {u,g}id= {u,d,f}mask= + allow_utime= check= codepage= conv= cvf_format= cvf_option= + debug fat= iocharset= tz= quiet showexec sys_immutable flush + usefree {,no}dots dotsOK=' -- "$cur") ) + ;;& + vfat|auto) + COMPREPLY+=( $(compgen -W 'uni_xlate posix nonumtail utf8 + shortname=' -- "$cur") ) + ;;& + iso9660|auto) + COMPREPLY+=( $(compgen -W 'norock nojoliet check= {u,g}id= map= + mode= unhide block= conv= cruft session= sbsector= + iocharset= utf8' -- "$cur") ) + ;;& + jffs2|auto) + COMPREPLY+=( $(compgen -W 'compr= rp_size=' -- "$cur") ) + ;;& + jfs|auto) + COMPREPLY+=( $(compgen -W 'iocharset= resize= {,no}integrity + errors= {,no,usr,grp}quota' -- "$cur") ) + ;;& + nfs|nfs4|auto) + COMPREPLY+=( $(compgen -W 'soft hard timeo= retrans= {r,w}size= + {,no}ac acreg{min,max}= acdir{min,max}= actimeo= bg fg + retry= sec= {,no}sharecache {,no}resvport lookupcache= + proto= port= {,no}intr {,no}cto {,nfs}vers= ' -- "$cur") ) + ;;& + nfs|auto) + COMPREPLY+=( $(compgen -W 'udp tcp rdma mount{port,proto,host}= + mountvers= namlen={,no}lock {,no}acl {,no}rdirplus + {,no}fsc' -- "$cur") ) + ;;& + nfs4|auto) + COMPREPLY+=( $(compgen -W 'clientaddr= {,no}migration' \ + -- "$cur") ) + ;;& + ntfs-3g) + COMPREPLY+=( $(compgen -W '{u,g}id= {u,f,d}mask= usermapping= + permissions inherit locale= force {,no}recover + ignore_case remove_hiberfile show_sys_files + hide_{hid,dot}_files windows_names allow_other max_read= + silent no_def_opts streams_interface= user_xattr efs_raw + {,no}compression debug no_detach' -- "$cur") ) + ;;& + proc|auto) + COMPREPLY+=( $(compgen -W '{u,g}id=' -- "$cur") ) + ;;& + reiserfs|auto) + COMPREPLY+=( $(compgen -W 'conv hash= {,no_un}hashed_relocation + noborder nolog notail replayonly resize= user_xattr acl + barrier=' -- "$cur") ) + ;;& + tmpfs|auto) + COMPREPLY+=( $(compgen -W 'size= nr_blocks= nr_inodes= mode= + {u,g}id= mpol=' -- "$cur") ) + ;;& + udf|auto) + COMPREPLY+=( $(compgen -W '{u,g}id= umask= unhide undelete + nostrict iocharset bs= novrs session= anchor= volume= + partition= lastblock= fileset= rootdir=' -- "$cur") ) + ;;& + usbfs|auto) + COMPREPLY+=( $(compgen -W 'dev{u,g}id= devmode= bus{u,g}id= + busmode= list{u,g}id= listmode=' -- "$cur") ) + ;;& + xfs|auto) + COMPREPLY+=( $(compgen -W 'allocsize= {,no}attr2 barrier dmapi + {,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep + inode{32,64} {,no}largeio logbufs= logbsize= logdev= + rtdev= mtpt= noalign norecovery nouuid osyncisosync + {u,g,p}qnoenforce {,u,usr,g,grp,p,prj}quota sunit= swidth= + swalloc' -- "$cur") ) + ;;& + esac + # COMP_WORDBREAKS is a real pain in the ass + prev="${prev##*[$COMP_WORDBREAKS]}" + $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '--version --help --verbose --all --fork + --fake --internal-only -l --no-mtab --no-canonicalize --pass-fd -s + --read-only --rw -L -U --types --test-opts --options --bind --rbind + --move' -- "$cur") ) + [[ $COMPREPLY ]] && return + fi + + [[ "$cur" == \\ ]] && cur="/" + + local sm host + + if [[ "$cur" == *:* ]]; then + for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do + [[ -x $sm ]] || continue + COMPREPLY=( $(compgen -W "$("$sm" -e ${cur%%:*} | \ + awk 'NR>1 {print $1}')" -- "${cur#*:}") ) + return + done + fi + + if [[ "$cur" == //* ]]; then + host=${cur#//} + host=${host%%/*} + if [[ -n $host ]]; then + COMPREPLY=( $(compgen -P "//$host" -W \ + "$(smbclient -d 0 -NL $host 2>/dev/null | + command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | + command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p' )" \ + -- "${cur#//$host}") ) + fi + fi + + _filedir +} && +complete -F _mount mount + +# ex: filetype=sh diff --git a/completions/_nmcli b/completions/_nmcli index f77f0505..780a477f 100644 --- a/completions/_nmcli +++ b/completions/_nmcli @@ -5,33 +5,33 @@ _nmcli_list() { - COMPREPLY=( $( compgen -W '$1' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$1' -- "$cur") ) } _nmcli_con_id() { local IFS=$'\n' - COMPREPLY=( $( compgen -W "$(nmcli con list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $1 }')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(nmcli con list 2>/dev/null | \ + tail -n +2 | awk -F ' {2,}' '{print $1 }')" -- "$cur") ) } _nmcli_con_uuid() { - COMPREPLY=( $( compgen -W "$(nmcli con list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(nmcli con list 2>/dev/null | \ + tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur") ) } _nmcli_ap_ssid() { local IFS=$'\n' - COMPREPLY=( $( compgen -W "$(nmcli dev wifi list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $1}')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(nmcli dev wifi list 2>/dev/null | \ + tail -n +2 | awk -F ' {2,}' '{print $1}')" -- "$cur") ) } _nmcli_ab_bssid() { - COMPREPLY=( $( compgen -W "$(nmcli dev wifi list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(nmcli dev wifi list 2>/dev/null | \ + tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur") ) } _nmcli() @@ -41,11 +41,11 @@ _nmcli() case $prev in -m|--mode) - COMPREPLY=( $( compgen -W 'tabular multiline' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'tabular multiline' -- "$cur") ) return ;; -f|--fields) - COMPREPLY=( $( compgen -W 'all common' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'all common' -- "$cur") ) return ;; -e|--escape) @@ -74,12 +74,12 @@ _nmcli() ;; esac - if [[ $cword -eq 1 ]] ; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--terse --pretty --mode --fields - --escape --version --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--terse --pretty --mode --fields + --escape --version --help' -- "$cur") ) else - COMPREPLY=( $( compgen -W "nm con dev" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "nm con dev" -- "$cur") ) fi else local object=${words[1]} @@ -110,50 +110,50 @@ _nmcli() ;; esac - COMPREPLY=( $( compgen -W 'status permissions enable sleep - wifi wwan wimax' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'status permissions enable sleep + wifi wwan wimax' -- "$cur") ) ;; con) case $command in list) - COMPREPLY=( $( compgen -W 'id uuid' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) return ;; up) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--nowait --timeout' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--nowait --timeout' \ + -- "$cur") ) else - COMPREPLY=( $( compgen -W 'id uuid iface ap nsp' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'id uuid iface ap nsp' \ + -- "$cur") ) fi return ;; down) - COMPREPLY=( $( compgen -W 'id uuid' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) return ;; delete) - COMPREPLY=( $( compgen -W 'id uuid' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) return ;; esac - COMPREPLY=( $( compgen -W 'list status up down delete' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'list status up down delete' \ + -- "$cur") ) ;; dev) case $command in list) - COMPREPLY=( $( compgen -W 'iface' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'iface' -- "$cur") ) return ;; disconnect) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--nowait --timeout' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--nowait --timeout' \ + -- "$cur") ) else - COMPREPLY=( $( compgen -W 'iface' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'iface' -- "$cur") ) fi return ;; @@ -162,34 +162,34 @@ _nmcli() case $subcommand in list) - COMPREPLY=( $( compgen -W 'iface bssid' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'iface bssid' \ + -- "$cur") ) return ;; connect) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--private - --nowait --timeout' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--private + --nowait --timeout' -- "$cur") ) else if [[ "$prev" == "connect" ]]; then _nmcli_ap_ssid else - COMPREPLY=( $( compgen -W 'password + COMPREPLY=( $(compgen -W 'password wep-key-type iface bssid name' \ - -- "$cur" ) ) + -- "$cur") ) fi fi return ;; esac - COMPREPLY=( $( compgen -W 'list connect' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'list connect' -- "$cur") ) return ;; esac - COMPREPLY=( $( compgen -W 'status list disconnect wifi' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'status list disconnect wifi' \ + -- "$cur") ) ;; esac diff --git a/completions/_renice b/completions/_renice index 1f1a6102..2598533d 100644 --- a/completions/_renice +++ b/completions/_renice @@ -24,7 +24,7 @@ _renice() _pids ;; esac - i=$(( ++i )) + (( i++ )) done } && complete -F _renice renice diff --git a/completions/_repomanage b/completions/_repomanage index c1072e79..ea27f07e 100644 --- a/completions/_repomanage +++ b/completions/_repomanage @@ -12,8 +12,8 @@ _repomanage() $split && return - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir -d diff --git a/completions/_reptyr b/completions/_reptyr index 4a087b49..00cccddd 100644 --- a/completions/_reptyr +++ b/completions/_reptyr @@ -15,7 +15,7 @@ _reptyr() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/_rfkill b/completions/_rfkill index e807d976..a14a3eaf 100644 --- a/completions/_rfkill +++ b/completions/_rfkill @@ -9,18 +9,18 @@ _rfkill() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--version' -- "$cur") ) else case $cword in 1) - COMPREPLY=( $( compgen -W "help event list block unblock" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "help event list block unblock" \ + -- "$cur") ) ;; 2) if [[ $prev == block || $prev == unblock ]]; then - COMPREPLY=( $( compgen -W "$($1 list | awk -F: \ + COMPREPLY=( $(compgen -W "$($1 list | awk -F: \ '/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \ - wwan gps" -- "$cur" ) ) + wwan gps" -- "$cur") ) fi ;; esac diff --git a/completions/_rtcwake b/completions/_rtcwake index b03c1244..43d264c9 100644 --- a/completions/_rtcwake +++ b/completions/_rtcwake @@ -13,19 +13,19 @@ _rtcwake() return ;; --mode|-m) - COMPREPLY=( $( compgen -W 'standby mem disk on no off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'standby mem disk on no off' -- "$cur") ) return ;; --device|-d) - COMPREPLY=( $( command ls -d /dev/rtc?* 2>/dev/null ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur" ) ) + COMPREPLY=( $(command ls -d /dev/rtc?* 2>/dev/null) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur") ) return ;; esac $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _rtcwake rtcwake diff --git a/completions/_su b/completions/_su index 2b069498..9c0f59c1 100644 --- a/completions/_su +++ b/completions/_su @@ -21,7 +21,7 @@ _su() # linux-specific completion -c|--command|--session-command) local IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -d -c -- "$cur" ) ) + COMPREPLY=( $(compgen -d -c -- "$cur") ) return ;; esac @@ -29,12 +29,12 @@ _su() # linux-specific completion $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) } && complete -F _su su diff --git a/completions/_svn b/completions/_svn index 37b6b2b4..42e2dbe7 100644 --- a/completions/_svn +++ b/completions/_svn @@ -16,11 +16,11 @@ _svn() proplist plist pl propset pset ps resolved revert \ status stat st switch sw unlock update up' - if [[ $cword -eq 1 ]] ; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--version' -- "$cur") ) else - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) fi else @@ -34,8 +34,7 @@ _svn() return ;; --encoding) - COMPREPLY=( $( compgen -W '$( iconv --list | \ - command sed -e "s@//@@;" )' -- "$cur" ) ) + _xfunc iconv _iconv_charsets return ;; --editor-cmd|--diff-cmd|--diff3-cmd) @@ -196,10 +195,10 @@ _svn() esac options+=" --help --config-dir" - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) else if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) else _filedir fi diff --git a/completions/_svnadmin b/completions/_svnadmin index 395ae119..7a86c43e 100644 --- a/completions/_svnadmin +++ b/completions/_svnadmin @@ -12,11 +12,11 @@ _svnadmin() commands='create deltify dump help ? hotcopy list-dblogs list-unused-dblogs load lslocks lstxns recover rmlocks rmtxns setlog verify' - if [[ $cword -eq 1 ]] ; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--version' -- "$cur") ) else - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) fi else case $prev in @@ -25,7 +25,7 @@ _svnadmin() return ;; --fs-type) - COMPREPLY=( $( compgen -W 'fsfs bdb' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'fsfs bdb' -- "$cur") ) return ;; esac @@ -62,10 +62,10 @@ _svnadmin() esac options+=" --help" - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) else if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) else _filedir fi diff --git a/completions/_svnlook b/completions/_svnlook index a4f34243..2cbd134b 100644 --- a/completions/_svnlook +++ b/completions/_svnlook @@ -12,11 +12,11 @@ _svnlook() commands='author cat changed date diff dirs-changed help ? h history info lock log propget pget pg proplist plist pl tree uuid youngest' - if [[ $cword -eq 1 ]] ; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--version' -- "$cur") ) else - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) fi else local command=${words[1]} @@ -47,10 +47,10 @@ _svnlook() esac options+=" --help" - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) else if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) else _filedir fi diff --git a/completions/_udevadm b/completions/_udevadm index 80424dca..ce43f1ad 100644 --- a/completions/_udevadm +++ b/completions/_udevadm @@ -24,12 +24,12 @@ _udevadm() return ;; --log-priority) - COMPREPLY=( $( compgen -W 'err info debug' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'err info debug' -- "$cur") ) return ;; --query) - COMPREPLY=( $( compgen -W 'name symlink path property all' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'name symlink path property all' \ + -- "$cur") ) return ;; --name) @@ -42,11 +42,11 @@ _udevadm() return ;; --action) - COMPREPLY=( $( compgen -W 'add change remove' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'add change remove' -- "$cur") ) return ;; --type) - COMPREPLY=( $( compgen -W 'devices subsystems failed' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'devices subsystems failed' -- "$cur") ) return ;; esac @@ -56,21 +56,19 @@ _udevadm() if [[ -z $udevcmd ]]; then case $cur in -*) - COMPREPLY=( $( compgen -W '--help --version --debug' -- \ - "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --version --debug' -- "$cur") ) ;; *) - COMPREPLY=( $( compgen -W "$( "$1" --help 2>/dev/null | - awk '/^[ \t]/ { print $1 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$("$1" --help 2>/dev/null | + awk '/^[ \t]/ { print $1 }')" -- "$cur") ) ;; esac return fi if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W \ - '$( "$1" $udevcmd --help 2>/dev/null | _parse_help - )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$("$1" $udevcmd --help 2>/dev/null | _parse_help -)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/_umount b/completions/_umount new file mode 100644 index 00000000..a5d338bc --- /dev/null +++ b/completions/_umount @@ -0,0 +1,24 @@ +# umount(8) completion -*- shell-script -*- + +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.28, use that instead. + +if [[ $OSTYPE == *linux* ]]; then + . "$BASH_SOURCE.linux" + return +fi + +# umount(8) completion. This relies on the mount point being the third +# space-delimited field in the output of mount(8) +# +_umount() +{ + local cur prev words cword + _init_completion || return + + local IFS=$'\n' + COMPREPLY=( $(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur") ) +} && +complete -F _umount -o dirnames umount + +# ex: filetype=sh diff --git a/completions/_umount.linux b/completions/_umount.linux new file mode 100644 index 00000000..59727b4b --- /dev/null +++ b/completions/_umount.linux @@ -0,0 +1,143 @@ +# umount(8) completion -*- shell-script -*- + +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.28, use that instead. + +# Just like COMPREPLY=(`compgen -W "${COMPREPLY[*]}" -- "$cur"`), only better! +# +# This will correctly escape special characters in COMPREPLY. +_reply_compgen_array() +{ + # Create the argument for compgen -W by escaping twice. + # + # One round of escape is because we want to reply with escaped arguments. A + # second round is required because compgen -W will helpfully expand it's + # argument. + local i wlist + for i in ${!COMPREPLY[*]}; do + local q=$(quote "$(printf %q "${COMPREPLY[$i]}")") + wlist+=$q$'\n' + done + + # We also have to add another round of escaping to $cur. + local ecur="$cur" + ecur=${ecur//\\/\\\\} + ecur=${ecur//\'/\\\'} + + # Actually generate completions. + local oldifs=$IFS + IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)' + IFS=$oldifs +} + +# Unescape strings in the linux fstab(5) format (with octal escapes). +__linux_fstab_unescape() { + eval $1="'${!1//\'/\\047}'" + eval $1="'${!1/%\\/\\\\}'" + eval "$1=$'${!1}'" +} + +# Complete linux fstab entries. +# +# Reads a file from stdin in the linux fstab(5) format; as used by /etc/fstab +# and /proc/mounts. +_linux_fstab() +{ + COMPREPLY=() + + # Read and unescape values into COMPREPLY + local fs_spec fs_file fs_other + local oldifs="$IFS" + while read -r fs_spec fs_file fs_other; do + if [[ $fs_spec == [#]* ]]; then continue; fi + if [[ $1 == -L ]]; then + local fs_label=${fs_spec/#LABEL=} + if [[ $fs_label != "$fs_spec" ]]; then + __linux_fstab_unescape fs_label + IFS=$'\0' + COMPREPLY+=("$fs_label") + IFS=$oldifs + fi + else + __linux_fstab_unescape fs_spec + __linux_fstab_unescape fs_file + IFS=$'\0' + [[ $fs_spec == */* ]] && COMPREPLY+=("$fs_spec") + [[ $fs_file == */* ]] && COMPREPLY+=("$fs_file") + IFS=$oldifs + fi + done + + # Add relative paths to COMPREPLY + if [[ $cur && $cur != /* ]]; then + local realcur + [[ $cur == */ ]] && # don't let readlink drop last / from path + realcur="$(readlink -f "$cur." 2>/dev/null)/" || + realcur=$(readlink -f "$cur" 2>/dev/null) + if [[ $realcur ]]; then + local dirrealcur="" dircur="" basecur + if [[ $cur == */* ]]; then + dirrealcur="${realcur%/*}/" + dircur="${cur%/*}/" + fi + basecur=${cur#"$dircur"} + local i n=${#COMPREPLY[@]} + for (( i=0; i < $n; i++ )); do + [[ "${COMPREPLY[i]}" == "$realcur"* ]] && + COMPREPLY+=( $(cd "$dircur" 2>/dev/null && + compgen -f -d -P "$dircur" \ + -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur") ) + done + fi + fi + + _reply_compgen_array +} + +_umount() +{ + local cur prev words cword + _init_completion || return + + case "$prev" in + -t) + # FIXME: no + local split=false + if [[ "$cur" == ?*,* ]]; then + prev="${cur%,*}" + cur="${cur##*,}" + split=true + fi + COMPREPLY=( $(compgen -W 'adfs affs autofs btrfs cifs coda + cramfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs + iso9660 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc qnx4 + ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs + umsdos usbfs vfat xfs' -- "$cur") ) + _fstypes + $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) + return + ;; + -O) + # argument required but no completions available + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l + --no-canonicalize --fake' -- "$cur") ) + [[ $COMPREPLY ]] && return + fi + + if [[ -r /proc/mounts ]]; then + # Linux /proc/mounts is properly quoted. This is important when + # unmounting usb devices with pretty names. + _linux_fstab /dev/null | \ + awk '!/Name|Domain-0/ { print $1 }')" -- "$cur") ) +} + +_xen_domain_ids() +{ + COMPREPLY=( $(compgen -W "$(xm list 2>/dev/null | \ + awk '!/Name|Domain-0/ { print $2 }')" -- "$cur") ) +} + +_xm() +{ + local cur prev words cword + _init_completion || return + + # TODO: _split_longopt + + local args command commands options + + commands='console vncviewer create new delete destroy domid domname + dump-core list mem-max mem-set migrate pause reboot rename reset + restore resume save shutdown start suspend sysrq trigger top unpause + uptime usb-add usb-del vcpu-list vcpu-pin vcpu-set debug-keys dmesg + info log serve sched-credit sched-sedf block-attach block-detach + block-list block-configure network-attach network-detach network-list + vtpm-list pci-attach pci-detach pci-list pci-list-assignable-devices + scsi-attach scsi-detach scsi-list vnet-list vnet-create vnet-delete + labels addlabel rmlabel getlabel dry-run resources dumppolicy setpolicy + resetpolicy getpolicy shell help' + + if [[ $cword -eq 1 ]]; then + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + else + if [[ "$cur" == *=* ]]; then + prev=${cur/=*/} + cur=${cur/*=/} + fi + + command=${words[1]} + if [[ "$cur" == -* ]]; then + # possible options for the command + case $command in + create) + options='-c' + ;; + dmesg) + options='--clear' + ;; + list) + options='--long' + ;; + reboot) + options='-w -a' + ;; + shutdown) + options='-w -a -R -H' + ;; + sched-credit) + options='-d -w -c' + ;; + block-list|network-list|vtpm-list|vnet-list) + options='-l --long' + ;; + getpolicy) + options='--dumpxml' + ;; + new) + options='-h --help --help_config -q --quiet --path= -f= + --defconfig= -F= --config= -b --dryrun -x --xmldryrun + -s --skipdtd -p --paused -c --console_autoconnect' + ;; + esac + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + else + case $command in + console|destroy|domname|domid|list|mem-set|mem-max| \ + pause|reboot|rename|shutdown|unpause|vcpu-list|vcpu-pin| \ + vcpu-set|block-list|network-list|vtpm-list) + _count_args + case $args in + 2) + _xen_domain_names + ;; + esac + ;; + migrate) + _count_args + case $args in + 2) + _xen_domain_names + ;; + 3) + _known_hosts_real -- "$cur" + ;; + esac + ;; + restore|dry-run|vnet-create) + _filedir + ;; + save) + _count_args + case $args in + 2) + _xen_domain_names + ;; + 3) + _filedir + ;; + esac + ;; + sysrq) + _count_args + case $args in + 2) + _xen_domain_names + ;; + 3) + COMPREPLY=( $(compgen -W "r s e i u b" -- "$cur") ) + ;; + esac + ;; + block-attach) + _count_args + case $args in + 2) + _xen_domain_names + ;; + 3) + COMPREPLY=( $(compgen -W "phy: file:" -- "$cur") ) + ;; + 5) + COMPREPLY=( $(compgen -W "w r" -- "$cur") ) + ;; + 6) + _xen_domain_names + ;; + esac + ;; + block-detach) + _count_args + case $args in + 2) + _xen_domain_names + ;; + 3) + COMPREPLY=( $(compgen -W "$(xm block-list $prev \ + 2>/dev/null | awk '!/Vdev/ { print $1 }')" \ + -- "$cur") ) + ;; + esac + ;; + network-attach) + _count_args + case $args in + 2) + _xen_domain_names + ;; + *) + COMPREPLY=( $(compgen -W "script= ip= mac= bridge= + backend=" -- "$cur") ) + ;; + esac + ;; + network-detach) + _count_args + case $args in + 2) + _xen_domain_names + ;; + 3) + COMPREPLY=( $(compgen -W "$(xm network-list $prev \ + 2>/dev/null | awk '!/Idx/ { print $1 }')" \ + -- "$cur") ) + ;; + esac + ;; + sched-credit) + case $prev in + -d) + _xen_domain_names + return + ;; + esac + ;; + create) + _filedir + COMPREPLY+=( \ + $(compgen -W '$(command ls /etc/xen 2>/dev/null)' \ + -- "$cur") ) + ;; + new) + case $prev in + -f|-F|--defconfig|--config) + _filedir + return + ;; + --path) + _filedir -d + return + ;; + esac + + _count_args + case $args in + 2) + _xen_domain_names + ;; + esac + ;; + esac + fi + fi +} && +complete -F _xm xm + +# ex: filetype=sh diff --git a/completions/_yum b/completions/_yum index f3a104bd..d5e06eca 100644 --- a/completions/_yum +++ b/completions/_yum @@ -5,16 +5,16 @@ _yum_list() { - if [[ "$1" == all ]] ; then + if [[ "$1" == all ]]; then # Try to strip in between headings like "Available Packages" # This will obviously only work for English :P - COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \ + COMPREPLY=( $(yum -d 0 -C list $1 "$cur*" 2>/dev/null | \ command sed -ne '/^Available /d' -e '/^Installed /d' -e '/^Updated /d' \ - -e 's/[[:space:]].*//p' ) ) + -e 's/[[:space:]].*//p') ) else # Drop first line (e.g. "Updated Packages") - COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \ - command sed -ne 1d -e 's/[[:space:]].*//p' ) ) + COMPREPLY=( $(yum -d 0 -C list $1 "$cur*" 2>/dev/null | \ + command sed -ne 1d -e 's/[[:space:]].*//p') ) fi } @@ -75,22 +75,22 @@ _yum() case $prev in list) - COMPREPLY=( $( compgen -W 'all available updates installed extras - obsoletes recent' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'all available updates installed extras + obsoletes recent' -- "$cur") ) ;; clean) - COMPREPLY=( $( compgen -W 'packages headers metadata cache dbcache - all' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'packages headers metadata cache dbcache + all' -- "$cur") ) ;; repolist) - COMPREPLY=( $( compgen -W 'all enabled disabled' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'all enabled disabled' -- "$cur") ) ;; localinstall|localupdate) # TODO: should not match *src.rpm _filedir rpm ;; -d|-e) - COMPREPLY=( $( compgen -W '{0..10}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") ) ;; -c) _filedir @@ -99,21 +99,20 @@ _yum() _filedir -d ;; --enablerepo) - COMPREPLY=( $( compgen -W '$( _yum_repolist disabled )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_yum_repolist disabled)' -- "$cur") ) ;; --disablerepo) - COMPREPLY=( $( compgen -W '$( _yum_repolist enabled )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_yum_repolist enabled)' -- "$cur") ) ;; --disableexcludes) - COMPREPLY=( $( compgen -W '$( _yum_repolist all ) all main' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_yum_repolist all) all main' \ + -- "$cur") ) ;; --enableplugin|--disableplugin) - COMPREPLY=( $( compgen -W '$( _yum_plugins )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_yum_plugins)' -- "$cur") ) ;; --color) - COMPREPLY=( $( compgen -W 'always auto never' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'always auto never' -- "$cur") ) ;; -R|-x|--exclude) # argument required but no completions available @@ -124,18 +123,18 @@ _yum() return ;; *) - COMPREPLY=( $( compgen -W 'install update check-update upgrade + COMPREPLY=( $(compgen -W 'install update check-update upgrade remove erase list info provides whatprovides clean makecache groupinstall groupupdate grouplist groupremove groupinfo search shell resolvedep localinstall localupdate deplist - repolist help' -- "$cur" ) ) + repolist help' -- "$cur") ) ;; esac $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/a2x b/completions/a2x index 06c7c3a4..cf9f9516 100644 --- a/completions/a2x +++ b/completions/a2x @@ -6,15 +6,15 @@ _a2x() _init_completion -s || return case $prev in - -a|--attribute|--asciidoc-opts|--dblatex-opts|--fop-opts|-h|--help|\ - --version|--xsltproc-opts) + --attribute|--asciidoc-opts|--dblatex-opts|--fop-opts|--help|\ + --version|--xsltproc-opts|-!(-*)[ah]) return ;; - -D|--destination-dir|--icons-dir) + --destination-dir|--icons-dir|-!(-*)D) _filedir -d return ;; - --doctype|-d) + --doctype|-!(-*)d) _xfunc asciidoc _asciidoc_doctype return ;; @@ -27,8 +27,7 @@ _a2x() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/abook b/completions/abook index 4bb0e8e3..29d326b9 100644 --- a/completions/abook +++ b/completions/abook @@ -22,21 +22,21 @@ _abook() case $prev in --informat) - COMPREPLY=( $( compgen -W "$($1 --formats | \ + COMPREPLY=( $(compgen -W "$($1 --formats | \ command sed -n -e 's/^'$'\t''\([a-z]*\).*/\1/p' -e '/^$/q')" \ - -- "$cur" ) ) + -- "$cur") ) ;; --outformat) - COMPREPLY=( $( compgen -W "$($1 --formats | \ + COMPREPLY=( $(compgen -W "$($1 --formats | \ command sed -n -e '/^$/,$s/^'$'\t''\([a-z]*\).*/\1/p')" \ - -- "$cur" ) ) + -- "$cur") ) ;; --infile) - COMPREPLY=( $( compgen -W stdin -- "$cur" ) ) + COMPREPLY=( $(compgen -W stdin -- "$cur") ) _filedir ;; --outfile) - COMPREPLY=( $( compgen -W stdout -- "$cur" ) ) + COMPREPLY=( $(compgen -W stdout -- "$cur") ) _filedir ;; --config|--datafile) diff --git a/completions/aclocal b/completions/aclocal index 7a3d6467..f0cc6114 100644 --- a/completions/aclocal +++ b/completions/aclocal @@ -19,17 +19,17 @@ _aclocal() ;; --warnings|-W) local cats=( syntax unsupported ) - COMPREPLY=( $( compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) return ;; esac $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && -complete -F _aclocal aclocal aclocal-1.1{0..5} +complete -F _aclocal aclocal aclocal-1.1{0..6} # ex: filetype=sh diff --git a/completions/acpi b/completions/acpi index b748cbde..745b8f78 100644 --- a/completions/acpi +++ b/completions/acpi @@ -6,16 +6,16 @@ _acpi() _init_completion || return case $prev in - -h|--help|-v|--version) + --help|--version|-!(-*)[hv]) return ;; - -d|--directory) + --directory|-!(-*)d) _filedir -d return ;; esac - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _acpi acpi diff --git a/completions/adb b/completions/adb deleted file mode 100644 index d069b425..00000000 --- a/completions/adb +++ /dev/null @@ -1,66 +0,0 @@ -# adb completion -*- shell-script -*- - -_adb_command_usage() -{ - COMPREPLY=( $( compgen -W \ - '$( "$1" help 2>&1 | command grep "^ *\(adb \)\? *$2 " \ - | command sed -e "s/[]|[]/\n/g" | _parse_help - )' -- "$cur" ) ) -} - -_adb() -{ - local cur prev words cword - _init_completion || return - - case $prev in - -s|-p|--algo|--key|--iv) - return - ;; - -f) - _filedir - return - ;; - esac - - local cmd i - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" != -* && "${words[i-1]}" != -[sp] ]]; then - cmd="${words[i]}" - break - fi - done - - if [[ ! "$cmd" ]]; then - local tmp=() - if [[ ! $cur || $cur == -* ]]; then - tmp+=( $( compgen -W '$( _parse_help "$1" help )' -- "$cur" ) ) - fi - if [[ ! $cur || $cur != -* ]]; then - tmp+=( $( $1 help 2>&1 | awk '$1 == "adb" { print $2 }' ) ) - tmp+=( devices connect disconnect sideload ) - fi - COMPREPLY=( $( compgen -W '${tmp[@]}' -- "$cur" ) ) - return - fi - - # TODO: more and better command completions - - _adb_command_usage "$1" $cmd - - case $cmd in - push|restore|sideload) - _filedir - ;; - forward) - COMPREPLY=( $( compgen -W \ - '$( "$1" help 2>&1 | command sed -ne "s/^ *adb *forward *-/-/p" | \ - _parse_help - )' -- "$cur" ) ) - ;; - reboot) - COMPREPLY=( $( compgen -W 'bootloader recovery' -- "$cur" ) ) - ;; - esac -} && -complete -F _adb adb - -# ex: filetype=sh diff --git a/completions/add_members b/completions/add_members index d582d94b..75ae417c 100644 --- a/completions/add_members +++ b/completions/add_members @@ -11,7 +11,7 @@ _add_members() return ;; -w|-a|--welcome-msg|--admin-notify) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac @@ -19,8 +19,8 @@ _add_members() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--regular-members-file --digest-members-file - --welcome-msg --admin-notify --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--regular-members-file --digest-members-file + --welcome-msg --admin-notify --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/alias b/completions/alias index e90dff60..af39302a 100644 --- a/completions/alias +++ b/completions/alias @@ -7,11 +7,11 @@ _alias() case ${words[@]} in *[^=]) - COMPREPLY=( $( compgen -A alias -- "$cur" ) ) + COMPREPLY=( $(compgen -A alias -- "$cur") ) ;; *=) - COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | command sed \ - -e 's|^alias '"$cur"'\(.*\)$|\1|' )" ) + COMPREPLY=( "$(alias ${cur%=} 2>/dev/null | command sed \ + -e 's|^alias '"$cur"'\(.*\)$|\1|')" ) ;; esac } && diff --git a/completions/ant b/completions/ant index 639cde97..ba141965 100644 --- a/completions/ant +++ b/completions/ant @@ -11,7 +11,7 @@ _ant_parse_targets() if [[ $line =~ \<(target|extension-point)[[:space:]].*name=[\"\']([^\"\']+) ]]; then targets+=" ${BASH_REMATCH[2]}" fi - done < $1 + done <$1 # parse imports while read -rd '>' line; do @@ -22,7 +22,7 @@ _ant_parse_targets() _ant_parse_targets $imported_buildfile fi fi - done < $1 + done <$1 } _ant() @@ -39,7 +39,7 @@ _ant() return ;; -logfile|-l) - _filedir + [[ $1 != *phing || $prev != -l ]] && _filedir return ;; -propertyfile) @@ -47,7 +47,7 @@ _ant() return ;; -nice) - COMPREPLY=( $( compgen -W '{1..10}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..10}' -- "$cur") ) return ;; -lib) @@ -62,7 +62,10 @@ _ant() if [[ $cur == -D* ]]; then return elif [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + # The &1 >/dev/null | awk 'NR<2 { print $3; exit }' | \ tr "|" " ") - COMPREPLY=( $( compgen -W "$APWORDS" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$APWORDS" -- "$cur") ) } && complete -F _apache2ctl apache2ctl diff --git a/completions/appdata-validate b/completions/appdata-validate index 3285a3b3..e6c6ddd6 100644 --- a/completions/appdata-validate +++ b/completions/appdata-validate @@ -10,9 +10,9 @@ _appdata_validate() return ;; --output-format) - COMPREPLY=( $( compgen -W "$( $1 --help | - command sed -ne 's/--output-format.*\[\(.*\)\]/\1/' -e 's/|/ /gp' )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 --help | + command sed -ne 's/--output-format.*\[\(.*\)\]/\1/' -e 's/|/ /gp')" \ + -- "$cur") ) return ;; esac @@ -20,7 +20,7 @@ _appdata_validate() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/apt-build b/completions/apt-build index 0723bcc4..b6cf8eff 100644 --- a/completions/apt-build +++ b/completions/apt-build @@ -15,11 +15,11 @@ _apt_build() if [[ -n $special ]]; then case $special in install|source|info) - COMPREPLY=( $( apt-cache pkgnames "$cur" 2> /dev/null ) ) + COMPREPLY=( $(apt-cache pkgnames "$cur" 2>/dev/null) ) ;; remove) COMPREPLY=( \ - $( _xfunc dpkg _comp_dpkg_installed_packages "$cur" ) ) + $(_xfunc dpkg _comp_dpkg_installed_packages "$cur") ) ;; esac return @@ -36,15 +36,15 @@ _apt_build() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir + COMPREPLY=( $(compgen -W '--help --show-upgraded -u --build-dir --repository-dir --build-only --build-command --reinstall --rebuild --remove-builddep --no-wrapper --purge --patch --patch-strip -p - --yes -y --version -v --no-source' -- "$cur" ) ) + --yes -y --version -v --no-source' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'update upgrade install remove source + COMPREPLY=( $(compgen -W 'update upgrade install remove source dist-upgrade world clean info clean-build update-repository' \ - -- "$cur" ) ) + -- "$cur") ) fi } && diff --git a/completions/apt-cache b/completions/apt-cache index bedae4e9..5bd85e90 100644 --- a/completions/apt-cache +++ b/completions/apt-cache @@ -2,17 +2,18 @@ # List APT binary packages _apt_cache_packages() { - apt-cache --no-generate pkgnames "$cur" 2> /dev/null + apt-cache --no-generate pkgnames "$cur" 2>/dev/null } # List APT source packages _apt_cache_sources() { - apt-cache dumpavail | command grep "^Source: $1" | cut -f2 -d" " | sort -u + compgen -W "$(apt-cache dumpavail | \ + awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$1" } # List APT source packages _apt_cache_src_packages() { - compgen -W '$( _apt_cache_sources "$cur" )' -- "$cur" + compgen -W '$(_apt_cache_sources "$cur")' -- "$cur" } _apt_cache() @@ -37,11 +38,11 @@ _apt_cache() ;; showsrc) - COMPREPLY=( $( _apt_cache_sources "$cur" ) ) + COMPREPLY=( $(_apt_cache_sources "$cur") ) ;; *) - COMPREPLY=( $( _apt_cache_packages ) ) + COMPREPLY=( $(_apt_cache_packages) ) ;; esac @@ -50,7 +51,7 @@ _apt_cache() case $prev in - -c|-p|-s|--config-file|--pkg-cache|--src-cache) + --config-file|--pkg-cache|--src-cache|-!(-*)[cps]) _filedir return ;; @@ -63,16 +64,16 @@ _apt_cache() if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c -o --help + COMPREPLY=( $(compgen -W '-h -v -p -s -q -i -f -a -g -c -o --help --version --pkg-cache --src-cache --quiet --important --full --all-versions --no-all-versions --generate --no-generate --names-only --all-names --recurse --config-file --option - --installed' -- "$cur" ) ) + --installed' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'add gencaches show showpkg showsrc stats + COMPREPLY=( $(compgen -W 'add gencaches show showpkg showsrc stats dump dumpavail unmet search search depends rdepends pkgnames - dotty xvcg policy madison' -- "$cur" ) ) + dotty xvcg policy madison' -- "$cur") ) fi diff --git a/completions/apt-get b/completions/apt-get index 32c4bcf8..3b00c56a 100644 --- a/completions/apt-get +++ b/completions/apt-get @@ -3,7 +3,7 @@ _apt_get() { local cur prev words cword - _init_completion || return + _init_completion -n = || return local special i for (( i=0; i < ${#words[@]}-1; i++ )); do @@ -17,57 +17,75 @@ _apt_get() remove|autoremove|purge) if [[ -f /etc/debian_version ]]; then # Debian system - COMPREPLY=( $( \ - _xfunc dpkg _comp_dpkg_installed_packages $cur ) ) + COMPREPLY=( $(\ + _xfunc dpkg _comp_dpkg_installed_packages $cur) ) else # assume RPM based _xfunc rpm _rpm_installed_packages fi ;; source) - COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ - 2> /dev/null ) $( apt-cache dumpavail | \ - command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) ) + COMPREPLY=( $(apt-cache --no-generate pkgnames "$cur" \ + 2>/dev/null) $(compgen -W "$(apt-cache dumpavail | + awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur") ) ;; - *) - if [[ $special == install && $cur == */* ]]; then + install) + if [[ $cur == */* ]]; then _filedir deb - else - COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ - 2>/dev/null ) ) + return + elif [[ $cur == *=* ]]; then + COMPREPLY=( $(compgen -W "$(\ + apt-cache --no-generate show "${cur%%=*}" 2>/dev/null | + command sed -ne \ + 's/^Version:[[:space:]]*\([^[:space:]]\)/\1/p')" \ + -- "${cur#*=}") ) + return fi + ;;& + *) + COMPREPLY=( $(apt-cache --no-generate pkgnames "$cur" \ + 2>/dev/null) ) ;; esac return fi case $prev in - -c|--config-file) + --help|--version|--option|-!(-*)[hvo]) + return + ;; + --config-file|-!(-*)c) _filedir return ;; - -t|--target-release|--default-release) - COMPREPLY=( $( apt-cache policy | \ - command grep "release.o=Debian,a=$cur" | \ - command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) ) + --target-release|--default-release|-!(-*)t) + COMPREPLY=( $(compgen -W "$(apt-cache policy | command sed -ne \ + 's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')" \ + -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y -u -t -b -c -o - --download-only --fix-broken --help --version --ignore-missing - --fix-missing --no-download --quiet --simulate --just-print - --dry-run --recon --no-act --yes --assume-yes --show-upgraded - --only-source --compile --build --ignore-hold --target-release - --no-upgrade --force-yes --print-uris --purge --reinstall - --list-cleanup --default-release --trivial-only --no-remove - --diff-only --no-install-recommends --tar-only --config-file - --option --auto-remove' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--no-install-recommends --install-suggests + --download-only --fix-broken --ignore-missing --fix-missing + --no-download --quiet --simulate --just-print --dry-run --recon + --no-act --yes --assume-yes --assume-no --no-show-upgraded + --verbose-versions --host-architecture --build-profiles --compile + --build --ignore-hold --with-new-pkgs --no-upgrade --only-upgrade + --allow-downgrades --allow-remove-essential + --allow-change-held-packages --force-yes --print-uris --purge + --reinstall --list-cleanup --target-release --default-release + --trivial-only --no-remove --auto-remove --autoremove --only-source + --diff-only --dsc-only --tar-only --arch-only --indep-only + --allow-unauthenticated --no-allow-insecure-repositories + --allow-releaseinfo-change --show-progress --with-source --help + --version --config-file --option' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade - dist-upgrade install remove purge source build-dep download - changelog check clean autoclean autoremove' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'update upgrade dist-upgrade + dselect-upgrade install remove purge source build-dep check + download clean autoclean autoremove changelog indextargets' \ + -- "$cur") ) fi } && diff --git a/completions/aptitude b/completions/aptitude index a8b88737..3f4e5500 100644 --- a/completions/aptitude +++ b/completions/aptitude @@ -39,16 +39,16 @@ _aptitude() install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade| \ safe-upgrade|download|show|changelog|why|why-not|build-dep| \ add-user-tag|remove-user-tag|versions) - COMPREPLY=( $( _xfunc apt-cache _apt_cache_packages ) ) + COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) ) return ;; purge|remove|reinstall|forbid-version) COMPREPLY=( \ - $( _xfunc dpkg _comp_dpkg_installed_packages "$cur" ) ) + $(_xfunc dpkg _comp_dpkg_installed_packages "$cur") ) return ;; unhold) - COMPREPLY=( $( _comp_dpkg_hold_packages "$cur" ) ) + COMPREPLY=( $(_comp_dpkg_hold_packages "$cur") ) return ;; esac @@ -59,26 +59,26 @@ _aptitude() autoclean|clean|forget-new|search|upgrade|update|keep-all) return ;; - -S) + -!(-*)S) _filedir return ;; - -t|--target-release|--default-release) - COMPREPLY=( $( apt-cache policy | \ + --target-release|--default-release|-!(-*)t) + COMPREPLY=( $(apt-cache policy | \ command grep "release.o=Debian,a=$cur" | \ - command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) ) + command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2>/dev/null) ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$dashoptions" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$dashoptions" -- "$cur") ) else - COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new + COMPREPLY=( $(compgen -W 'update upgrade safe-upgrade forget-new clean autoclean install reinstall remove hold unhold purge markauto unmarkauto why why-not dist-upgrade full-upgrade download search show forbid-version changelog keep keep-all build-dep add-user-tag - remove-user-tag versions' -- "$cur" ) ) + remove-user-tag versions' -- "$cur") ) fi } && diff --git a/completions/arch b/completions/arch index cd33b4f0..e275577b 100644 --- a/completions/arch +++ b/completions/arch @@ -10,7 +10,7 @@ _arch() case $prev in -w|-g|-d|--welcome-msg|--goodbye-msg|--digest) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; -d|--file) @@ -22,12 +22,12 @@ _arch() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else local args=$cword for (( i=1; i < cword; i++ )); do if [[ "${words[i]}" == -* ]]; then - args=$(($args-1)) + (( args-- )) fi done case $args in diff --git a/completions/arp b/completions/arp new file mode 100644 index 00000000..e83f05d3 --- /dev/null +++ b/completions/arp @@ -0,0 +1,59 @@ +# arp(8) completion -*- shell-script -*- + +_arp() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --device|-!(-*)i) + _available_interfaces -a + return + ;; + --protocol|-!(-*)[Ap]) + # TODO protocol/address family + return + ;; + --file|-!(-*)f) + _filedir + return + ;; + --hw-type|-!(-*)[Ht]) + # TODO: parse from --help output? + COMPREPLY=( $(compgen -W 'ash ether ax25 netrom rose arcnet \ + dlci fddi hippi irda x25 eui64' -- "$cur") ) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + local args + _count_args "" "@(--device|--protocol|--file|--hw-type|-!(-*)[iApfHt])" + case $args in + 1) + local ips=$("$1" -an | command sed -ne \ + 's/.*(\([0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}\)).*/\1/p') + COMPREPLY=( $(compgen -W '$ips' -- "$cur") ) + ;; + 2) + # TODO if -d mode: "pub"; if not -f mode: hw_addr + # TODO hw_addr is a configured interface with --use-device/-*D* + ;; + 3) + # TODO netmask|pub|temp if -s mode + ;; + 4) + # TODO netmask value if previous was "netmask" + ;; + 5) + # TODO "pub" if 3rd was "netmask" + ;; + esac +} && +complete -F _arp arp + +# ex: filetype=sh diff --git a/completions/arping b/completions/arping index 2f544353..6adcde7c 100644 --- a/completions/arping +++ b/completions/arping @@ -6,21 +6,21 @@ _arping() _init_completion || return case $prev in - -c|-w) + -*c|-*w) return ;; - -I) + -*I) _available_interfaces -a return ;; - -s) + -*s) _ip_addresses return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) return fi diff --git a/completions/arpspoof b/completions/arpspoof index e31288fc..6275a667 100644 --- a/completions/arpspoof +++ b/completions/arpspoof @@ -17,7 +17,7 @@ _arpspoof() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _known_hosts_real -- "$cur" fi diff --git a/completions/asciidoc b/completions/asciidoc index fb29fad4..2ddcdfe9 100644 --- a/completions/asciidoc +++ b/completions/asciidoc @@ -2,7 +2,7 @@ _asciidoc_doctype() { - COMPREPLY+=( $( compgen -W 'article book manpage' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W 'article book manpage' -- "$cur") ) } _asciidoc() @@ -11,26 +11,26 @@ _asciidoc() _init_completion -s || return case $prev in - --attribute|-a) + --attribute|-!(-*)a) return ;; - --backend|-b) - COMPREPLY=( $( compgen -W 'docbook html4 xhtml11' -- "$cur" ) ) + --backend|-!(-*)b) + COMPREPLY=( $(compgen -W 'docbook html4 xhtml11' -- "$cur") ) return ;; - --conf-file|-f) + --conf-file|-!(-*)f) _filedir conf return ;; - --doctype|-d) + --doctype|-!(-*)d) _asciidoc_doctype return ;; - --help|-h) - COMPREPLY=( $( compgen -W 'manpage syntax topics' -- "$cur" ) ) + --help|-!(-*)h) + COMPREPLY=( $(compgen -W 'manpage syntax topics' -- "$cur") ) return ;; - --out-file|-o) + --out-file|-!(-*)o) _filedir return ;; @@ -39,8 +39,8 @@ _asciidoc() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" "--help manpage" )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help manpage")' \ + -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/aspell b/completions/aspell index 9457a5fa..040853cb 100644 --- a/completions/aspell +++ b/completions/aspell @@ -3,14 +3,14 @@ _aspell_dictionary() { local datadir aspell=${1:-aspell} - datadir=$( $aspell config data-dir 2>/dev/null || echo /usr/lib/aspell ) + datadir=$($aspell config data-dir 2>/dev/null || echo /usr/lib/aspell) # First, get aliases (dicts dump does not list them) - COMPREPLY=( $( printf '%s\n' $datadir/*.alias ) ) + COMPREPLY=( $(printf '%s\n' $datadir/*.alias) ) COMPREPLY=( "${COMPREPLY[@]%.alias}" ) COMPREPLY=( "${COMPREPLY[@]#$datadir/}" ) # Then, add the canonical dicts - COMPREPLY+=( $( $aspell dicts 2>/dev/null ) ) - COMPREPLY=( $( compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur" ) ) + COMPREPLY+=( $($aspell dicts 2>/dev/null) ) + COMPREPLY=( $(compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur") ) } _aspell() @@ -28,21 +28,21 @@ _aspell() return ;; dump|create|merge) - COMPREPLY=( $( compgen -W 'master personal repl' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'master personal repl' -- "$cur") ) return ;; --mode) - COMPREPLY=( $( compgen -W "$( $1 modes 2>/dev/null | \ - awk '{ print $1 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 modes 2>/dev/null | \ + awk '{ print $1 }')" -- "$cur") ) return ;; --sug-mode) - COMPREPLY=( $( compgen -W 'ultra fast normal bad-speller' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'ultra fast normal bad-speller' \ + -- "$cur") ) return ;; --keymapping) - COMPREPLY=( $( compgen -W 'aspell ispell' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'aspell ispell' -- "$cur") ) return ;; -d|--master) @@ -50,8 +50,8 @@ _aspell() return ;; --add-filter|--rem-filter) - COMPREPLY=( $( compgen -W "$( $1 filters 2>/dev/null | \ - awk '{ print $1 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 filters 2>/dev/null | \ + awk '{ print $1 }')" -- "$cur") ) return ;; esac @@ -59,7 +59,7 @@ _aspell() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= + COMPREPLY=( $(compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= --encoding= --add-filter= --rem-filter= --mode= --add-extra-dicts= --rem-extra-dicts= --home-dir= --ignore= --ignore-accents --dont-ignore-accents --ignore-case --dont-ignore-case @@ -76,11 +76,11 @@ _aspell() --add-tex-command= --rem-tex-command= --tex-check-comments --dont-tex-check-comments --add-tex-extension --rem-tex-extension --add-sgml-check= --rem-sgml-check= --add-sgml-extension - --rem-sgml-extension' -- "$cur" ) ) + --rem-sgml-extension' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else - COMPREPLY=( $( compgen -W 'usage help check pipe list config soundslike - filter version dump create merge' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'usage help check pipe list config soundslike + filter version dump create merge' -- "$cur") ) fi } && complete -F _aspell aspell diff --git a/completions/autoconf b/completions/autoconf index c67f1bdb..94a014ff 100644 --- a/completions/autoconf +++ b/completions/autoconf @@ -15,8 +15,8 @@ _autoconf() ;; --warnings|-W) local cats=( cross obsolete syntax ) - COMPREPLY=( $( compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) return ;; --prepend-include|-B|--include|-I) @@ -28,7 +28,7 @@ _autoconf() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/automake b/completions/automake index c5fe1a10..ff3d4523 100644 --- a/completions/automake +++ b/completions/automake @@ -11,8 +11,8 @@ _automake() ;; --warnings|-W) local cats=( gnu obsolete override portability syntax unsupported ) - COMPREPLY=( $( compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) return ;; --libdir) @@ -24,13 +24,13 @@ _automake() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _automake automake automake-1.1{0..5} +complete -F _automake automake automake-1.1{0..6} # ex: filetype=sh diff --git a/completions/autoreconf b/completions/autoreconf index c067cec1..cf983312 100644 --- a/completions/autoreconf +++ b/completions/autoreconf @@ -12,8 +12,8 @@ _autoreconf() --warnings|-W) local cats=( cross gnu obsolete override portability syntax \ unsupported ) - COMPREPLY=( $( compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) return ;; --prepend-include|-B|--include|-I) @@ -25,12 +25,12 @@ _autoreconf() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi - if [[ $1 == autoheader ]] ; then + if [[ $1 == *autoheader ]]; then _filedir '@(ac|in)' else _filedir -d diff --git a/completions/autorpm b/completions/autorpm index 8c6e299a..7a0bbe18 100644 --- a/completions/autorpm +++ b/completions/autorpm @@ -5,8 +5,8 @@ _autorpm() local cur prev words cword _init_completion || return - COMPREPLY=( $( compgen -W '--notty --debug --help --version auto add - fullinfo info help install list remove set' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--notty --debug --help --version auto add + fullinfo info help install list remove set' -- "$cur") ) } && complete -F _autorpm autorpm diff --git a/completions/autoscan b/completions/autoscan index 054a58af..5f70a508 100644 --- a/completions/autoscan +++ b/completions/autoscan @@ -6,10 +6,10 @@ _autoscan() _init_completion -s || return case "$prev" in - --help|-h|--version|-V) + --help|--version|-!(-*)[hV]) return ;; - --prepend-include|-B|--include|-I) + --prepend-include|--include|-!(-*)[BI]) _filedir -d return ;; @@ -18,12 +18,12 @@ _autoscan() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi - if [[ $1 == autoupdate ]] ; then + if [[ $1 == *autoupdate ]]; then _filedir '@(ac|in)' else _filedir -d diff --git a/completions/avctrl b/completions/avctrl index acd9aeb7..2ef499f3 100644 --- a/completions/avctrl +++ b/completions/avctrl @@ -6,12 +6,12 @@ _avctrl() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --quiet' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --quiet' -- "$cur") ) else local args _count_args if [[ $args -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'discover switch' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'discover switch' -- "$cur") ) fi fi } && diff --git a/completions/badblocks b/completions/badblocks index d70affe2..a366338c 100644 --- a/completions/badblocks +++ b/completions/badblocks @@ -6,19 +6,19 @@ _badblocks() _init_completion || return case $prev in - -b|-c|-e|-d|-p|-t) + -*[bcedpt]) return ;; - -i|-o) + -*[io]) _filedir return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) # Filter out -w (dangerous) and -X (internal use) - for i in ${!COMPREPLY[@]}; do + for i in "${!COMPREPLY[@]}"; do [[ ${COMPREPLY[i]} == -[wX] ]] && unset 'COMPREPLY[i]' done return diff --git a/completions/bind b/completions/bind index ec5d0b81..c06654b1 100644 --- a/completions/bind +++ b/completions/bind @@ -6,30 +6,30 @@ _bind() _init_completion || return case $prev in - -l|-p|-P|-s|-S|-v|-V|-r|-x|-X) + -*[lpPsSvVrxX]) return ;; - -m) - COMPREPLY=( $( compgen -W "emacs emacs-standard emacs-meta - emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur" ) ) + -*m) + COMPREPLY=( $(compgen -W "emacs emacs-standard emacs-meta + emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur") ) return ;; - -f) + -*f) _filedir return ;; - -q|-u) - COMPREPLY=( $( compgen -W '$( "$1" -l )' -- "$cur" ) ) + -*[qu]) + COMPREPLY=( $(compgen -W '$("$1" -l)' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -A binding -- "$cur" ) ) + COMPREPLY=( $(compgen -A binding -- "$cur") ) } && complete -F _bind bind diff --git a/completions/bk b/completions/bk index 334e25b4..73b5bb1c 100644 --- a/completions/bk +++ b/completions/bk @@ -6,10 +6,10 @@ _bk() local cur prev words cword _init_completion || return - local BKCMDS="$( bk help topics 2>/dev/null | \ - awk '/^ bk/ { print $2 }' | xargs printf '%s ' )" + local BKCMDS="$(bk help topics 2>/dev/null | \ + awk '/^ bk/ { print $2 }' | xargs printf '%s ')" - COMPREPLY=( $( compgen -W "$BKCMDS" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$BKCMDS" -- "$cur") ) _filedir } && diff --git a/completions/brctl b/completions/brctl index 01370654..755812d3 100644 --- a/completions/brctl +++ b/completions/brctl @@ -9,17 +9,17 @@ _brctl() case $cword in 1) - COMPREPLY=( $( compgen -W "addbr delbr addif delif setageing + COMPREPLY=( $(compgen -W "addbr delbr addif delif setageing setbridgeprio setfd sethello setmaxage setpathcost setportprio - show showmacs showstp stp" -- "$cur" ) ) + show showmacs showstp stp" -- "$cur") ) ;; 2) case $command in show) ;; *) - COMPREPLY=( $( compgen -W "$($1 show | \ - awk 'NR>1 {print $1}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 show | \ + awk 'NR>1 {print $1}' )" -- "$cur") ) esac ;; 3) @@ -28,7 +28,7 @@ _brctl() _configured_interfaces ;; stp) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) ;; esac ;; diff --git a/completions/btdownloadheadless.py b/completions/btdownloadheadless.py index f0b74615..c15de1a4 100644 --- a/completions/btdownloadheadless.py +++ b/completions/btdownloadheadless.py @@ -13,7 +13,7 @@ _btdownload() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--max_uploads --keepalive_interval + COMPREPLY=( $(compgen -W '--max_uploads --keepalive_interval --download_slice_size --request_backlog --max_message_length --ip --minport --maxport --responsefile --url --saveas --timeout --timeout_check_interval --max_slice_length --max_rate_period @@ -21,7 +21,7 @@ _btdownload() --min_peers --http_timeout --max_initiate --max_allow_in --check_hashes --max_upload_rate --snub_time --spew --rarest_first_cutoff --min_uploads --report_hash_failures' \ - -- "$cur" ) ) + -- "$cur") ) else _filedir fi diff --git a/completions/bts b/completions/bts index ba33fd66..c87b51e1 100644 --- a/completions/bts +++ b/completions/bts @@ -3,14 +3,14 @@ # List bug numbers from bugs cache in ~/.devscripts_cache/bts _cached_bugs() { [[ -d $HOME/.devscripts_cache/bts ]] && \ - find $HOME/.devscripts_cache/bts -maxdepth 1 -name "$cur[0-9]*.html" \ + find $HOME/.devscripts_cache/bts -maxdepth 1 -name "${cur}[0-9]*.html" \ -printf "%f\n" | cut -d'.' -f1 } # List APT source packages prefixed with "src:" _src_packages_with_prefix() { ppn=${cur:4} # partial package name, after stripping "src:" - compgen -P "src:" -W '$( _xfunc apt-cache _apt_cache_sources "$ppn" )' \ + compgen -P "src:" -W '$(_xfunc apt-cache _apt_cache_sources "$ppn")' \ -- "$ppn" } @@ -22,58 +22,58 @@ _bts() case $prev in show|bugs) - COMPREPLY=( $( compgen -W 'release-critical RC from: tag: - usertag:' -- "$cur" ) $( _cached_bugs ) - $( _src_packages_with_prefix ) ) + COMPREPLY=( $(compgen -W 'release-critical RC from: tag: + usertag:' -- "$cur") $(_cached_bugs) + $(_src_packages_with_prefix) ) return ;; select) - COMPREPLY=( $( compgen -W 'package: source: maintainer: submitter: + COMPREPLY=( $(compgen -W 'package: source: maintainer: submitter: severity: status: tag: owner: correspondent: affects: bugs: - users: archive:' -- "$cur" ) ) + users: archive:' -- "$cur") ) return ;; status) - COMPREPLY=( $( compgen -W 'file: fields: verbose' -- "$cur" ) - $( _cached_bugs ) ) + COMPREPLY=( $(compgen -W 'file: fields: verbose' -- "$cur") + $(_cached_bugs) ) return ;; block|unblock) - COMPREPLY=( $( compgen -W 'by with' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'by with' -- "$cur") ) return ;; severity) - COMPREPLY=( $( compgen -W 'wishlist minor normal important serious - grave critical' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'wishlist minor normal important serious + grave critical' -- "$cur") ) return ;; limit) - COMPREPLY=( $( compgen -W 'submitter date subject msgid package - source tag severity owner affects archive' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'submitter date subject msgid package + source tag severity owner affects archive' -- "$cur") ) return ;; - clone|done|reopen|archive|unarchive|retitle|summary|submitter|found\ + clone|"done"|reopen|archive|unarchive|retitle|summary|submitter|found\ |notfound|fixed|notfixed|merge|forcemerge|unmerge|claim|unclaim\ |forwarded|notforwarded|owner|noowner|subscribe|unsubscribe\ |reportspam|spamreport|affects|usertag|usertags|reassign|tag\ |tags) - COMPREPLY=( $( _cached_bugs ) ) + COMPREPLY=( $(_cached_bugs) ) return ;; package) - COMPREPLY=( $( _xfunc apt-cache _apt_cache_packages ) ) + COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) ) return ;; cache) - COMPREPLY=( $( _xfunc apt-cache _apt_cache_packages ) - $( _src_packages_with_prefix ) - $( compgen -W 'from: release-critical RC' -- "$cur" ) ) + COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) + $(_src_packages_with_prefix) + $(compgen -W 'from: release-critical RC' -- "$cur") ) return ;; cleancache) - COMPREPLY=( $( _xfunc apt-cache _apt_cache_packages ) - $( _src_packages_with_prefix ) - $( compgen -W 'from: tag: usertag: ALL' -- "$cur" ) ) + COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) + $(_src_packages_with_prefix) + $(compgen -W 'from: tag: usertag: ALL' -- "$cur") ) return ;; user) @@ -86,7 +86,7 @@ _bts() # COMP_WORDS would be: "bts cleancache src : " pos=$((COMP_CWORD - 2)) if [[ $pos -gt 0 && "${COMP_WORDS[$pos]}" == "src" ]]; then - COMPREPLY=( $( _xfunc apt-cache _apt_cache_src_packages ) ) + COMPREPLY=( $(_xfunc apt-cache _apt_cache_src_packages) ) return fi ;; @@ -94,7 +94,7 @@ _bts() $split && return - COMPREPLY=( $( compgen -W '--offline --online --no-offline + COMPREPLY=( $(compgen -W '--offline --online --no-offline --no-action --cache --no-cache --cache-mode --cache-delay --mbox --mailreader --cc-addr --use-default-cc --no-use-default-cc --sendmail --mutt --no-mutt --smtp-host --smtp-username @@ -107,7 +107,7 @@ _bts() merge forcemerge unmerge tag tags affects user usertag usertags claim unclaim severity forwarded notforwarded package limit owner noowner subscribe unsubscribe reportspam spamreport cache cleancache version - help' -- "$cur" ) ) + help' -- "$cur") ) } && complete -F _bts bts diff --git a/completions/bzip2 b/completions/bzip2 index f45e29f2..8bd72cc9 100644 --- a/completions/bzip2 +++ b/completions/bzip2 @@ -6,23 +6,23 @@ _bzip2() _init_completion || return case $prev in - -b|-h|--help|-p) + --help|-!(-*)[bhp]) return ;; - -n) - COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) + -!(-*)n) + COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - local helpopts=$( _parse_help "$1" ) - COMPREPLY=( $( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ - -- "$cur" ) ) + local helpopts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ + -- "$cur") ) return fi - local IFS=$'\n' xspec="*.bz2" + local IFS=$'\n' xspec="*.?(t)bz2" if [[ "$prev" == --* ]]; then [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec @@ -35,8 +35,7 @@ _bzip2() _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) } && complete -F _bzip2 bzip2 pbzip2 lbzip2 diff --git a/completions/cancel b/completions/cancel index 2722d2a8..b903517b 100644 --- a/completions/cancel +++ b/completions/cancel @@ -5,7 +5,22 @@ _cancel() local cur prev words cword _init_completion || return - COMPREPLY=( $( compgen -W "$( lpstat 2>/dev/null | cut -d' ' -f1 )" -- "$cur" ) ) + case $prev in + -h) + _known_hosts_real -- "$cur" + return + ;; + -U) + return + ;; + -u) + COMPREPLY=( $(compgen -u -- "$cur") ) + return + ;; + esac + + COMPREPLY=( $(compgen -W \ + "$(lpstat 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) } && complete -F _cancel cancel diff --git a/completions/cardctl b/completions/cardctl index 273d1a90..588ea467 100644 --- a/completions/cardctl +++ b/completions/cardctl @@ -6,8 +6,8 @@ _cardctl() _init_completion || return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'status config ident suspend resume reset - eject insert scheme' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'status config ident suspend resume reset + eject insert scheme' -- "$cur") ) fi } && complete -F _cardctl cardctl pccardctl diff --git a/completions/ccache b/completions/ccache index 7184d74e..7dbec9fe 100644 --- a/completions/ccache +++ b/completions/ccache @@ -11,17 +11,17 @@ _ccache() _command_offset $i return fi - [[ ${COMP_WORDS[i]} == -[oFM] ]] && ((i++)) + [[ ${COMP_WORDS[i]} == -*[oFM] ]] && ((i++)) done case $prev in - -h|--help|-V|--version|-F|--max-files|-M|--max-size) + --help|--version|--max-files|--max-size|-!(-*)[hVFM]) return ;; - -o|--set-config) + --set-config|-!(-*)o) if [[ $cur != *=* ]]; then - COMPREPLY=( $( compgen -S = -W "$( $1 -p 2>/dev/null | \ - awk '$3 = "=" { print $2 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -S = -W "$($1 -p 2>/dev/null | \ + awk '$3 = "=" { print $2 }')" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi return @@ -30,7 +30,7 @@ _ccache() $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _ccache ccache diff --git a/completions/ccze b/completions/ccze index c803408b..7c17f364 100644 --- a/completions/ccze +++ b/completions/ccze @@ -9,33 +9,33 @@ _ccze() -'?'|--help|--usage|-V|--version) return ;; - -a|--argument|-c|--color) + --argument|--color|-!(-*)[ac]) # TODO? return ;; - -F|--rcfile) + --rcfile|-!(-*)F) _filedir return ;; - -m|--mode) - COMPREPLY=( $( compgen -W "curses ansi html" -- "$cur" ) ) + --mode|-!(-*)m) + COMPREPLY=( $(compgen -W "curses ansi html" -- "$cur") ) return ;; - -o|--option) + --option|-!(-*)o) local -a opts=(scroll wordcolor lookups transparent cssfile) - COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur") ) return ;; - -p|--plugin) - COMPREPLY=( $( compgen -W '$( "$1" --list-plugins | - sed -ne "s/^\([a-z0-9]\{1,\}\)[[:space:]]\{1,\}|.*/\1/p" )' \ - -- "$cur" ) ) + --plugin|-!(-*)p) + COMPREPLY=( $(compgen -W '$("$1" --list-plugins | command \ + sed -ne "s/^\([a-z0-9]\{1,\}\)[[:space:]]\{1,\}|.*/\1/p")' \ + -- "$cur") ) return esac $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _ccze ccze diff --git a/completions/cfagent b/completions/cfagent index fbf364ed..14987723 100644 --- a/completions/cfagent +++ b/completions/cfagent @@ -13,7 +13,7 @@ _cfagent() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _cfagent cfagent diff --git a/completions/cfrun b/completions/cfrun index f4d1f265..0a7d0542 100644 --- a/completions/cfrun +++ b/completions/cfrun @@ -8,7 +8,7 @@ _cfrun() local i section=1 for (( i=1; i < cword; i++ )); do if [[ "${words[i]}" == -- ]]; then - section=$((section + 1)) + (( section++ )) fi done @@ -22,7 +22,7 @@ _cfrun() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-f -h -d -S -T -v' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-f -h -d -S -T -v' -- "$cur") ) else hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts for (( i=1; i < cword; i++ )); do @@ -33,12 +33,12 @@ _cfrun() done [[ ! -f $hostfile ]] && return - COMPREPLY=( $(compgen -W "$( command grep -v \ - -E '(=|^$|^#)' $hostfile )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(command grep -v \ + -E '(=|^$|^#)' $hostfile )" -- "$cur") ) fi ;; 2) - COMPREPLY=( $( compgen -W '$( _parse_help cfagent )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help cfagent)' -- "$cur") ) ;; esac } && diff --git a/completions/chage b/completions/chage index 9b11f169..cb9d8fcf 100644 --- a/completions/chage +++ b/completions/chage @@ -6,8 +6,12 @@ _chage() _init_completion -s || return case $prev in - -d|--lastday|-E|--expiredate|-h|--help|-I|--inactive|-m|--mindays|\ - -M|--maxdays|-W|--warndays) + --lastday|--expiredate|--help|--inactive|--mindays|--maxdays|\ + --warndays|-!(-*)[dEhImMW]) + return + ;; + --root|-!(-*)R) + _filedir -d return ;; esac @@ -15,11 +19,11 @@ _chage() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) } && complete -F _chage chage diff --git a/completions/change_pw b/completions/change_pw index b0f2061f..61c45768 100644 --- a/completions/change_pw +++ b/completions/change_pw @@ -15,8 +15,8 @@ _change_pw() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--all --domain --listname --password --quiet - --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--all --domain --listname --password --quiet + --help' -- "$cur") ) fi } && diff --git a/completions/check_db b/completions/check_db index 6f666173..ade03a5a 100644 --- a/completions/check_db +++ b/completions/check_db @@ -6,7 +6,7 @@ _check_db() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--all --verbose --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--all --verbose --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/check_perms b/completions/check_perms index 0fb05b11..d53b22a6 100644 --- a/completions/check_perms +++ b/completions/check_perms @@ -6,7 +6,7 @@ _check_perms() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-f -v -h' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-f -v -h' -- "$cur") ) fi } && diff --git a/completions/checksec b/completions/checksec index 4e9fb601..e07d07d0 100644 --- a/completions/checksec +++ b/completions/checksec @@ -28,7 +28,7 @@ _checksec() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi } && diff --git a/completions/chgrp b/completions/chgrp index 986a77a6..0e39739c 100644 --- a/completions/chgrp +++ b/completions/chgrp @@ -20,9 +20,9 @@ _chgrp() for w in "${words[@]}" ; do [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break done - COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference + COMPREPLY=( $(compgen -W '-c -h -f -R -v --changes --dereference --no-dereference --silent --quiet --reference --recursive --verbose - --help --version $opts' -- "$cur" ) ) + --help --version $opts' -- "$cur") ) return fi diff --git a/completions/chkconfig b/completions/chkconfig index 8766b3a2..f1ee8704 100644 --- a/completions/chkconfig +++ b/completions/chkconfig @@ -12,7 +12,7 @@ _chkconfig() return ;; --level) - COMPREPLY=( $( compgen -W '{1..6}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..6}' -- "$cur") ) return ;; esac @@ -20,12 +20,12 @@ _chkconfig() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--list --add --del --override --level' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--list --add --del --override --level' \ + -- "$cur") ) else if [[ $cword -eq 2 || $cword -eq 4 ]]; then - COMPREPLY=( $( compgen -W 'on off reset resetpriorities' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off reset resetpriorities' \ + -- "$cur") ) else _services _xinetd_services diff --git a/completions/chmod b/completions/chmod new file mode 100644 index 00000000..849da851 --- /dev/null +++ b/completions/chmod @@ -0,0 +1,40 @@ +# chmod(1) completion -*- shell-script -*- + +_chmod() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--version) + return + ;; + --reference) + _filedir + return + ;; + esac + + $split && return + + # Adapted from coreutils 8.28 chmod man page + local modearg="-@(@(+([rwxXst])|[ugo])|+([0-7]))" + + if [[ $cur == -* && $cur != $modearg ]]; then + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + local args + _count_args "" "" "$modearg" + + case $args in + 1) ;; # mode + *) _filedir ;; + esac +} && +complete -F _chmod chmod + +# ex: filetype=sh diff --git a/completions/chown b/completions/chown index c4479dd2..6bfa264a 100644 --- a/completions/chown +++ b/completions/chown @@ -25,9 +25,9 @@ _chown() for w in "${words[@]}" ; do [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break done - COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference + COMPREPLY=( $(compgen -W '-c -h -f -R -v --changes --dereference --no-dereference --from --silent --quiet --reference --recursive - --verbose --help --version $opts' -- "$cur" ) ) + --verbose --help --version $opts' -- "$cur") ) else local args diff --git a/completions/chpasswd b/completions/chpasswd index 93e74f8c..8c5a4dfd 100644 --- a/completions/chpasswd +++ b/completions/chpasswd @@ -6,19 +6,23 @@ _chpasswd() _init_completion -s || return case $prev in - -c|--crypt) - COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \ - -- "$cur" ) ) + --crypt|-!(-*)c) + COMPREPLY=( $(compgen -W 'DES MD5 NONE SHA256 SHA512' \ + -- "$cur") ) return ;; - -s|--sha-rounds) + --sha-rounds|-!(-*)s) + return + ;; + --root|-!(-*)R) + _filedir -d return ;; esac $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _chpasswd chpasswd diff --git a/completions/chromium-browser b/completions/chromium-browser new file mode 100644 index 00000000..f8bebd97 --- /dev/null +++ b/completions/chromium-browser @@ -0,0 +1,35 @@ +# chromium-browser completion -*- shell-script -*- + +_chromium_browser() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--app|--proxy-server|--proxy-pac-url|-h) + return + ;; + --user-data-dir) + _filedir -d + return + ;; + --password-store) + COMPREPLY=( $(compgen -W 'basic gnome kwallet' -- "$cur") ) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir "@(?([xs])htm?(l)|pdf)" +} && +complete -F _chromium_browser chromium-browser google-chrome \ + google-chrome-stable chromium chrome + +# ex: filetype=sh diff --git a/completions/chronyc b/completions/chronyc index fae9d2e4..a59746aa 100644 --- a/completions/chronyc +++ b/completions/chronyc @@ -2,12 +2,12 @@ _chronyc_command_args() { - local -a args=( $( compgen -W "$( $1 help 2>/dev/null | \ - awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }' )" ) ) + local -a args=( $(compgen -W "$($1 help 2>/dev/null | \ + awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')") ) case $args in \) _known_hosts_real -- "$cur" ;; \<*) ;; - *) COMPREPLY+=( $( compgen -W '${args[@]}' -- "$cur" ) ) ;; + *) COMPREPLY+=( $(compgen -W '${args[@]}' -- "$cur") ) ;; esac } @@ -17,17 +17,17 @@ _chronyc() _init_completion || return case $prev in - --help|-p) + --help|-*p) return ;; - -h) + -*h) _known_hosts_real -- "$cur" return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" ) -6' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -6' -- "$cur") ) return fi @@ -38,15 +38,15 @@ _chronyc() case $args in 0) - COMPREPLY=( $( compgen -W "$( $1 help 2>/dev/null | \ - awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }' )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 help 2>/dev/null | \ + awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }')" \ + -- "$cur") ) ;; 1) _chronyc_command_args "$1" if [[ ! $COMPREPLY && $prev == sources?(tats) ]]; then # [-v] not handled by _chronyc_command_args yet - COMPREPLY=( $( compgen -W '-v' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-v' -- "$cur") ) fi ;; 2) diff --git a/completions/chrpath b/completions/chrpath index 13e43ad0..bcd0f91d 100644 --- a/completions/chrpath +++ b/completions/chrpath @@ -6,17 +6,17 @@ _chrpath() _init_completion || return case $prev in - -v|--version|-h|--help) + --version|--help|-!(-*)[vh]) return ;; - -r|--replace) + --replace|-!(-*)r) _filedir -d return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/cksfv b/completions/cksfv index dd90816e..89ccc7b7 100644 --- a/completions/cksfv +++ b/completions/cksfv @@ -6,16 +6,16 @@ _cksfv() _init_completion || return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi case "$prev" in - -C|-g) + -*C|-*g) _filedir -d return ;; - -f) + -*f) _filedir 'sfv' return ;; diff --git a/completions/cleanarch b/completions/cleanarch index edac34f8..5e57e5be 100644 --- a/completions/cleanarch +++ b/completions/cleanarch @@ -6,8 +6,8 @@ _cleanarch() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--status --dry-run --quiet --help' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--status --dry-run --quiet --help' \ + -- "$cur") ) fi } && diff --git a/completions/clisp b/completions/clisp index 23b04f04..f9ccfbb8 100644 --- a/completions/clisp +++ b/completions/clisp @@ -9,9 +9,9 @@ _clisp() # completing an option (may or may not be separated by a space) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-h --help --version --license -B -K -M -m -L + COMPREPLY=( $(compgen -W '-h --help --version --license -B -K -M -m -L -N -E -q --quiet --silent -w -I -ansi -traditional -p -C -norc -i - -c -l -o -x ' -- "$cur" ) ) + -c -l -o -x ' -- "$cur") ) else _filedir fi diff --git a/completions/clone_member b/completions/clone_member index fe45e494..5a0797fe 100644 --- a/completions/clone_member +++ b/completions/clone_member @@ -15,8 +15,8 @@ _clone_member() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--listname --remove --admin --quiet - --nomodify --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--listname --remove --admin --quiet + --nomodify --help' -- "$cur") ) fi } && diff --git a/completions/complete b/completions/complete index 5de2d168..0519744d 100644 --- a/completions/complete +++ b/completions/complete @@ -6,43 +6,42 @@ _complete() _init_completion || return case $prev in - -o) - COMPREPLY=( $( compgen -W 'bashdefault default dirnames filenames - nospace plusdirs' -- "$cur" ) ) + -*o) + COMPREPLY=( $(compgen -W 'bashdefault default dirnames filenames + nospace plusdirs' -- "$cur") ) return ;; - -A) - COMPREPLY=( $( compgen -W 'alias arrayvar binding builtin command + -*A) + COMPREPLY=( $(compgen -W 'alias arrayvar binding builtin command directory disabled enabled export file function group helptopic hostname job keyword running service setopt shopt signal - stopped user variable' -- "$cur" ) ) + stopped user variable' -- "$cur") ) return ;; - -C) - COMPREPLY=( $( compgen -A command -- "$cur" ) ) + -*C) + COMPREPLY=( $(compgen -A command -- "$cur") ) return ;; - -F) - COMPREPLY=( $( compgen -A function -- "$cur" ) ) + -*F) + COMPREPLY=( $(compgen -A function -- "$cur") ) return ;; - -p|-r) - COMPREPLY=( $( complete -p | command sed -e 's|.* ||' ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) + -*p|-*r) + COMPREPLY=( $(complete -p | command sed -e 's|.* ||') ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) return ;; - esac if [[ "$cur" == -* ]]; then # relevant options completion local opts="-a -b -c -d -e -f -g -j -k -o -s -u -v -A -G -W -P -S -X" [[ $1 != compgen ]] && opts+=" -F -C" - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) else - COMPREPLY=( $( compgen -A command -- "$cur" ) ) + COMPREPLY=( $(compgen -A command -- "$cur") ) fi } && complete -F _complete compgen complete diff --git a/completions/config_list b/completions/config_list index 653c628a..f86263d7 100644 --- a/completions/config_list +++ b/completions/config_list @@ -15,8 +15,8 @@ _config_list() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--inputfile --outputfile --checkonly - --verbose --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--inputfile --outputfile --checkonly + --verbose --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/configure b/completions/configure index 0e37726b..726c7bda 100644 --- a/completions/configure +++ b/completions/configure @@ -27,13 +27,13 @@ _configure() [[ "$cur" != -* ]] && return if [[ -n $COMP_CONFIGURE_HINTS ]]; then - COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \ + COMPREPLY=( $(compgen -W "$($1 --help 2>&1 | \ awk '/^ --[A-Za-z]/ { print $1; \ - if ($2 ~ /--[A-Za-z]/) print $2 }' | command sed -e 's/[[,].*//g' )" \ - -- "$cur" ) ) + if ($2 ~ /--[A-Za-z]/) print $2 }' | command sed -e 's/[[,].*//g')" \ + -- "$cur") ) [[ $COMPREPLY == *=* ]] && compopt -o nospace else - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/convert b/completions/convert index 59647d59..3ebfc5e9 100644 --- a/completions/convert +++ b/completions/convert @@ -4,97 +4,97 @@ _ImageMagick() { case $prev in -channel) - COMPREPLY=( $( compgen -W 'Red Green Blue Opacity Matte Cyan - Magenta Yellow Black' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Red Green Blue Opacity Matte Cyan + Magenta Yellow Black' -- "$cur") ) return ;; -colormap) - COMPREPLY=( $( compgen -W 'shared private' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'shared private' -- "$cur") ) return ;; -colorspace) - COMPREPLY=( $( compgen -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ - YPbPr YUV CMYK' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ + YPbPr YUV CMYK' -- "$cur") ) return ;; -compose) - COMPREPLY=( $( compgen -W 'Over In Out Atop Xor Plus Minus Add + COMPREPLY=( $(compgen -W 'Over In Out Atop Xor Plus Minus Add Subtract Difference Multiply Bumpmap Copy CopyRed CopyGreen - CopyBlue CopyOpacity' -- "$cur" ) ) + CopyBlue CopyOpacity' -- "$cur") ) return ;; -compress) - COMPREPLY=( $( compgen -W 'None BZip Fax Group4 JPEG Lossless LZW - RLE Zip' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'None BZip Fax Group4 JPEG Lossless LZW + RLE Zip' -- "$cur") ) return ;; -dispose) - COMPREPLY=( $( compgen -W 'Undefined None Background Previous' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Undefined None Background Previous' \ + -- "$cur") ) return ;; -encoding) - COMPREPLY=( $( compgen -W 'AdobeCustom AdobeExpert AdobeStandard + COMPREPLY=( $(compgen -W 'AdobeCustom AdobeExpert AdobeStandard AppleRoman BIG5 GB2312 Latin2 None SJIScode Symbol Unicode - Wansung' -- "$cur" ) ) + Wansung' -- "$cur") ) return ;; -endian) - COMPREPLY=( $( compgen -W 'MSB LSB' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'MSB LSB' -- "$cur") ) return ;; -filter) - COMPREPLY=( $( compgen -W 'Point Box Triangle Hermite Hanning + COMPREPLY=( $(compgen -W 'Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell - Lanczos Bessel Sinc' -- "$cur" ) ) + Lanczos Bessel Sinc' -- "$cur") ) return ;; -format) - COMPREPLY=( $( compgen -W "$( convert -list format | awk \ - '/ [r-][w-][+-] / { sub("[*]$","",$1); print tolower($1) }' )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(convert -list format | awk \ + '/ [r-][w-][+-] / { sub("[*]$","",$1); print tolower($1) }')" \ + -- "$cur") ) return ;; -gravity) - COMPREPLY=( $( compgen -W 'Northwest North NorthEast West Center - East SouthWest South SouthEast' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Northwest North NorthEast West Center + East SouthWest South SouthEast' -- "$cur") ) return ;; -intent) - COMPREPLY=( $( compgen -W 'Absolute Perceptual Relative - Saturation' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Absolute Perceptual Relative + Saturation' -- "$cur") ) return ;; -interlace) - COMPREPLY=( $( compgen -W 'None Line Plane Partition' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'None Line Plane Partition' -- "$cur") ) return ;; -limit) - COMPREPLY=( $( compgen -W 'Disk File Map Memory' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Disk File Map Memory' -- "$cur") ) return ;; -list) - COMPREPLY=( $( compgen -W 'Delegate Format Magic Module Resource - Type' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Delegate Format Magic Module Resource + Type' -- "$cur") ) return ;; -map) - COMPREPLY=( $( compgen -W 'best default gray red green blue' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'best default gray red green blue' \ + -- "$cur") ) _filedir return ;; -noise) - COMPREPLY=( $( compgen -W 'Uniform Gaussian Multiplicative - Impulse Laplacian Poisson' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Uniform Gaussian Multiplicative + Impulse Laplacian Poisson' -- "$cur") ) return ;; -preview) - COMPREPLY=( $( compgen -W 'Rotate Shear Roll Hue Saturation + COMPREPLY=( $(compgen -W 'Rotate Shear Roll Hue Saturation Brightness Gamma Spiff Dull Grayscale Quantize Despeckle ReduceNoise AddNoise Sharpen Blur Treshold EdgeDetect Spread Shade Raise Segment Solarize Swirl Implode Wave OilPaint - CharcoalDrawing JPEG' -- "$cur" ) ) + CharcoalDrawing JPEG' -- "$cur") ) return ;; -mask|-profile|-texture|-tile|-write) @@ -102,24 +102,24 @@ _ImageMagick() return ;; -type) - COMPREPLY=( $( compgen -W 'Bilevel Grayscale Palette PaletteMatte + COMPREPLY=( $(compgen -W 'Bilevel Grayscale Palette PaletteMatte TrueColor TrueColorMatte ColorSeparation ColorSeparationlMatte - Optimize' -- "$cur" ) ) + Optimize' -- "$cur") ) return ;; -units) - COMPREPLY=( $( compgen -W 'Undefined PixelsPerInch - PixelsPerCentimeter' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Undefined PixelsPerInch + PixelsPerCentimeter' -- "$cur") ) return ;; -virtual-pixel) - COMPREPLY=( $( compgen -W 'Constant Edge mirror tile' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'Constant Edge mirror tile' -- "$cur") ) return ;; -visual) - COMPREPLY=( $( compgen -W 'StaticGray GrayScale StaticColor + COMPREPLY=( $(compgen -W 'StaticGray GrayScale StaticColor PseudoColor TrueColor DirectColor defaut visualid' \ - -- "$cur" ) ) + -- "$cur") ) return ;; esac @@ -135,11 +135,11 @@ _convert() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+adjoin +append +compress +contrast +debug + COMPREPLY=( $(compgen -W '+adjoin +append +compress +contrast +debug +dither +endian +gamma +label +map +mask +matte +negate +noise - +page +raise +render +write' -- "$cur" ) ) + +page +raise +render +write' -- "$cur") ) else _filedir fi @@ -154,10 +154,10 @@ _mogrify() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither +endian - +gamma +label +map +mask +matte +negate +page +raise' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+compress +contrast +debug +dither +endian + +gamma +label +map +mask +matte +negate +page +raise' -- "$cur") ) else _filedir fi @@ -172,10 +172,10 @@ _display() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither +endian - +gamma +label +map +matte +negate +page +raise +write' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+compress +contrast +debug +dither +endian + +gamma +label +map +matte +negate +page +raise +write' -- "$cur") ) else _filedir fi @@ -190,10 +190,10 @@ _animate() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+debug +dither +gamma +map +matte' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+debug +dither +gamma +map +matte' \ + -- "$cur") ) else _filedir fi @@ -208,9 +208,9 @@ _identify() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) else _filedir fi @@ -225,10 +225,10 @@ _montage() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+adjoin +compress +debug +dither +endian - +gamma +label +matte +page' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+adjoin +compress +debug +dither +endian + +gamma +label +matte +page' -- "$cur") ) else _filedir fi @@ -243,10 +243,10 @@ _composite() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+compress +debug +dither +endian +label - +matte +negate +page +write' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+compress +debug +dither +endian +label + +matte +negate +page +write' -- "$cur") ) else _filedir fi @@ -261,9 +261,9 @@ _compare() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) else _filedir fi @@ -278,9 +278,9 @@ _conjure() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) else _filedir fi @@ -295,9 +295,9 @@ _import() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) else _filedir fi @@ -312,9 +312,9 @@ _stream() _ImageMagick && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) else _filedir fi diff --git a/completions/cowsay b/completions/cowsay index 4f4411ac..c6cbf813 100644 --- a/completions/cowsay +++ b/completions/cowsay @@ -7,15 +7,15 @@ _cowsay() case $prev in -f) - COMPREPLY=( $( compgen -W \ - '$( cowsay -l 2>/dev/null | tail -n +2 )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(cowsay -l 2>/dev/null | tail -n +2)' -- "$cur") ) return ;; esac # relevant options completion - COMPREPLY=( $( compgen -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W' \ + -- "$cur") ) } && complete -F _cowsay -o default cowsay cowthink diff --git a/completions/cpan2dist b/completions/cpan2dist index 9704782d..b24e068c 100644 --- a/completions/cpan2dist +++ b/completions/cpan2dist @@ -8,9 +8,9 @@ _cpan2dist() case $prev in --format) # should remove ":" from COMP_WORDBREAKS, but doesn't work (?) - COMPREPLY=( $( compgen -W '$(perl -MCPANPLUS::Dist -e \ + COMPREPLY=( $(compgen -W '$(perl -MCPANPLUS::Dist -e \ "print map { \"\$_\n\" } CPANPLUS::Dist->dist_types")' \ - -- "$cur" ) ) + -- "$cur") ) return ;; --banlist|--ignorelist|--modulelist|--logfile) @@ -20,16 +20,16 @@ _cpan2dist() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else local cpandirs=( "$HOME/.cpanplus/" "$HOME/.cpan/source/modules/" ) local packagelist - for dir in ${cpandirs[@]}; do + for dir in "${cpandirs[@]}"; do [[ -d "$dir" && -r "$dir/02packages.details.txt.gz" ]] && \ packagelist="$dir/02packages.details.txt.gz" done - [[ $packagelist ]] && COMPREPLY=( $( zgrep "^${cur//-/::}" \ - $packagelist 2>/dev/null | awk '{print $1}' | command sed -e 's/::/-/g' ) ) + [[ $packagelist ]] && COMPREPLY=( $(zgrep "^${cur//-/::}" \ + $packagelist 2>/dev/null | awk '{print $1}' | command sed -e 's/::/-/g') ) fi } && complete -F _cpan2dist -o default cpan2dist diff --git a/completions/cpio b/completions/cpio index 36e3fe90..bbb1ecf9 100644 --- a/completions/cpio +++ b/completions/cpio @@ -7,22 +7,22 @@ _cpio() # --name value style option case $prev in - -H|--format) - COMPREPLY=( $( compgen -W \ - 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur" ) ) + --format|-!(-*)H) + COMPREPLY=( $(compgen -W \ + 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur") ) return ;; - -E|-F|-I|--file|--pattern-file) + --file|--pattern-file|-!(-*)[EFI]) _filedir return ;; - -R|--owner) + --owner|-!(-*)R) _usergroup return ;; --rsh-command) compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) return ;; esac @@ -30,23 +30,23 @@ _cpio() $split && return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through - -? --help --license --usage --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-o --create -i --extract -p --pass-through + -? --help --license --usage --version' -- "$cur") ) else case ${words[1]} in -o|--create) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B -L -V -C -H -M + COMPREPLY=( $(compgen -W '-0 -a -c -v -A -B -L -V -C -H -M -O -F --file --format --message --null --reset-access-time --verbose --dot --append --block-size --dereference --io-size --quiet --force-local --rsh-command --help --version' \ - -- "$cur" ) ) + -- "$cur") ) fi ;; -i|--extract) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-b -c -d -f -m -n -r -t -s -u -v + COMPREPLY=( $(compgen -W '-b -c -d -f -m -n -r -t -s -u -v -B -S -V -C -E -H -M -R -I -F --file --make-directories --nonmatching --preserve-modification-time --numeric-uid-gid --rename --list --swap-bytes --swap @@ -55,17 +55,17 @@ _cpio() --owner --no-preserve-owner --message --force-local --no-absolute-filenames --sparse --only-verify-crc --quiet --rsh-command --help --to-stdout --version' \ - -- "$cur" ) ) + -- "$cur") ) fi ;; -p*|--pass-through) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-0 -a -d -l -m -u -v -L -V -R + COMPREPLY=( $(compgen -W '-0 -a -d -l -m -u -v -L -V -R --null --reset-access-time --make-directories --link --quiet --preserve-modification-time --unconditional --verbose --dot --dereference --owner --no-preserve-owner --sparse --help --version' \ - -- "$cur" ) ) + -- "$cur") ) else _filedir -d fi diff --git a/completions/cppcheck b/completions/cppcheck index 86990dd5..2e487f81 100644 --- a/completions/cppcheck +++ b/completions/cppcheck @@ -23,14 +23,14 @@ _cppcheck() cur="${cur##*,}" split=true fi - COMPREPLY=( $( compgen -W 'all warning style performance + COMPREPLY=( $(compgen -W 'all warning style performance portability information unusedFunction missingInclude' \ - -- "$cur" ) ) + -- "$cur") ) $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) return ;; --error-exitcode) - COMPREPLY=( $( compgen -W '{0..255}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..255}' -- "$cur") ) return ;; --file-list) @@ -43,22 +43,22 @@ _cppcheck() return ;; -j) - COMPREPLY=( $( compgen -W "{2..$(_ncpus)}" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "{2..$(_ncpus)}" -- "$cur") ) return ;; --language|-x) - COMPREPLY=( $( compgen -W 'c c++' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'c c++' -- "$cur") ) return ;; --std) - COMPREPLY=( $( compgen -W 'c89 c99 c11 c++03 c++11 posix' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'c89 c99 c11 c++03 c++11 posix' \ + -- "$cur") ) return ;; --platform) _filedir - COMPREPLY+=( $( compgen -W 'unix32 unix64 win32A win32W win64 - native' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W 'unix32 unix64 win32A win32W win64 + native' -- "$cur") ) return ;; -rp|--relative-paths) @@ -72,7 +72,7 @@ _cppcheck() return ;; --xml-version) - COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) return ;; esac @@ -80,7 +80,7 @@ _cppcheck() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])' diff --git a/completions/crontab b/completions/crontab index bb8d0e24..a5e5cc58 100644 --- a/completions/crontab +++ b/completions/crontab @@ -6,7 +6,7 @@ _crontab() _init_completion || return case $prev in - -u) + -*u) _allowed_users return ;; @@ -36,12 +36,12 @@ _crontab() done if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '${!opts[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${!opts[@]}' -- "$cur") ) return fi # do filenames only if we did not have -l, -r, or -e - [[ "${words[@]}" == *\ -[lre]* ]] || _filedir + [[ "${words[*]}" == *\ -[lre]* ]] || _filedir } && complete -F _crontab crontab diff --git a/completions/cryptsetup b/completions/cryptsetup index 570b27ef..f8be116f 100644 --- a/completions/cryptsetup +++ b/completions/cryptsetup @@ -2,8 +2,7 @@ _cryptsetup_name() { - COMPREPLY=( $( compgen -X control -W '$( command ls /dev/mapper )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -X control -W '$(command ls /dev/mapper)' -- "$cur") ) } _cryptsetup_device() @@ -18,10 +17,18 @@ _cryptsetup() _init_completion -s || return case $prev in - --key-file|--master-key-file|--header-backup-file|-d) + --help|--version|--cipher|--hash|--*-size|--key-slot|--size|--offset|\ + --skip|--iter-time|--timeout|--tries|-!(-*)[chslSbopitT]) + return + ;; + --key-file|--master-key-file|--header-backup-file|-!(-*)d) _filedir return ;; + --type|-!(-*)M) + COMPREPLY=( $(compgen -W "luks plain loopaes tcrypt" -- "$cur") ) + return + ;; esac $split && return @@ -30,17 +37,16 @@ _cryptsetup() _get_first_arg if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else - COMPREPLY=( $( compgen -W 'open close resize status benchmark + COMPREPLY=( $(compgen -W 'open close resize status benchmark repair erase luksFormat luksAddKey luksRemoveKey luksChangeKey luksKillSlot luksUUID isLuks luksDump tcryptDump luksSuspend - luksResume luksHeaderBackup luksHeaderRestore' -- "$cur" ) ) + luksResume luksHeaderBackup luksHeaderRestore' -- "$cur") ) fi else - local args - _count_args + local args; _count_args "" "-!(-*)[chslSbopitTdM]" case $arg in open|create|luksOpen|loopaesOpen|tcryptOpen) case $args in diff --git a/completions/curl b/completions/curl index c28a8ccd..2fe06272 100644 --- a/completions/curl +++ b/completions/curl @@ -6,24 +6,24 @@ _curl() _init_completion || return case $prev in - --ciphers|--connect-timeout|-C|--continue-at|-F|--form|--form-string|\ - --ftp-account|--ftp-alternative-to-user|-P|--ftp-port|-H|--header|-h|\ - --help|--hostpubmd5|--keepalive-time|--krb|--limit-rate|--local-port|\ - --mail-from|--mail-rcpt|--max-filesize|--max-redirs|-m|--max-time|\ - --pass|--proto|--proto-redir|--proxy-user|--proxy1.0|-Q|--quote|-r|\ - --range|-X|--request|--retry|--retry-delay|--retry-max-time|\ - --socks5-gssapi-service|-t|--telnet-option|--tftp-blksize|-z|\ - --time-cond|--url|-u|--user|-A|--user-agent|-V|--version|-w|\ - --write-out|--resolve|--tlsuser|--tlspassword) - return - ;; - -K|--config|-b|--cookie|-c|--cookie-jar|-D|--dump-header|--egd-file|\ - --key|--libcurl|-o|--output|--random-file|-T|--upload-file|--trace|\ - --trace-ascii|--netrc-file) + --ciphers|--connect-timeout|--continue-at|--form|--form-string|\ + --ftp-account|--ftp-alternative-to-user|--ftp-port|--header|--help|\ + --hostpubmd5|--keepalive-time|--krb|--limit-rate|--local-port|\ + --mail-from|--mail-rcpt|--max-filesize|--max-redirs|--max-time|--pass|\ + --proto|--proto-redir|--proxy-user|--proxy1.0|--quote|--range|\ + --request|--retry|--retry-delay|--retry-max-time|\ + --socks5-gssapi-service|--telnet-option|--tftp-blksize|--time-cond|\ + --url|--user|--user-agent|--version|--write-out|--resolve|--tlsuser|\ + --tlspassword|-!(-*)[CFPHhmQrXtzuAVw]) + return + ;; + --config|--cookie|--cookie-jar|--dump-header|--egd-file|\ + --key|--libcurl|--output|--random-file|--upload-file|--trace|\ + --trace-ascii|--netrc-file|-!(-*)[KbcDoT]) _filedir return ;; - --cacert|-E|--cert) + --cacert|--cert|-!(-*)E) _filedir '@(c?(e)rt|cer|pem|der)' return ;; @@ -32,14 +32,14 @@ _curl() return ;; --cert-type|--key-type) - COMPREPLY=( $( compgen -W 'DER PEM ENG' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'DER PEM ENG' -- "$cur") ) return ;; --crlfile) _filedir crl return ;; - -d|--data|--data-ascii|--data-binary|--data-urlencode) + --data|--data-ascii|--data-binary|--data-urlencode|-!(-*)d) if [[ $cur == \@* ]]; then cur=${cur:1} _filedir @@ -48,26 +48,26 @@ _curl() return ;; --delegation) - COMPREPLY=( $( compgen -W 'none policy always' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'none policy always' -- "$cur") ) return ;; --engine) - COMPREPLY=( $( compgen -W 'list' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'list' -- "$cur") ) return ;; --ftp-method) - COMPREPLY=( $( compgen -W 'multicwd nocwd singlecwd' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'multicwd nocwd singlecwd' -- "$cur") ) return ;; --ftp-ssl-ccc-mode) - COMPREPLY=( $( compgen -W 'active passive' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'active passive' -- "$cur") ) return ;; --interface) _available_interfaces -a return ;; - -x|--proxy|--socks4|--socks4a|--socks5|--socks5-hostname) + --proxy|--socks4|--socks4a|--socks5|--socks5-hostname|-!(-*)x) _known_hosts_real -- "$cur" return ;; @@ -76,18 +76,18 @@ _curl() return ;; --stderr) - COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-' -- "$cur") ) _filedir return ;; --tlsauthtype) - COMPREPLY=( $( compgen -W 'SRP' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'SRP' -- "$cur") ) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _curl curl diff --git a/completions/cvs b/completions/cvs index fee256f2..0fb49f9c 100644 --- a/completions/cvs +++ b/completions/cvs @@ -4,7 +4,7 @@ _cvs_entries() { local prefix=${cur%/*}/ IFS=$'\n' [[ -e ${prefix:-}CVS/Entries ]] || prefix="" - entries=( $( cut -d/ -f2 -s ${prefix:-}CVS/Entries 2>/dev/null ) ) + entries=( $(cut -d/ -f2 -s ${prefix:-}CVS/Entries 2>/dev/null) ) if [[ $entries ]]; then entries=( "${entries[@]/#/${prefix:-}}" ) compopt -o filenames @@ -14,9 +14,9 @@ _cvs_entries() _cvs_modules() { if [[ -n $prefix ]]; then - COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) ) + COMPREPLY=( $(command ls -d ${cvsroot}/${prefix}/!(CVSROOT)) ) else - COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) ) + COMPREPLY=( $(command ls -d ${cvsroot}/!(CVSROOT)) ) fi } @@ -27,21 +27,21 @@ _cvs_commands() _cvs_command_options() { - COMPREPLY=( $( compgen -W '$( _parse_help "$1" "--help $2" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help $2")' -- "$cur") ) } _cvs_kflags() { - COMPREPLY=( $( compgen -W 'kv kvl k o b v' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'kv kvl k o b v' -- "$cur") ) } _cvs_roots() { local -a cvsroots cvsroots=( $CVSROOT ) - [[ -r ~/.cvspass ]] && cvsroots+=( $( awk '{ print $2 }' ~/.cvspass ) ) - [[ -r CVS/Root ]] && mapfile -tO ${#cvsroots[@]} cvsroots < CVS/Root - COMPREPLY=( $( compgen -W '${cvsroots[@]}' -- "$cur" ) ) + [[ -r ~/.cvspass ]] && cvsroots+=( $(awk '{ print $2 }' ~/.cvspass) ) + [[ -r CVS/Root ]] && mapfile -tO ${#cvsroots[@]} cvsroots /dev/null ) ) + files=( $(command ls -d ${cur}* 2>/dev/null) ) local f - for i in ${!files[@]}; do + for i in "${!files[@]}"; do if [[ ${files[i]} == ?(*/)CVS ]]; then unset 'files[i]' else @@ -166,22 +167,23 @@ _cvs() done fi done - COMPREPLY=( $( compgen -X "$_backup_glob" -W '${files[@]}' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -X "$_backup_glob" -W '${files[@]}' \ + -- "$cur") ) else _cvs_command_options "$1" $mode fi ;; admin) case $prev in - -a|-A|-b|-c|-e|-l|-m|-n|-N|-o|-s|-t-|-u) + --*) ;; + -*@([aAbcelmnNosu]|t-)) return ;; - -t) + -*t) _filedir return ;; - -k) + -*k) _cvs_kflags return ;; @@ -191,7 +193,7 @@ _cvs() _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $( compgen -W '${entries[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) fi ;; annotate) @@ -201,19 +203,20 @@ _cvs() _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $( compgen -W '${entries[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) fi ;; checkout) case $prev in - -r|-D|-j) + --*) ;; + -*[rDj]) return ;; - -d) + -*d) _filedir -d return ;; - -k) + -*k) _cvs_kflags return ;; @@ -221,19 +224,20 @@ _cvs() if [[ "$cur" != -* ]]; then [[ -z $cvsroot ]] && cvsroot=$CVSROOT - COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \ - awk '{print $1}' ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) + COMPREPLY=( $(cvs -d "$cvsroot" co -c 2>/dev/null | \ + awk '{print $1}') ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) else _cvs_command_options "$1" $mode fi ;; commit) case $prev in - -m|-r) + --*) ;; + -*[mr]) return ;; - -F) + -*F) _filedir return ;; @@ -247,15 +251,15 @@ _cvs() # this is the least computationally intensive way found so # far, but other changes (something other than # changed/removed/new) may be missing - changed=( $( cvs -q diff --brief 2>&1 | \ - command sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) ) - newremoved=( $( cvs -q diff --brief 2>&1 | \ - command sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) ) - COMPREPLY=( $( compgen -W '${changed[@]:-} \ - ${newremoved[@]:-}' -- "$cur" ) ) + changed=( $(cvs -q diff --brief 2>&1 | \ + command sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p') ) + newremoved=( $(cvs -q diff --brief 2>&1 | \ + command sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p') ) + COMPREPLY=( $(compgen -W '${changed[@]:-} \ + ${newremoved[@]:-}' -- "$cur") ) else _cvs_entries - COMPREPLY=( $( compgen -W '${entries[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) fi else _cvs_command_options "$1" $mode @@ -264,13 +268,13 @@ _cvs() cvsroot) _cvs_roots ;; - diff) + diff|log) if [[ "$cur" == -* ]]; then _cvs_command_options "$1" $mode [[ $COMPREPLY == *= ]] && compopt -o nospace else _cvs_entries - COMPREPLY=( $( compgen -W '${entries[@]:-}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${entries[@]:-}' -- "$cur") ) fi ;; editors|watchers) @@ -278,19 +282,20 @@ _cvs() _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $( compgen -W '${entries[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) fi ;; export) case $prev in - -r|-D) + --*) ;; + -*[rD]) return ;; - -d) + -*d) _filedir -d return ;; - -k) + -*k) _cvs_kflags return ;; @@ -298,18 +303,19 @@ _cvs() if [[ "$cur" != -* ]]; then [[ -z $cvsroot ]] && cvsroot=$CVSROOT - COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) + COMPREPLY=( $(cvs -d "$cvsroot" co -c | awk '{print $1}') ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) else _cvs_command_options "$1" $mode fi ;; import) case $prev in - -I|-b|-m|-W) + --*) ;; + -*[IbmW]) return ;; - -k) + -*k) _cvs_kflags return ;; @@ -324,9 +330,9 @@ _cvs() COMPREPLY=( ${COMPREPLY[@]#$cvsroot} ) COMPREPLY=( ${COMPREPLY[@]#\/} ) fi - pwd=$( pwd ) + pwd=$(pwd) pwd=${pwd##*/} - COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $pwd' -- "$cur") ) else _cvs_command_options "$1" $mode fi @@ -336,21 +342,22 @@ _cvs() _cvs_entries if [[ "$prev" != -f ]]; then # find out what files are missing - for i in ${!entries[@]}; do + for i in "${!entries[@]}"; do [[ -r "${entries[i]}" ]] && unset 'entries[i]' done fi - COMPREPLY=( $( compgen -W '${entries[@]:-}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${entries[@]:-}' -- "$cur") ) else _cvs_command_options "$1" $mode fi ;; update) case $prev in - -r|-D|-j|-I|-W) + --*) ;; + -*[rDjIW]) return ;; - -k) + -*k) _cvs_kflags return ;; @@ -360,27 +367,28 @@ _cvs() _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $( compgen -W '${entries[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) fi ;; "") case $prev in - -T) + --*) ;; + -*T) _filedir -d return ;; - -e|-s) + -*[es]) return ;; - -z) - COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) + -*z) + COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) return ;; esac - COMPREPLY=( $( compgen -W '$( _cvs_commands ) - $( _parse_help "$1" --help-options ) --help --help-commands - --help-options --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_cvs_commands) + $(_parse_help "$1" --help-options) --help --help-commands + --help-options --version' -- "$cur") ) ;; esac diff --git a/completions/cvsps b/completions/cvsps index 64dab54f..721a5b73 100644 --- a/completions/cvsps +++ b/completions/cvsps @@ -10,23 +10,23 @@ _cvsps() return ;; -s) - COMPREPLY=( $( compgen -W "$( $1 2>/dev/null | - awk '/^PatchSet:?[ \t]/ { print $2 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 2>/dev/null | + awk '/^PatchSet:?[ \t]/ { print $2 }')" -- "$cur") ) return ;; -a) - COMPREPLY=( $( compgen -W "$( $1 2>/dev/null | - awk '/^Author:[ \t]/ { print $2 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 2>/dev/null | + awk '/^Author:[ \t]/ { print $2 }')" -- "$cur") ) return ;; -b) - COMPREPLY=( $( compgen -W "$( $1 2>/dev/null | - awk '/^Branch:[ \t]/ { print $2 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 2>/dev/null | + awk '/^Branch:[ \t]/ { print $2 }')" -- "$cur") ) return ;; -r) - COMPREPLY=( $( compgen -W "$( $1 2>/dev/null | - awk '/^Tag:[ \t]+[^(]/ { print $2 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 2>/dev/null | + awk '/^Tag:[ \t]+[^(]/ { print $2 }')" -- "$cur") ) return ;; -p) @@ -38,7 +38,7 @@ _cvsps() return ;; -Z) - COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) return ;; --root) @@ -47,8 +47,8 @@ _cvsps() ;; esac - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) else _xfunc cvs _cvs_roots fi diff --git a/completions/dd b/completions/dd index b2647bca..5384dd5e 100644 --- a/completions/dd +++ b/completions/dd @@ -13,28 +13,28 @@ _dd() ;; conv=*) cur=${cur#*=} - COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock lcase + COMPREPLY=( $(compgen -W 'ascii ebcdic ibm block unblock lcase ucase sparse swab sync excl nocreat notrunc noerror fdatasync - fsync' -- "$cur" ) ) + fsync' -- "$cur") ) return ;; iflag=*|oflag=*) cur=${cur#*=} - COMPREPLY=( $( compgen -W 'append direct directory dsync sync + COMPREPLY=( $(compgen -W 'append direct directory dsync sync fullblock nonblock noatime nocache noctty nofollow count_bytes - skip_bytes seek_bytes' -- "$cur" ) ) + skip_bytes seek_bytes' -- "$cur") ) return ;; status=*) cur=${cur#*=} - COMPREPLY=( $( compgen -W 'none noxfer progress' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'none noxfer progress' -- "$cur") ) return ;; esac - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) \ - $( compgen -W 'bs cbs conv count ibs if iflag obs of oflag - seek skip status' -S '=' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") \ + $(compgen -W 'bs cbs conv count ibs if iflag obs of oflag + seek skip status' -S '=' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _dd dd diff --git a/completions/deja-dup b/completions/deja-dup index a508bb1e..ad3baeb8 100644 --- a/completions/deja-dup +++ b/completions/deja-dup @@ -22,8 +22,7 @@ _deja_dup() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/desktop-file-validate b/completions/desktop-file-validate index 93f21061..7d9f05b2 100644 --- a/completions/desktop-file-validate +++ b/completions/desktop-file-validate @@ -12,7 +12,7 @@ _desktop_file_validate() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/dhclient b/completions/dhclient index 24270c7e..b097bbac 100644 --- a/completions/dhclient +++ b/completions/dhclient @@ -6,7 +6,14 @@ _dhclient() _init_completion || return case $prev in - -cf|-lf|-pf|-sf) + -p|-e) + return + ;; + -D) + COMPREPLY=( $(compgen -W 'LL LLT' -- "$cur") ) + return + ;; + -*f) _filedir return ;; @@ -17,8 +24,7 @@ _dhclient() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-p -d -q -1 -r -lf -pf -cf -sf -s -g -n -nw - -w' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _available_interfaces fi diff --git a/completions/dict b/completions/dict index ac7df3fc..c3ea9906 100644 --- a/completions/dict +++ b/completions/dict @@ -15,36 +15,33 @@ _dict() for (( i=1; i < cword; i++ )); do case ${words[i]} in - -h|--host) - host=${words[i+1]} + --host|-!(-*)h) + host=${words[++i]} [[ -n $host ]] && host="-h $host" - i=$((++i)) ;; - -p|--port) - port=${words[i+1]} + --port|-!(-*)p) + port=${words[++i]} [[ -n $port ]] && port="-p $port" - i=$((++i)) ;; - -d|--database) - db=${words[i+1]} + --database|-!(-*)d) + db=${words[++i]} [[ -n $db ]] && host="-d $db" - i=$((++i)) ;; esac done if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi case $prev in - -d|--database|-i|-info) - COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) ) + --database|-info|-!(-*)[di]) + COMPREPLY=( $(compgen -W '$(_dictdata -D)' -- "$cur") ) return ;; - -s|--strategy) - COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) ) + --strategy|-!(-*)s) + COMPREPLY=( $(compgen -W '$(_dictdata -S)' -- "$cur") ) return ;; esac @@ -55,10 +52,10 @@ _dict() # it down with grep if $cur looks like something that's safe to embed # in a pattern instead. if [[ $cur == +([-A-Za-z0-9/.]) ]]; then - COMPREPLY=( $( compgen -W \ - '$( command grep "^${cur//./\\.}" $dictfile )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(command grep "^${cur//./\\.}" $dictfile)' -- "$cur") ) else - COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(cat $dictfile)' -- "$cur") ) fi fi } && diff --git a/completions/dnssec-keygen b/completions/dnssec-keygen new file mode 100644 index 00000000..2ecfcdc5 --- /dev/null +++ b/completions/dnssec-keygen @@ -0,0 +1,48 @@ +# bash completion for dnssec-keygen(8) -*- shell-script -*- + +_dnssec_keygen_optarg() +{ + local args=$("$1" -h 2>&1 | \ + command sed -e 's/|/ /g' -e 's/(.*//' \ + -ne '/^[[:space:]]*'$2'/,/^[[:space:]]*[(-]/p' | \ + command sed -e 's/^[[:space:]]*'$2'.*://' -e '/^[[:space:]]*-/d') + COMPREPLY+=( $(compgen -W '$args' -- "$cur") ) +} + +_dnssec_keygen() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -[hbEgLpsPARIDSi]) + return + ;; + -K) + _filedir -d + return + ;; + -[ancdfTtm]) + _dnssec_keygen_optarg "$1" $prev + return + ;; + -r) + cur=${cur:=/dev/} + _filedir + return + ;; + -v) + COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") ) + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1" | \ + command sed -e "s/:\$//")' -- "$cur") ) + return + fi +} && +complete -F _dnssec_keygen dnssec-keygen + +# ex: filetype=sh diff --git a/completions/dnsspoof b/completions/dnsspoof index d6b7872b..e45d48d6 100644 --- a/completions/dnsspoof +++ b/completions/dnsspoof @@ -17,7 +17,7 @@ _dnsspoof() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) fi } && diff --git a/completions/dot b/completions/dot index bc3531bb..bad82f2c 100644 --- a/completions/dot +++ b/completions/dot @@ -12,28 +12,28 @@ _dot() return ;; -T*) - local langs=( $( "$1" -TNON_EXISTENT 2>&1 | \ - command sed -ne 's/.*one of://p' ) ) - COMPREPLY=( $( compgen -P -T -W '${langs[@]}' -- "${cur#-T}" ) ) + local langs=( $("$1" -TNON_EXISTENT 2>&1 | \ + command sed -ne 's/.*one of://p') ) + COMPREPLY=( $(compgen -P -T -W '${langs[@]}' -- "${cur#-T}") ) return ;; -K*) - local layouts=( $( "$1" -KNON_EXISTENT 2>&1 | \ - command sed -ne 's/.*one of://p' ) ) - COMPREPLY=( $( compgen -P -K -W '${layouts[@]}' -- "${cur#-K}" ) ) + local layouts=( $("$1" -KNON_EXISTENT 2>&1 | \ + command sed -ne 's/.*one of://p') ) + COMPREPLY=( $(compgen -P -K -W '${layouts[@]}' -- "${cur#-K}") ) return ;; -o*) cur=${cur#-o} _filedir - COMPREPLY=( $( compgen -P -o -W '${COMPREPLY[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -P -o -W '${COMPREPLY[@]}' -- "$cur") ) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n - -n1 -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n + -n1 -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?' -- "$cur") ) [[ $COMPREPLY == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace return fi diff --git a/completions/dpkg b/completions/dpkg index 76dd5b01..827d9cad 100644 --- a/completions/dpkg +++ b/completions/dpkg @@ -3,7 +3,7 @@ _have grep-status && { _comp_dpkg_installed_packages() { - grep-status -P -e "^$1" -a -FStatus 'install ok installed' -n -s Package + grep-status -P -e "^$1" -a -FStatus 'ok installed' -n -s Package } } || { _comp_dpkg_installed_packages() @@ -19,7 +19,7 @@ _comp_dpkg_installed_packages() _have grep-status && { _comp_dpkg_purgeable_packages() { - grep-status -P -e "^$1" -a -FStatus 'install ok installed' -o -FStatus 'deinstall ok config-files' -n -s Package + grep-status -P -e "^$1" -a -FStatus 'ok installed' -o -FStatus 'ok config-files' -n -s Package } } || { _comp_dpkg_purgeable_packages() @@ -44,43 +44,41 @@ _dpkg() # find the last option flag if [[ $cur != -* ]]; then while [[ $prev != -* && $i -ne 1 ]]; do - i=$((i-1)) - prev=${words[i-1]} + prev=${words[--i - 1]} done fi case $prev in - -c|-i|-A|-I|-f|-e|-x|-W|--install|--unpack|--record-avail| \ - --contents|--info|--fsys-tarfile|--field|--control|--extract| \ - --vextract) + --install|--unpack|--record-avail|--contents|--info|--fsys-tarfile|\ + --field|--control|--extract|--vextract|-!(-*)[ciAIfexW]) _filedir '?(u|d)deb' return ;; - -b|--build) + --build|-!(-*)b) _filedir -d return ;; - -s|-p|-l|-W|--status|--print-avail|--list|--show) - COMPREPLY=( $( apt-cache pkgnames "$cur" 2>/dev/null ) ) + --status|--print-avail|--list|--show|-!(-*)[splW]) + COMPREPLY=( $(apt-cache pkgnames "$cur" 2>/dev/null) ) return ;; - -S|--search) + --search|-!(-*)S) _filedir return ;; - -r|-V|--remove|--verify) - COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) ) + --remove|--verify|-!(-*)[rV]) + COMPREPLY=( $(_comp_dpkg_installed_packages "$cur") ) return ;; - -L|-P|--listfiles|--purge) - COMPREPLY=( $( _comp_dpkg_purgeable_packages "$cur" ) ) + --listfiles|--purge|-!(-*)[LP]) + COMPREPLY=( $(_comp_dpkg_purgeable_packages "$cur") ) return ;; esac $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _dpkg dpkg dpkg-deb dpkg-query @@ -95,15 +93,15 @@ _dpkg_reconfigure() local opt case $prev in - -f|--frontend) - opt=( $( printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/* ) ) + --frontend|-!(-*)f) + opt=( $(printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/*) ) opt=( ${opt[@]##*/} ) opt=( ${opt[@]%.pm} ) - COMPREPLY=( $( compgen -W '${opt[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${opt[@]}' -- "$cur") ) return ;; - -p|--priority) - COMPREPLY=( $( compgen -W 'low medium high critical' -- "$cur" ) ) + --priority|-!(-*)p) + COMPREPLY=( $(compgen -W 'low medium high critical' -- "$cur") ) return ;; esac @@ -112,7 +110,7 @@ _dpkg_reconfigure() COMPREPLY=( $(compgen -W '--frontend --priority --all --unseen-only --help --showold --force --terse' -- "$cur" ) ) else - COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) ) + COMPREPLY=( $(_comp_dpkg_installed_packages "$cur") ) fi } && complete -F _dpkg_reconfigure -o default dpkg-reconfigure diff --git a/completions/dpkg-source b/completions/dpkg-source index 54403851..ffc34c41 100644 --- a/completions/dpkg-source +++ b/completions/dpkg-source @@ -10,7 +10,7 @@ _dpkg_source() packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sr -ss -sA -sK -sP \ -sU -sR" unpackopts="-sp -sn -su" - options="-x -b $packopts $unpackopts" + options="-x -b --print-format --before-build --after-build --commit $packopts $unpackopts" fields="Format Source Version Binary Maintainer Uploader Architecture \ Standards-Version Build-Depends Files" @@ -33,7 +33,7 @@ _dpkg_source() _filedir 'dsc' ;; *) - COMPREPLY=( $( compgen -W "$unpackopts" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$unpackopts" -- "$cur") ) _filedir -d _filedir ;; @@ -57,7 +57,7 @@ _dpkg_source() ;; -F) # -F: force change log format - COMPREPLY=( $( command ls /usr/lib/dpkg/parsechangelog ) ) + COMPREPLY=( $(command ls /usr/lib/dpkg/parsechangelog) ) ;; -V|-D) # -V: set a substitution variable @@ -72,23 +72,23 @@ _dpkg_source() # $cur contains a "=" COMPREPLY=() else - COMPREPLY=( $( compgen -W "$fields" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$fields" -- "$cur") ) fi ;; -U) # -U: remove a field # Suggest possible fieldnames - COMPREPLY=( $( compgen -W "$fields" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$fields" -- "$cur") ) ;; *) - COMPREPLY=( $( compgen -W "$packopts $unpackopts" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$packopts $unpackopts" \ + -- "$cur") ) ;; esac return ;; *) - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) return ;; esac diff --git a/completions/dselect b/completions/dselect index e5f148cb..6ad38842 100644 --- a/completions/dselect +++ b/completions/dselect @@ -17,11 +17,10 @@ _dselect() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--admindir --help --version --licence - --expert --debug' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'access update select install config remove - quit' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'access update select install config remove + quit' -- "$cur") ) fi } && diff --git a/completions/dsniff b/completions/dsniff index 165ab74b..e8e5bf37 100644 --- a/completions/dsniff +++ b/completions/dsniff @@ -17,7 +17,7 @@ _dsniff() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" ) -r -w -p' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -r -w -p' -- "$cur") ) fi } && diff --git a/completions/dumpdb b/completions/dumpdb index ced754f5..981211bb 100644 --- a/completions/dumpdb +++ b/completions/dumpdb @@ -6,8 +6,8 @@ _dumpdb() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--marshal --pickle --noprint --help' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--marshal --pickle --noprint --help' \ + -- "$cur") ) else _filedir fi diff --git a/completions/dumpe2fs b/completions/dumpe2fs index 90f84791..f44ecc32 100644 --- a/completions/dumpe2fs +++ b/completions/dumpe2fs @@ -6,17 +6,17 @@ _dumpe2fs() _init_completion || return case $prev in - -o|-V) + -*[oV]) return ;; - -i) + -*i) _filedir return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi diff --git a/completions/e2freefrag b/completions/e2freefrag index bee4a169..355ebb94 100644 --- a/completions/e2freefrag +++ b/completions/e2freefrag @@ -12,7 +12,7 @@ _e2freefrag() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h)' -- "$cur") ) return fi diff --git a/completions/ebtables b/completions/ebtables index 05af7e39..325962b5 100644 --- a/completions/ebtables +++ b/completions/ebtables @@ -8,45 +8,40 @@ _ebtables() local table chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \ targets='ACCEPT DROP CONTINUE RETURN' - if [[ ${words[@]} == *-t\ *filter* ]]; then - table="-t filter" - elif [[ ${words[@]} == *-t\ *nat* ]]; then - table="-t nat" - elif [[ ${words[@]} == *-t\ *mangle* ]]; then - table="-t mangle" - fi + [[ "${words[*]}" =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] \ + && table="-t ${BASH_REMATCH[2]}" case $prev in - -*[AIDPFXLZ]) - COMPREPLY=( $( compgen -W '`"$1" $table -L 2>/dev/null | \ - command sed -ne "$chain"`' -- "$cur" ) ) + -!(-*)[AIDPFXLZ]) + COMPREPLY=( $(compgen -W '`"$1" $table -L 2>/dev/null | \ + command sed -ne "$chain"`' -- "$cur") ) ;; - -*t) - COMPREPLY=( $( compgen -W 'nat filter broute' -- "$cur" ) ) + -!(-*)t) + COMPREPLY=( $(compgen -W 'nat filter broute' -- "$cur") ) ;; - -j) + -!(-*)j) if [[ "$table" == "-t filter" || -z "$table" ]]; then - COMPREPLY=( $( compgen -W '$targets + COMPREPLY=( $(compgen -W '$targets $("$1" $table -L 2>/dev/null | \ command sed -n -e "s/INPUT\|OUTPUT\|FORWARD//" \ -e "$chain")' \ - -- "$cur" ) ) + -- "$cur") ) elif [[ $table == "-t nat" ]]; then - COMPREPLY=( $( compgen -W '$targets + COMPREPLY=( $(compgen -W '$targets $("$1" $table -L 2>/dev/null | \ command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \ -e "$chain")' \ - -- "$cur" ) ) + -- "$cur") ) elif [[ $table == "-t broute" ]]; then - COMPREPLY=( $( compgen -W 'ACCEPT DROP + COMPREPLY=( $(compgen -W 'ACCEPT DROP $("$1" $table -L 2>/dev/null | \ command sed -n -e "s/BROUTING//" -e "$chain")' \ - -- "$cur" ) ) + -- "$cur") ) fi ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--802_3-sap --802_3-type --among-dst + COMPREPLY=( $(compgen -W '--802_3-sap --802_3-type --among-dst --among-dst-file --among-src --among-src-file --append --arp-gratuitous --arp-htype --arp-ip-dst --arp-ip-src --arp-mac-dst --arp-mac-src --arp-opcode --arp-ptype --arpreply-mac @@ -72,7 +67,7 @@ _ebtables() --stp-sender-prio --stp-type --table --to-destination --to-dst --to-source --to-src --ulog --ulog-cprange --ulog-nlgroup --ulog-prefix --ulog-qthreshold --version --vlan-encap --vlan-id - --vlan-prio --zero' -- "$cur" ) ) + --vlan-prio --zero' -- "$cur") ) fi ;; esac diff --git a/completions/ecryptfs-migrate-home b/completions/ecryptfs-migrate-home new file mode 100644 index 00000000..bad0962e --- /dev/null +++ b/completions/ecryptfs-migrate-home @@ -0,0 +1,22 @@ +# ecryptfs-migrate-home(8) completion -*- shell-script -*- + +_ecryptfs_migrate_home() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help) + return + ;; + --user|-u) + COMPREPLY=( $(compgen -u -- "$cur") ) + return + ;; + esac + + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) +} && +complete -F _ecryptfs_migrate_home ecryptfs-migrate-home + +# ex: filetype=sh diff --git a/completions/eog b/completions/eog index d5621119..d10cbbae 100644 --- a/completions/eog +++ b/completions/eog @@ -14,8 +14,7 @@ _eog() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/ether-wake b/completions/ether-wake index 387b2d64..a3e3e406 100644 --- a/completions/ether-wake +++ b/completions/ether-wake @@ -16,12 +16,12 @@ _ether_wake() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -u ) -V' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -u) -V' -- "$cur") ) return fi _mac_addresses } && -complete -F _ether_wake ether-wake +complete -F _ether_wake ether-wake etherwake # ex: filetype=sh diff --git a/completions/evince b/completions/evince index eb6c7305..d50f23c3 100644 --- a/completions/evince +++ b/completions/evince @@ -6,9 +6,9 @@ _evince() _init_completion -s || return case $prev in - --help*|-h|--sm-client-id|--class|--name|--screen|--gdk-debug|\ - --gdk-no-debug|--gtk-module|--gtk-debug|--gtk-no-debug|\ - -p|--page-label|-i|--page-index|-l|--find|--display) + --help*|--sm-client-id|--class|--name|--screen|--gdk-debug|\ + --gdk-no-debug|--gtk-module|--gtk-debug|--gtk-no-debug|--page-label|\ + --page-index|--find|--display|-!(-*)[hpil]) return ;; --sm-client-state-file) @@ -20,8 +20,7 @@ _evince() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/export b/completions/export index 31715f9a..816182f6 100644 --- a/completions/export +++ b/completions/export @@ -33,7 +33,7 @@ _export() case $cur in *=) - local pval=$( quote "$( eval printf %s \"\$${cur%=}\" )" ) + local pval=$(quote "$(eval printf %s \"\$${cur%=}\")") # Complete previous value if it's not empty. if [[ $pval != \'\' ]]; then COMPREPLY=( "$pval" ) @@ -48,8 +48,7 @@ _export() ;; *) if [[ $cword -eq 1 && $cur == -* ]]; then - COMPREPLY=( $( compgen -W \ - '-p $( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-p $(_parse_usage "$1")' -- "$cur") ) return fi local suffix @@ -57,7 +56,7 @@ _export() suffix+== compopt -o nospace fi - COMPREPLY=( $( compgen -A $action -S "$suffix" -- "$cur" ) ) + COMPREPLY=( $(compgen -A $action -S "$suffix" -- "$cur") ) ;; esac } && diff --git a/completions/faillog b/completions/faillog index 3b4a23d0..5e7d2ab2 100644 --- a/completions/faillog +++ b/completions/faillog @@ -6,11 +6,11 @@ _faillog() _init_completion -s || return case $prev in - -h|--help|-l|--lock-time|-m|--maximum|-t|--time) + --help|--lock-time|--maximum|--time|-!(-*)[hlmt]) return ;; - -u|--user) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + --user|-!(-*)u) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; esac @@ -18,7 +18,7 @@ _faillog() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/fbgs b/completions/fbgs index c58a7af9..7a3ad7be 100644 --- a/completions/fbgs +++ b/completions/fbgs @@ -8,23 +8,23 @@ _fbgs() case "$prev" in -f|--font) local IFS=$'\n' - COMPREPLY=( $( compgen -W '$( fc-list 2>/dev/null )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") ) return ;; -m|--mode) - COMPREPLY=( $( compgen -W '$( command sed \ + COMPREPLY=( $(compgen -W '$(command sed \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ - /etc/fb.modes 2> /dev/null )' -- "$cur" ) ) + /etc/fb.modes 2>/dev/null)' -- "$cur") ) return ;; -d|--device) - COMPREPLY=( $( compgen -f -d -- "${cur:-/dev/}" ) ) + COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") ) return ;; -fp|--firstpage|-lp|--lastpage|-r|--resolution|-s|--scroll|-t|\ --timeout) # expect integer value - COMPREPLY+=( $( compgen -W '{0..9}' ) ) + COMPREPLY+=( $(compgen -W '{0..9}') ) compopt -o nospace return ;; @@ -35,11 +35,11 @@ _fbgs() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--bell --help --password -fp --firstpage + COMPREPLY=( $(compgen -W '--bell --help --password -fp --firstpage -lp --lastpage --color -l -xl -xxl --resolution --autozoom --{,no}autoup --{,no}autodown --{,no}fitwidth --{,no}verbose --{,no}random --vt --scroll --timeout --{,no}once --gamma --font - --device --mode' -- "$cur" ) ) + --device --mode' -- "$cur") ) [[ $COMPREPLY ]] && return fi diff --git a/completions/fbi b/completions/fbi index 75b46b61..ac92e60f 100644 --- a/completions/fbi +++ b/completions/fbi @@ -11,22 +11,22 @@ _fbi() return ;; -r|--resolution) - COMPREPLY+=( $( compgen -W '{1..5}' ) ) + COMPREPLY+=( $(compgen -W '{1..5}') ) return ;; -f|--font) local IFS=$'\n' - COMPREPLY=( $( compgen -W '$( fc-list 2> /dev/null )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") ) return ;; -m|--mode) - COMPREPLY=( $( compgen -W '$( command sed \ + COMPREPLY=( $(compgen -W '$(command sed \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ - /etc/fb.modes 2> /dev/null )' -- "$cur" ) ) + /etc/fb.modes 2>/dev/null)' -- "$cur") ) return ;; -d|--device) - COMPREPLY=( $( compgen -f -d -- "${cur:-/dev/}" ) ) + COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") ) return ;; --cachemem|--blend|-T|--vt|-s|--scroll|-t|--timeout|-g|--gamma) @@ -36,12 +36,12 @@ _fbi() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version --store --list --text + COMPREPLY=( $(compgen -W '--help --version --store --list --text --autozoom --{,no}autoup --{,no}autodown --{,no}fitwidth --{,no}verbose --{,no}random --{,no}comments --{,no}edit --{,no}backup --{,no}preserve --{,no}readahead --cachemem --blend --vt --scroll --timeout --{,no}once --resolution --gamma --font - --device --mode' -- "$cur" ) ) + --device --mode' -- "$cur") ) [[ $COMPREPLY ]] && return fi diff --git a/completions/feh b/completions/feh index 1cd75420..71e59798 100644 --- a/completions/feh +++ b/completions/feh @@ -6,40 +6,40 @@ _feh() _init_completion -s || return case "$prev" in - -B|--image-bg) - COMPREPLY=( $( compgen -W 'checks white black' -- "$cur" ) ) + --image-bg|-B) + COMPREPLY=( $(compgen -W 'checks white black' -- "$cur") ) return ;; - -f|--filelist|-o|--output|-O|--output-only|-\||--start-at) + --filelist|--output|--output-only|--start-at|-!(-*)[foO\|]) _filedir return ;; - -K|--caption-path|-C|--fontpath|-j|--output-dir) + --caption-path|--fontpath|--output-dir|-!(-*)[KCj]) _filedir -d return ;; - -e|--font|-M|--menu-font|-@|--title-font) + --font|--menu-font|--title-font|-!(-*)[eM@]) # expect string like "dejavu.ttf/12" if [[ "$cur" == */* ]]; then # expect integer value - COMPREPLY=( $( compgen -P "$cur" -W '{0..9}' ) ) + COMPREPLY=( $(compgen -P "$cur" -W '{0..9}') ) compopt -o nospace return fi local font_path - # font_path="$( imlib2-config --prefix 2> /dev/null )/share/imlib2/data/fonts" - # COMPREPLY=( $( cd "$font_path" 2> /dev/null; compgen -f \ - # -X "!*.@([tT][tT][fF])" -S / -- "$cur" ) ) + # font_path="$(imlib2-config --prefix 2>/dev/null)/share/imlib2/data/fonts" + # COMPREPLY=( $(cd "$font_path" 2>/dev/null; compgen -f \ + # -X "!*.@([tT][tT][fF])" -S / -- "$cur") ) for (( i=${#words[@]}-1; i>0; i-- )); do if [[ ${words[i]} == -@(C|-fontpath) ]]; then font_path="${words[i+1]}" - COMPREPLY+=( $( cd "$font_path" 2> /dev/null; compgen -f \ - -X "!*.@([tT][tT][fF])" -S / -- "$cur" ) ) + COMPREPLY+=( $(cd "$font_path" 2>/dev/null; compgen -f \ + -X "!*.@([tT][tT][fF])" -S / -- "$cur") ) fi done compopt -o nospace return ;; - -T|--theme) + --theme|-!(-*)T) local conf_path=~/.config/feh/themes local theme_name theme_opts [[ -r $conf_path ]] || return @@ -47,51 +47,51 @@ _feh() if [[ "$theme_name" == '#'* || "$theme_name" == "" ]]; then continue fi - COMPREPLY+=( $( compgen -W "$theme_name" -- "$cur" ) ) - done < "$conf_path" + COMPREPLY+=( $(compgen -W "$theme_name" -- "$cur") ) + done <"$conf_path" return ;; - -S|--sort) - COMPREPLY=( $( compgen -W 'name filename mtime width height - pixels size format' -- "$cur" ) ) + --sort|-!(-*)S) + COMPREPLY=( $(compgen -W 'name filename mtime width height + pixels size format' -- "$cur") ) return ;; - -R|--reload|-H|--limit-height|-W|--limit-width|-E|--thumb-height|\ - -y|--thumb-width|-J|--thumb-redraw|--magick-timeout) + --reload|--limit-height|--limit-width|--thumb-height|--thumb-width|\ + --thumb-redraw|--magick-timeout|-!(-*)[RHWEyJ]) # expect integer value - COMPREPLY+=( $( compgen -W '{0..9}' ) ) + COMPREPLY+=( $(compgen -W '{0..9}') ) compopt -o nospace return ;; --zoom) # expect integer value or "max", "fill" - COMPREPLY=( $( compgen -W 'max fill' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'max fill' -- "$cur") ) if [[ ! $cur || ! $COMPREPLY ]]; then - COMPREPLY+=( $( compgen -W '{0..9}' ) ) + COMPREPLY+=( $(compgen -W '{0..9}') ) compopt -o nospace fi return ;; - -a|--alpha) - COMPREPLY=( $( compgen -W '{0..255}' -- "$cur" ) ) + --alpha|-!(-*)a) + COMPREPLY=( $(compgen -W '{0..255}' -- "$cur") ) return ;; - -b|--bg) + --bg|-!(-*)b) _filedir - COMPREPLY+=( $( compgen -W 'trans' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W 'trans' -- "$cur") ) return ;; - -g|--geometry|--max-dimension|--min-dimension) + --geometry|--max-dimension|--min-dimension|-!(-*)g) # expect string like 640x480 if [[ $cur && "$cur" != *x* ]]; then COMPREPLY=( x ) fi - COMPREPLY+=( $( compgen -W "{0..9}" ) ) + COMPREPLY+=( $(compgen -W "{0..9}") ) compopt -o nospace return ;; - -L|--customlist|--index-info|--info|-D|--slideshow-delay|-~|\ - --thumb-title|-^|--title) + --customlist|--index-info|--info|--slideshow-delay|--thumb-title|\ + --title|-!(-*)[LD~^]) # argument required but no completions available return ;; @@ -101,7 +101,7 @@ _feh() if [[ "$cur" == -* ]]; then # Some versions of feh just output "See 'man feh'" for --help :( - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY ]] && return fi diff --git a/completions/file b/completions/file index f3f6df88..494c7866 100644 --- a/completions/file +++ b/completions/file @@ -6,22 +6,22 @@ _file() _init_completion || return case $prev in - --help|-v|--version|-F|--separator) + --help|--version|--separator|-!(-*)[vF]) return ;; - -m|--magic-file|-f|--files-from) + --magic-file|--files-from|-!(-*)[mf]) _filedir return ;; - -e|--exclude) - COMPREPLY=( $( compgen -W 'apptype ascii cdf compress elf encoding - soft tar text tokens troff' -- "$cur" ) ) + --exclude|-!(-*)e) + COMPREPLY=( $(compgen -W 'apptype ascii cdf compress elf encoding + soft tar text tokens troff' -- "$cur") ) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/file-roller b/completions/file-roller index efa73bb1..bebf04ee 100644 --- a/completions/file-roller +++ b/completions/file-roller @@ -8,19 +8,19 @@ _file_roller() local exts='@(7z|ace|alz|ar|arj|[bglx]z|bz2|tb?(z)2|cab|cb[rz]|iso?(9660)|Z|t[abglx]z|cpio|deb|rar|?(g)tar|gem|lh[az]|lz[4h]|?(t)lrz|lzma|lzo|wim|swm|rpm|sit|zoo)' case $prev in - -'?'|--help|--help-all|--help-gtk|--help-sm-client) + --help|--help-all|--help-gtk|--help-sm-client|-!(-*)'?') return ;; --sm-client-state-file) _filedir return ;; - -a|--add-to) + --add-to|-!(-*)a) _filedir_xspec unzip _filedir "$exts" return ;; - -e|--extract-to|--default-dir) + --extract-to|--default-dir|-!(-*)e) _filedir -d return ;; @@ -29,8 +29,7 @@ _file_roller() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/filefrag b/completions/filefrag index b4866dc0..b8b51e3c 100644 --- a/completions/filefrag +++ b/completions/filefrag @@ -6,7 +6,7 @@ _filefrag() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi diff --git a/completions/filesnarf b/completions/filesnarf index 0cdcfe27..01766555 100644 --- a/completions/filesnarf +++ b/completions/filesnarf @@ -13,7 +13,7 @@ _snarf() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) fi } && diff --git a/completions/find b/completions/find index 4451d059..80fbe8c0 100644 --- a/completions/find +++ b/completions/find @@ -9,7 +9,7 @@ _find() case $prev in -maxdepth|-mindepth) - COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") ) return ;; -newer|-anewer|-cnewer|-fls|-fprint|-fprint0|-fprintf|-name|-iname|\ @@ -20,7 +20,7 @@ _find() -fstype) _fstypes [[ $OSTYPE == *bsd* ]] && \ - COMPREPLY+=( $( compgen -W 'local rdonly' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W 'local rdonly' -- "$cur") ) return ;; -gid) @@ -28,11 +28,11 @@ _find() return ;; -group) - COMPREPLY=( $( compgen -g -- "$cur" 2>/dev/null) ) + COMPREPLY=( $(compgen -g -- "$cur" 2>/dev/null) ) return ;; -xtype|-type) - COMPREPLY=( $( compgen -W 'b c d p f l s' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'b c d p f l s' -- "$cur") ) return ;; -uid) @@ -40,7 +40,7 @@ _find() return ;; -user) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; -exec|-execdir|-ok|-okdir) @@ -56,15 +56,15 @@ _find() return ;; -regextype) - COMPREPLY=( $( compgen -W 'emacs posix-awk posix-basic posix-egrep - posix-extended' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'emacs posix-awk posix-basic posix-egrep + posix-extended' -- "$cur") ) return ;; esac local i exprfound=false # set exprfound to true if there is already an expression present - for i in ${words[@]}; do + for i in "${words[@]}"; do [[ "$i" == [-\(\),\!]* ]] && exprfound=true && break done @@ -75,7 +75,7 @@ _find() fi # complete using basic options - COMPREPLY=( $( compgen -W '-daystart -depth -follow -help + COMPREPLY=( $(compgen -W '-daystart -depth -follow -help -ignore_readdir_race -maxdepth -mindepth -mindepth -mount -noignore_readdir_race -noleaf -regextype -version -warn -nowarn -xdev -amin -anewer -atime -cmin -cnewer -ctime -empty -executable -false @@ -84,7 +84,7 @@ _find() -readable -regex -samefile -size -true -type -uid -used -user -wholename -writable -xtype -context -delete -exec -execdir -fls -fprint -fprint0 -fprintf -ls -ok -okdir -print -print0 -printf -prune - -quit' -- "$cur" ) ) + -quit' -- "$cur") ) if [[ ${#COMPREPLY[@]} -ne 0 ]]; then # this removes any options from the list of completions that have @@ -98,7 +98,7 @@ _find() local j for i in "${words[@]}"; do [[ $i && ${onlyonce[$i]} ]] || continue - for j in ${!COMPREPLY[@]}; do + for j in "${!COMPREPLY[@]}"; do [[ ${COMPREPLY[j]} == $i ]] && unset 'COMPREPLY[j]' done done diff --git a/completions/find_member b/completions/find_member index df1a24f9..720e3074 100644 --- a/completions/find_member +++ b/completions/find_member @@ -15,8 +15,8 @@ _find_member() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--listname --exclude --owners --help' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--listname --exclude --owners --help' \ + -- "$cur") ) fi } && diff --git a/completions/fio b/completions/fio new file mode 100644 index 00000000..7710cf6b --- /dev/null +++ b/completions/fio @@ -0,0 +1,89 @@ +# fio(1) completion -*- shell-script -*- + +_fio() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--version) + return + ;; + --debug) + local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=( $(compgen -W "process file io mem blktrace verify + random parse diskutil job mutex profile time net rate compress + steadystate helperthread" -- "${cur##*,}") ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + return + ;; + --output-format) + COMPREPLY=( $(compgen -W "terse json json+ normal" -- "$cur") ) + return + ;; + --terse-version) + COMPREPLY=( $(compgen -W "2 3" -- "$cur") ) + return + ;; + --cmdhelp) + # TODO more commands? + COMPREPLY=( $(compgen -W "all" -- "$cur") ) + return + ;; + --enghelp) + # TODO print ioengine help, or list available ioengines + # TODO engine,help arg + return + ;; + --eta) + COMPREPLY=( $(compgen -W "always never auto" -- "$cur") ) + return + ;; + --daemonize) + _filedir pid + return + ;; + --client) + _known_hosts_real -- "$cur" + return + ;; + --remote-config) + _filedir job + return + ;; + --idle-prof) + COMPREPLY=( $(compgen -W "system percpu calibrate" -- "$cur") ) + return + ;; + --inflate-log) + _filedir log + return + ;; + --trigger-file) + _filedir + return + ;; + --trigger|--trigger-remote) + compopt -o filenames + COMPREPLY=( $(compgen -c -- "$cur") ) + return + ;; + --aux-path) + _filedir -d + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir job +} && +complete -F _fio fio + +# ex: filetype=sh diff --git a/completions/firefox b/completions/firefox new file mode 100644 index 00000000..eeaca9f6 --- /dev/null +++ b/completions/firefox @@ -0,0 +1,46 @@ +# firefox completion -*- shell-script -*- + +_firefox() +{ + local cur prev words cword split + _init_completion -s || return + + [[ $cur == -MOZ_LOG*=* ]] && prev=${cur%%=*} cur=${cur#*=} + + case $prev in + --help|--version|--display|--UILocale|-MOZ_LOG|--new-window|--new-tab|\ + --private-window|--window-size|--search|--start-debugger-server|\ + --recording|--debugger-args|-[hvPa]) + return + ;; + --profile|--screenshot) + _filedir -d + return + ;; + -MOZ_LOG_FILE) + _filedir log + return + ;; + --recording-file) + _filedir + return + ;; + --debugger|-d) + COMPREPLY=( $(compgen -c -- "$cur") ) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir "@(?([xs])htm?(l)|pdf)" +} && +complete -F _firefox firefox mozilla-firefox iceweasel + +# ex: filetype=sh diff --git a/completions/flake8 b/completions/flake8 index 6f0be12f..f18351e8 100644 --- a/completions/flake8 +++ b/completions/flake8 @@ -6,15 +6,15 @@ _flake8() _init_completion -s || return case $prev in - -h|--help|--version) + --help|--version|-!(-*)h) return ;; --format) - COMPREPLY=( $( compgen -W 'default pylint' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'default pylint' -- "$cur") ) return ;; - -j|--jobs) - COMPREPLY=( $( compgen -W "auto {1..$(_ncpus)}" -- "$cur" ) ) + --jobs|-!(-*)j) + COMPREPLY=( $(compgen -W "auto {1..$(_ncpus)}" -- "$cur") ) return ;; --output-file|--append-config|--config) @@ -30,7 +30,7 @@ _flake8() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/freeciv b/completions/freeciv new file mode 100644 index 00000000..0f475482 --- /dev/null +++ b/completions/freeciv @@ -0,0 +1,41 @@ +# freeciv client completions -*- shell-script -*- + +_freeciv() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--version|--name|--port|-[hvnp]) + return + ;; + --file|--log|--music|--read|--Sound|--tiles|-[flmrSt]) + _filedir + return + ;; + --Announce|-A) + COMPREPLY=( $(compgen -W 'IPv4 IPv6 none' -- "$cur") ) + return + ;; + --debug|-d) + COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) + return + ;; + --Meta|--server|-[Ms]) + _known_hosts_real -- "$cur" + return + ;; + --Plugin|-P) + COMPREPLY=( $(compgen -W 'none esd sdl' -- "$cur") ) + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + fi + +} && +complete -F _freeciv freeciv{,-{gtk{2,3},sdl,xaw}} civclient + +# ex: filetype=sh diff --git a/completions/freeciv-gtk2 b/completions/freeciv-gtk2 deleted file mode 100644 index 953b829a..00000000 --- a/completions/freeciv-gtk2 +++ /dev/null @@ -1,30 +0,0 @@ -# freeciv client completions -*- shell-script -*- - -_civclient() -{ - local cur prev words cword - _init_completion || return - - case $prev in - -l|-S|-t|--log|--Sound|--tiles) - _filedir - return - ;; - -P|--Plugin) - COMPREPLY=( $( compgen -W 'none esd sdl' -- "$cur" ) ) - return - ;; - -s|--server) - _known_hosts_real -- "$cur" - return - ;; - esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - fi - -} && -complete -F _civclient civclient freeciv-gtk2 freeciv-sdl freeciv-xaw - -# ex: filetype=sh diff --git a/completions/freeciv-server b/completions/freeciv-server index 78f57afa..08f63158 100644 --- a/completions/freeciv-server +++ b/completions/freeciv-server @@ -13,7 +13,7 @@ _civserver() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && diff --git a/completions/function b/completions/function index fbcf10d2..a97b5255 100644 --- a/completions/function +++ b/completions/function @@ -8,28 +8,28 @@ _function() if [[ $1 == @(declare|typeset) ]]; then if [[ $cur == [-+]* ]]; then local opts - opts=( $( _parse_usage "$1" ) ) + opts=( $(_parse_usage "$1") ) # Most options also have a '+' form. We'll exclude the ones that don't with compgen. opts+=( ${opts[*]/-/+} ) - COMPREPLY=( $( compgen -W "${opts[*]}" -X '+[Ffgp]' -- "$cur" ) ) + COMPREPLY=( $(compgen -W "${opts[*]}" -X '+[Ffgp]' -- "$cur") ) else local i=1 while [[ ${words[i]} == [-+]* ]]; do if [[ ${words[i]} == -*[fF]* ]]; then - COMPREPLY=( $( compgen -A function -- "$cur" ) ) + COMPREPLY=( $(compgen -A function -- "$cur") ) return fi ((i++)) done if [[ $i -gt 1 ]]; then # There was at least one option and it was not one that limited operations to functions - COMPREPLY=( $( compgen -A variable -- "$cur" ) ) + COMPREPLY=( $(compgen -A variable -- "$cur") ) fi fi elif [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -A function -- "$cur" ) ) + COMPREPLY=( $(compgen -A function -- "$cur") ) else - COMPREPLY=( "() $( type -- ${words[1]} | command sed -e 1,2d )" ) + COMPREPLY=( "() $(type -- ${words[1]} | command sed -e 1,2d)" ) fi } && complete -F _function function declare typeset diff --git a/completions/fusermount b/completions/fusermount index 23671bd6..c40c18ce 100644 --- a/completions/fusermount +++ b/completions/fusermount @@ -6,19 +6,19 @@ _fusermount() _init_completion || return case $prev in - -h|-V|-o) + -*[hVo]) return ;; - -u) - COMPREPLY=( $( compgen -W "$( awk \ + -*u) + COMPREPLY=( $(compgen -W "$(awk \ '{ if ($3 ~ /^fuse(\.|$)/) print $2 }' /etc/mtab \ - 2>/dev/null )" -- "$cur" ) ) + 2>/dev/null)" -- "$cur") ) return ;; esac - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) else _filedir -d fi diff --git a/completions/gcc b/completions/gcc index b93a33f2..b72bf972 100644 --- a/completions/gcc +++ b/completions/gcc @@ -34,31 +34,33 @@ _gcc() esac if [[ "$cur" == -* ]]; then - cc=$( $1 -print-prog-name=$backend 2>/dev/null ) + cc=$($1 -print-prog-name=$backend 2>/dev/null) [[ $cc ]] || return # sink stderr: # for C/C++/ObjectiveC it's useless # for FORTRAN/Java it's an error - COMPREPLY=( $( compgen -W "$( $cc --help 2>/dev/null | tr '\t' ' ' |\ - command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($cc --help 2>/dev/null | tr '\t' ' ' |\ + command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/')" \ + -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir fi } && -complete -F _gcc gcc g++ gfortran g77 g95 gcj gpc && +complete -F _gcc gcc{,-5,-6,-7,-8} g++{,-5,-6,-7,-8} g77 g95 \ + gccgo{,-5,-6,-7,-8} gcj gfortran{,-5,-6,-7,-8} gpc && { cc --version 2>/dev/null | command grep -q GCC || \ - [[ $( _realcommand cc ) == *gcc* ]] && \ + [[ $(_realcommand cc) == *gcc* ]] && \ complete -F _gcc cc || complete -F _minimal cc c++ --version 2>/dev/null | command grep -q GCC || \ - [[ $( _realcommand c++ ) == *g++* ]] && \ + [[ $(_realcommand c++) == *g++* ]] && \ complete -F _gcc c++ || complete -F _minimal c++ f77 --version 2>/dev/null | command grep -q GCC || \ - [[ $( _realcommand f77 ) == *gfortran* ]] && \ + [[ $(_realcommand f77) == *gfortran* ]] && \ complete -F _gcc f77 || complete -F _minimal f77 f95 --version 2>/dev/null | command grep -q GCC || \ - [[ $( _realcommand f95 ) == *gfortran* ]] && \ + [[ $(_realcommand f95) == *gfortran* ]] && \ complete -F _gcc f95 || complete -F _minimal f95 } diff --git a/completions/gcl b/completions/gcl index 5d1ca5f3..9acc813d 100644 --- a/completions/gcl +++ b/completions/gcl @@ -9,8 +9,8 @@ _gcl() # completing an option (may or may not be separated by a space) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-eval -load -f -batch -dir -libdir -compile - -o-file -c-file -h-file -data-file -system-p' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-eval -load -f -batch -dir -libdir -compile + -o-file -c-file -h-file -data-file -system-p' -- "$cur") ) else _filedir fi diff --git a/completions/gdb b/completions/gdb index 75414782..b37387e1 100644 --- a/completions/gdb +++ b/completions/gdb @@ -20,25 +20,25 @@ _gdb() if [[ "$cur" == */* ]]; then # compgen -c works as expected if $cur contains any slashes. IFS=$'\n' - COMPREPLY=( $( PATH="$PATH:." compgen -d -c -- "$cur" ) ) + COMPREPLY=( $(PATH="$PATH:." compgen -d -c -- "$cur") ) else # otherwise compgen -c contains Bash's built-in commands, # functions and aliases. Thus we need to retrieve the program # names manually. IFS=":" - local path_array=( $( \ - command sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" ) ) + local path_array=( $(\ + command sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH") ) IFS=$'\n' - COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \ + COMPREPLY=( $(compgen -d -W '$(find "${path_array[@]}" . \ -mindepth 1 -maxdepth 1 -not -type d -executable \ - -printf "%f\\n" 2>/dev/null)' -- "$cur" ) ) + -printf "%f\\n" 2>/dev/null)' -- "$cur") ) fi elif [[ $cword -eq 2 ]]; then - COMPREPLY=( $( compgen -W "$( command ps axo comm,pid | \ - awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(command ps axo comm,pid | \ + awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')" -- "$cur") ) compopt -o filenames - COMPREPLY+=( $( compgen -f -X '!?(*/)core?(.+([0-9]))' -o plusdirs \ - -- "$cur" ) ) + COMPREPLY+=( $(compgen -f -X '!?(*/)core?(.?*)' -o plusdirs \ + -- "$cur") ) fi } && complete -F _gdb gdb diff --git a/completions/genaliases b/completions/genaliases index f9a9890a..3bad5c7e 100644 --- a/completions/genaliases +++ b/completions/genaliases @@ -6,7 +6,7 @@ _genaliases() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--quiet --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--quiet --help' -- "$cur") ) fi } && diff --git a/completions/genisoimage b/completions/genisoimage index caf6d457..52b66bbe 100644 --- a/completions/genisoimage +++ b/completions/genisoimage @@ -12,8 +12,8 @@ _mkisofs() return ;; -*-charset) - COMPREPLY=( $( compgen -W '$( mkisofs -input-charset \ - help 2>&1 | tail -n +3 )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(mkisofs -input-charset \ + help 2>&1 | tail -n +3)' -- "$cur") ) return ;; -uid) @@ -27,7 +27,7 @@ _mkisofs() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) else _filedir fi diff --git a/completions/geoiplookup b/completions/geoiplookup index 0c92548a..8347728f 100644 --- a/completions/geoiplookup +++ b/completions/geoiplookup @@ -20,7 +20,7 @@ _geoiplookup() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h)' -- "$cur") ) return fi diff --git a/completions/getconf b/completions/getconf index 80be667c..6e86e9de 100644 --- a/completions/getconf +++ b/completions/getconf @@ -11,9 +11,9 @@ _getconf() return ;; -v) - COMPREPLY=( $( compgen -W \ - '$( "$1" -a 2>/dev/null | awk "{ print \$1 }" )' -- \ - "${cur:-POSIX_V}" ) ) + COMPREPLY=( $(compgen -W \ + '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- \ + "${cur:-POSIX_V}") ) return ;; esac @@ -21,10 +21,12 @@ _getconf() if [[ $prev == PATH_MAX ]]; then # TODO more path vars, better handling _filedir elif [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-a -v' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-a -v' -- "$cur") ) else - COMPREPLY=( $( compgen -W \ - '$( "$1" -a 2>/dev/null | awk "{ print \$1 }" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- "$cur") ) fi } && complete -F _getconf getconf + +# ex: filetype=sh diff --git a/completions/getent b/completions/getent index 0658b0bb..9a181f60 100644 --- a/completions/getent +++ b/completions/getent @@ -8,10 +8,10 @@ _getent() local i db for (( i=1; i < cword; i++ )); do case ${words[i]} in - -V|--version|--usage|-'?'|--help) + --version|--usage|--help|-!(-*)[V?]) return ;; - -s|--service) + --service|-!(-*)s) (( i++ )) ;; -*) @@ -26,29 +26,28 @@ _getent() case $db in passwd) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; group) - COMPREPLY=( $( compgen -g -- "$cur" ) ) + COMPREPLY=( $(compgen -g -- "$cur") ) return ;; services) - COMPREPLY=( $( compgen -s -- "$cur" ) ) + COMPREPLY=( $(compgen -s -- "$cur") ) return ;; hosts) - COMPREPLY=( $( compgen -A hostname -- "$cur" ) ) + COMPREPLY=( $(compgen -A hostname -- "$cur") ) return ;; protocols|networks|ahosts|ahostsv4|ahostsv6|rpc) - COMPREPLY=( $( compgen -W "$( $1 $db | \ - awk '{ print $1 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 $db | \ + awk '{ print $1 }')" -- "$cur") ) return ;; aliases|shadow|gshadow) - COMPREPLY=( $( compgen -W "$( $1 $db | cut -d: -f1 )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 $db | cut -d: -f1)" -- "$cur") ) return ;; ethers|netgroup) @@ -65,12 +64,12 @@ _getent() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace elif [[ -z $db ]]; then - COMPREPLY=( $( compgen -W 'passwd group hosts services protocols + COMPREPLY=( $(compgen -W 'passwd group hosts services protocols networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc - shadow gshadow' -- "$cur" ) ) + shadow gshadow' -- "$cur") ) fi } && complete -F _getent getent diff --git a/completions/gkrellm b/completions/gkrellm index 52d2a651..9eb76bcb 100644 --- a/completions/gkrellm +++ b/completions/gkrellm @@ -32,7 +32,7 @@ _gkrellm() ;; esac - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _gkrellm gkrellm gkrellm2 diff --git a/completions/gm b/completions/gm index 88c233c6..4ea4f3e9 100644 --- a/completions/gm +++ b/completions/gm @@ -2,8 +2,8 @@ _gm_commands() { - COMPREPLY+=( $( compgen -W '$( "$1" help | - awk "/^ +[^ ]+ +- / { print \$1 }" )' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '$("$1" help | + awk "/^ +[^ ]+ +- / { print \$1 }")' -- "$cur") ) } _gm() diff --git a/completions/gnatmake b/completions/gnatmake index 4cd24d2e..383bb9b4 100644 --- a/completions/gnatmake +++ b/completions/gnatmake @@ -8,14 +8,14 @@ _gnatmake() if [[ "$cur" == -* ]]; then # relevant (and less relevant ;-) )options completion - COMPREPLY=( $( compgen -W '-a -c -f -i -j -k -m -M -n -o -q -s -v -z + COMPREPLY=( $(compgen -W '-a -c -f -i -j -k -m -M -n -o -q -s -v -z -aL -A -aO -aI -I -I- -L -nostdinc -nostdlib -cargs -bargs -largs -fstack-check -fno-inline -g -O1 -O0 -O2 -O3 -gnata -gnatA -gnatb -gnatc -gnatd -gnatD -gnate -gnatE -gnatf -gnatF -gnatg -gnatG -gnath -gnati -gnatk -gnatl -gnatL -gnatm -gnatn -gnato -gnatO -gnatp -gnatP -gnatq -gnatR -gnats -gnatt -gnatT -gnatu -gnatU -gnatv -gnatws -gnatwe -gnatwl -gnatwu -gnatW -gnatx -gnatX -gnaty - -gnatz -gnatZ -gnat83' -- "$cur" ) ) + -gnatz -gnatZ -gnat83' -- "$cur") ) else # source file completion _filedir '@(adb|ads)' diff --git a/completions/gnokii b/completions/gnokii index 95ccaeae..ff43c3d1 100644 --- a/completions/gnokii +++ b/completions/gnokii @@ -3,7 +3,7 @@ _gnokii_memory_type() { # TODO: reduce the number of choices - COMPREPLY=( $( compgen -W "IN OU SM ME MT" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "IN OU SM ME MT" -- "$cur") ) } _gnokii() @@ -24,15 +24,15 @@ _gnokii() [[ -f $config_file ]] && break done [[ ! -f $config_file ]] && return - COMPREPLY=( $( compgen -W \ - "$( command sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + "$(command sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file)" \ + -- "$cur") ) return ;; --help) - COMPREPLY=( $( compgen -W 'all monitor sms mms phonebook calendar + COMPREPLY=( $(compgen -W 'all monitor sms mms phonebook calendar todo dial profile settings wap logo ringtone security file - other' -- "$cur" ) ) + other' -- "$cur") ) return ;; --version|--shell|ping) @@ -41,15 +41,15 @@ _gnokii() # MONITOR --monitor) - COMPREPLY=( $( compgen -W 'delay once' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'delay once' -- "$cur") ) return ;; --getdisplaystatus|--displayoutput) return ;; --netmonitor) - COMPREPLY=( $( compgen -W 'reset off field devel next nr' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'reset off field devel next nr' \ + -- "$cur") ) return ;; @@ -59,8 +59,8 @@ _gnokii() return ;; --savesms) - COMPREPLY=( $( compgen -W '--sender --smsc --smscno --folder - --location --sent --read --deliver --datetime' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--sender --smsc --smscno --folder + --location --sent --read --deliver --datetime' -- "$cur") ) return ;; --memory-type|--memory|--getsms|--deletesms|--getmms|--deletemms|\ @@ -82,8 +82,8 @@ _gnokii() return ;; --writephonebook) - COMPREPLY=( $( compgen -W '--overwrite --find-free --memory-type - --location --vcard --ldif' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--overwrite --find-free --memory-type + --location --vcard --ldif' -- "$cur") ) return ;; --writecalendarnote|--writetodo) @@ -97,7 +97,7 @@ _gnokii() return ;; --divert) - COMPREPLY=( $( compgen -W '--op' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--op' -- "$cur") ) return ;; @@ -112,7 +112,7 @@ _gnokii() # SETTINGS --reset) - COMPREPLY=( $( compgen -W 'soft hard' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'soft hard' -- "$cur") ) return ;; --setdatetime|--setalarm) @@ -131,12 +131,12 @@ _gnokii() # LOGOS --sendlogo) - COMPREPLY=( $( compgen -W 'caller op picture' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'caller op picture' -- "$cur") ) return ;; --setlogo|--getlogo) - COMPREPLY=( $( compgen -W 'op startup caller dealer text' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'op startup caller dealer text' \ + -- "$cur") ) return ;; --viewlogo) @@ -145,7 +145,7 @@ _gnokii() ;; --entersecuritycode) - COMPREPLY=( $( compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur") ) return ;; @@ -166,16 +166,16 @@ _gnokii() return ;; --gettodo|--getcalendarnote) - COMPREPLY=( $( compgen -W '{1..9} end --vCal' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..9} end --vCal' -- "$cur") ) return ;; --deletecalendarnote) - COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..9} end' -- "$cur") ) return ;; --divert) - COMPREPLY=( $( compgen -W 'register enable query disable - erasure' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'register enable query disable + erasure' -- "$cur") ) return ;; esac @@ -186,20 +186,20 @@ _gnokii() tprev=${words[cword-3]} case $tprev in --deletesms|--deletemms) - COMPREPLY=( $( compgen -W 'end' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'end' -- "$cur") ) return ;; --getphonebook|--writetodo|--writecalendarnote) - COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..9} end' -- "$cur") ) return ;; --gettodo|--getcalendarnote) [[ ${words[cword-1]} == end ]] && \ - COMPREPLY=( $( compgen -W '--vCal' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--vCal' -- "$cur") ) return ;; --divert) - COMPREPLY=( $( compgen -W '--type' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--type' -- "$cur") ) return esac fi @@ -209,26 +209,26 @@ _gnokii() fprev=${words[cword-4]} case $fprev in --getphonebook) - COMPREPLY=( $( compgen -W '--raw --vcard --ldif' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--raw --vcard --ldif' -- "$cur") ) return ;; --divert) - COMPREPLY=( $( compgen -W 'all busy noans outofreach notavail' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'all busy noans outofreach notavail' \ + -- "$cur") ) return esac fi # safer to use LANG=C - local all_cmd="$( LANG=C _parse_help $1 "--help all" )" + local all_cmd="$(LANG=C _parse_help $1 "--help all")" # these 2 below are allowed in combination with others - local main_cmd=$( command grep -v -- '--config\|--phone' <<<"$all_cmd" ) + local main_cmd=$(command grep -v -- '--config\|--phone' <<<"$all_cmd") # don't provide main command completions if one is # already on the command line - [[ $COMP_LINE =~ $( tr ' ' '\b|'<<<$main_cmd ) ]] && return + [[ $COMP_LINE =~ $(tr ' ' '\b|'<<<$main_cmd) ]] && return - COMPREPLY=( $( compgen -W "$all_cmd" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$all_cmd" -- "$cur") ) } && complete -F _gnokii gnokii diff --git a/completions/gnome-mplayer b/completions/gnome-mplayer index 9a250419..fa4361df 100644 --- a/completions/gnome-mplayer +++ b/completions/gnome-mplayer @@ -10,7 +10,7 @@ _gnome_mplayer() return ;; --showcontrols|--showsubtitles|--autostart) - COMPREPLY=( $( compgen -w '0 1' -- "$cur" ) ) + COMPREPLY=( $(compgen -w '0 1' -- "$cur") ) return ;; --subtitle) @@ -18,7 +18,7 @@ _gnome_mplayer() return ;; --tvdriver) - COMPREPLY=( $( compgen -W 'v4l v4l2' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'v4l v4l2' -- "$cur") ) return ;; esac @@ -26,8 +26,7 @@ _gnome_mplayer() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/gnome-screenshot b/completions/gnome-screenshot new file mode 100644 index 00000000..d0270c38 --- /dev/null +++ b/completions/gnome-screenshot @@ -0,0 +1,31 @@ +# gnome-screenshot(1) completion -*- shell-script -*- + +_gnome_screenshot() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--help-*|--version|--delay|--display|-!(-*)[hd]) + return + ;; + --border-effect|-!(-*)e) + COMPREPLY=( $(compgen -W 'shadow border vintage none' -- "$cur") ) + return + ;; + --file|-!(-*)f) + _filedir '@(jp?(e)|pn)g' + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + fi +} && +complete -F _gnome_screenshot gnome-screenshot + +# ex: filetype=sh diff --git a/completions/gpasswd b/completions/gpasswd index ada12b8d..8f27cfec 100644 --- a/completions/gpasswd +++ b/completions/gpasswd @@ -6,19 +6,19 @@ _gpasswd() _init_completion || return case $prev in - -a|--add|-d|--delete|-A|--administrators|-M|--members) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + --add|--delete|--administrators|--members|-!(-*)[adAM]) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then # TODO: only -A and -M can be combined - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -g -- "$cur" ) ) + COMPREPLY=( $(compgen -g -- "$cur") ) } && complete -F _gpasswd gpasswd diff --git a/completions/gpg b/completions/gpg index 3fee3df3..cb00fa66 100644 --- a/completions/gpg +++ b/completions/gpg @@ -6,31 +6,31 @@ _gpg() _init_completion || return case $prev in - -s|--sign|--clearsign|--decrypt-files|--load-extension) + --sign|--clearsign|--decrypt-files|--load-extension|-!(-*)s) _filedir return ;; --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key) # return list of public keys - COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | command sed -ne \ + COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ - 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) ) + 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur") ) return ;; - -r|--recipient) - COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | command sed -ne \ - 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ) ) + --recipient|-!(-*)r) + COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ + 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur") ) if [[ -e ~/.gnupg/gpg.conf ]]; then - COMPREPLY+=( $( compgen -W "$( command sed -ne \ + COMPREPLY+=( $(compgen -W "$(command sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ - ~/.gnupg/gpg.conf )" -- "$cur" ) ) + ~/.gnupg/gpg.conf)" -- "$cur") ) fi return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$($1 --dump-options)' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$($1 --dump-options)' -- "$cur") ) fi } && complete -F _gpg -o default gpg diff --git a/completions/gpg2 b/completions/gpg2 index 66630590..45014922 100644 --- a/completions/gpg2 +++ b/completions/gpg2 @@ -10,31 +10,31 @@ _gpg2() _filedir -d return ;; - -s|--sign|--clearsign|--options|--decrypt) + --sign|--clearsign|--options|--decrypt|-!(-*)s) _filedir return ;; --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key) # return list of public keys - COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | command sed -ne \ + COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ - 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) ) + 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur") ) return ;; - -r|--recipient) - COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | \ - command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ) ) + --recipient|-!(-*)r) + COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | \ + command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur") ) if [[ -e ~/.gnupg/gpg.conf ]]; then - COMPREPLY+=( $( compgen -W "$( command sed -ne \ + COMPREPLY+=( $(compgen -W "$(command sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ - ~/.gnupg/gpg.conf)" -- "$cur" ) ) + ~/.gnupg/gpg.conf)" -- "$cur") ) fi return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$($1 --dump-options)' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$($1 --dump-options)' -- "$cur") ) fi } && complete -F _gpg2 -o default gpg2 diff --git a/completions/gpgv b/completions/gpgv new file mode 100644 index 00000000..a3221afc --- /dev/null +++ b/completions/gpgv @@ -0,0 +1,46 @@ +# gpgv(1) completion -*- shell-script -*- + +_gpgv() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--version|--weak-digest|--*-fd|-!(-*)[?h]*) + return + ;; + --keyring) + _filedir "@(gpg|kbx)" + return + ;; + --homedir) + _filedir -d + return + ;; + esac + + local args + _count_args "" "--@(weak-digest|*-fd|keyring|homedir)" + + if [[ $cur == -* && $args -eq 1 ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + if [[ $args -gt 1 ]]; then + if [[ ${COMP_LINE,,} == *.@(asc|sig|sign)\ * ]]; then + # Detached signature, only complete one arbitrary file arg and - + if [[ $args -eq 2 ]]; then + COMPREPLY=( $(compgen -W '-' -- "$cur") ) + _filedir + fi + else + _filedir gpg + fi + else + _filedir "@(asc|gpg|sig|sign)" + fi +} && +complete -F _gpgv gpgv gpgv2 + +# ex: filetype=sh diff --git a/completions/gphoto2 b/completions/gphoto2 index 94bf0634..89277a95 100644 --- a/completions/gphoto2 +++ b/completions/gphoto2 @@ -23,20 +23,20 @@ _gphoto2() return ;; --port) - COMPREPLY=( $(compgen -W "$( $1 --list-ports 2>/dev/null | \ - awk 'NR>3 { print $1 }' )" -- "$cur") ) + COMPREPLY=( $(compgen -W "$($1 --list-ports 2>/dev/null | \ + awk 'NR>3 { print $1 }')" -- "$cur") ) __ltrim_colon_completions "$cur" return ;; --camera) local IFS=$'\n' - COMPREPLY=( $(compgen -W "$( $1 --list-cameras 2>/dev/null | \ - awk -F'"' 'NR>2 { print $2 }' )" -- "$cur") ) + COMPREPLY=( $(compgen -W "$($1 --list-cameras 2>/dev/null | \ + awk -F'"' 'NR>2 { print $2 }')" -- "$cur") ) return ;; --get-config|--set-config|--set-config-index|--set-config-value) - COMPREPLY=( $(compgen -W "$( $1 --list-config 2>/dev/null \ - )" -- "$cur") ) + COMPREPLY=( $(compgen -W "$($1 --list-config 2>/dev/null \ + )" -- "$cur") ) return ;; esac @@ -44,7 +44,7 @@ _gphoto2() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi diff --git a/completions/gprof b/completions/gprof index b9692bad..d1f4a4a3 100644 --- a/completions/gprof +++ b/completions/gprof @@ -17,8 +17,8 @@ _gprof() ;; -O*) cur=${cur:2} - COMPREPLY=( $( compgen -P -O -W 'auto bsd 4.4bsd magic prof' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -P -O -W 'auto bsd 4.4bsd magic prof' \ + -- "$cur") ) return ;; esac @@ -36,8 +36,7 @@ _gprof() return ;; --file-format) - COMPREPLY=( $( compgen -W 'auto bsd 4.4bsd magic prof' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'auto bsd 4.4bsd magic prof' -- "$cur") ) return ;; esac @@ -45,7 +44,7 @@ _gprof() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '--annotated-source --brief --exec-counts + COMPREPLY=( $(compgen -W '--annotated-source --brief --exec-counts --file-info --directory-path --no-annotated-source --print-path --flat-profile --no-flat-profile --graph --no-graph --table-length= --separate-files --no-exec-counts --function-ordering @@ -53,7 +52,7 @@ _gprof() --no-demangle --no-static --static-call-graph --ignore-non-functions -k --line --min-count= --time= --no-time= --external-symbol-table= --display-unused-functions --debug --help - --file-format= --sum --version' -- "$cur" ) ) + --file-format= --sum --version' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/groupadd b/completions/groupadd index c5a74b7a..013feaa4 100644 --- a/completions/groupadd +++ b/completions/groupadd @@ -9,7 +9,7 @@ _groupadd() # with -g/--gid case $prev in - -g|--gid|-K|--key|-p|--password) + --gid|--key|--password|-!(-*)[gKp]) return ;; esac @@ -17,7 +17,7 @@ _groupadd() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/groupdel b/completions/groupdel index 867b1741..fcdd14c1 100644 --- a/completions/groupdel +++ b/completions/groupdel @@ -16,11 +16,11 @@ _groupdel() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -g -- "$cur" ) ) + COMPREPLY=( $(compgen -g -- "$cur") ) } && complete -F _groupdel groupdel diff --git a/completions/groupmems b/completions/groupmems index 3bb5d820..6e599a24 100644 --- a/completions/groupmems +++ b/completions/groupmems @@ -7,11 +7,11 @@ _groupmems() case $prev in -a|--add|-d|--delete) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; -g|--group) - COMPREPLY=( $( compgen -g -- "$cur" ) ) + COMPREPLY=( $(compgen -g -- "$cur") ) return ;; -R|--root) @@ -20,7 +20,7 @@ _groupmems() ;; esac - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _groupmems groupmems diff --git a/completions/groupmod b/completions/groupmod index 51e23b5c..2ac62ea3 100644 --- a/completions/groupmod +++ b/completions/groupmod @@ -9,7 +9,7 @@ _groupmod() # with -g/--gid case $prev in - -g|--gid|-h|--help|-n|--new-name|-p|--password) + --gid|--help|--new-name|--password|-!(-*)[ghnp]) return ;; esac @@ -17,12 +17,12 @@ _groupmod() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi - COMPREPLY=( $( compgen -g -- "$cur" ) ) + COMPREPLY=( $(compgen -g -- "$cur") ) } && complete -F _groupmod groupmod diff --git a/completions/growisofs b/completions/growisofs index 04b29a55..a0c6de3f 100644 --- a/completions/growisofs +++ b/completions/growisofs @@ -15,7 +15,7 @@ _growisofs() return ;; /?(r)dev/*) - if [[ $cur == =* ]] ; then + if [[ $cur == =* ]]; then # e.g. /dev/dvd=foo.iso, /dev/dvdrw=/dev/zero cur="${cur#=}" _filedir @@ -26,9 +26,9 @@ _growisofs() if [[ "$cur" == -* ]]; then # TODO: mkisofs options - COMPREPLY=( $( compgen -W '-dvd-compat -overburn -speed= -Z -M' \ - -- "$cur" ) ) - [[ ${COMPREPLY[@]} == *= ]] && compopt -o nospace + COMPREPLY=( $(compgen -W '-dvd-compat -overburn -speed= -Z -M' \ + -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/grpck b/completions/grpck index 18a53920..9f5eac7b 100644 --- a/completions/grpck +++ b/completions/grpck @@ -5,8 +5,16 @@ _grpck() local cur prev words cword _init_completion || return + case $prev in + --root|-!(-*)R) + _filedir + return + ;; + esac + if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) return fi diff --git a/completions/gzip b/completions/gzip index 59818d92..d3bce282 100644 --- a/completions/gzip +++ b/completions/gzip @@ -6,18 +6,17 @@ _gzip() _init_completion || return case $prev in - -b|--blocksize|-S|--suffix|-h|--help|-V|--version) + --blocksize|--suffix|--help|--version|-!(-*)[bShV]) return ;; - -p|--processes) - COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) + --processes|-!(-*)p) + COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) {-1..-9}' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -36,8 +35,8 @@ _gzip() _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") \ + $(compgen -d -- "$cur") ) } && complete -F _gzip gzip pigz diff --git a/completions/hcitool b/completions/hcitool index 38d66427..ccc64f18 100644 --- a/completions/hcitool +++ b/completions/hcitool @@ -3,28 +3,28 @@ _bluetooth_addresses() { if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then - COMPREPLY+=( $( compgen -W "$( hcitool scan | \ - awk '/^\t/{print $1}' )" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W "$(hcitool scan | \ + awk '/^\t/{print $1}')" -- "$cur") ) fi } _bluetooth_devices() { - COMPREPLY+=( $( compgen -W "$( hcitool dev | \ - awk '/^\t/{print $1}' )" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W "$(hcitool dev | \ + awk '/^\t/{print $1}')" -- "$cur") ) } _bluetooth_services() { - COMPREPLY=( $( compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG SAP NAP + COMPREPLY=( $(compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG SAP NAP GN PANU HCRP HID CIP A2SRC A2SNK AVRCT AVRTG UDIUE UDITE SYNCML' \ - -- "$cur" ) ) + -- "$cur") ) } _bluetooth_packet_types() { - COMPREPLY=( $( compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \ + -- "$cur") ) } _hcitool() @@ -38,7 +38,7 @@ _hcitool() return ;; --role) - COMPREPLY=( $( compgen -W 'm s' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'm s' -- "$cur") ) return ;; --pkt-type) @@ -53,11 +53,11 @@ _hcitool() _get_first_arg if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'dev inq scan name info spinq epinq cmd + COMPREPLY=( $(compgen -W 'dev inq scan name info spinq epinq cmd con cc dc sr cpt rssi lq tpl afh lst auth enc key clkoff - clock' -- "$cur" ) ) + clock' -- "$cur") ) fi else local args @@ -70,7 +70,7 @@ _hcitool() ;; cc) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--role --pkt-type' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--role --pkt-type' -- "$cur") ) else _count_args if [[ $args -eq 2 ]]; then @@ -83,7 +83,7 @@ _hcitool() if [[ $args -eq 2 ]]; then _bluetooth_addresses else - COMPREPLY=( $( compgen -W 'master slave' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'master slave' -- "$cur") ) fi ;; cpt) @@ -99,7 +99,7 @@ _hcitool() if [[ $args -eq 2 ]]; then _bluetooth_addresses else - COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) fi ;; esac @@ -125,39 +125,39 @@ _sdptool() _get_first_arg if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'search browse records add del get - setattr setseq' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'search browse records add del get + setattr setseq' -- "$cur") ) fi else case $arg in search) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--bdaddr --tree --raw --xml' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--bdaddr --tree --raw --xml' \ + -- "$cur") ) else _bluetooth_services fi ;; browse|records) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--tree --raw --xml' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--tree --raw --xml' -- "$cur") ) else _bluetooth_addresses fi ;; add) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--handle --channel' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--handle --channel' -- "$cur") ) else _bluetooth_services fi ;; get) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--bdaddr --tree --raw --xml' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--bdaddr --tree --raw --xml' \ + -- "$cur") ) fi ;; esac @@ -181,7 +181,7 @@ _l2ping() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _bluetooth_addresses fi @@ -209,10 +209,10 @@ _rfcomm() _get_first_arg if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'show connect listen watch bind - release' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'show connect listen watch bind + release' -- "$cur") ) fi else local args @@ -249,10 +249,10 @@ _ciptool() _get_first_arg if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'show search connect release loopback' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'show search connect release loopback' \ + -- "$cur") ) fi else local args @@ -281,14 +281,14 @@ _dfutool() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else local args _count_args case $args in 1) - COMPREPLY=( $( compgen -W 'verify modify upgrade archive' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'verify modify upgrade archive' \ + -- "$cur") ) ;; 2) _filedir @@ -307,13 +307,13 @@ _hciconfig() _get_first_arg if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --all' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --all' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'up down reset rstat auth noauth encrypt + COMPREPLY=( $(compgen -W 'up down reset rstat auth noauth encrypt noencrypt secmgr nosecmgr piscan noscan iscan pscan ptype name class voice iac inqmode inqdata inqtype inqparams pageparms pageto afhmode aclmtu scomtu putkey delkey commands features - version revision lm' -- "$cur" ) ) + version revision lm' -- "$cur") ) fi else local args @@ -327,8 +327,8 @@ _hciconfig() lm) _count_args if [[ $args -eq 2 ]]; then - COMPREPLY=( $( compgen -W 'MASTER SLAVE NONE ACCEPT' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'MASTER SLAVE NONE ACCEPT' \ + -- "$cur") ) fi ;; ptype) @@ -348,26 +348,26 @@ _hciattach() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-n -p -t -b -s -l' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-n -p -t -b -s -l' -- "$cur") ) else local args _count_args case $args in 1) - COMPREPLY=( $( printf '%s\n' /dev/tty* ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]} - ${COMPREPLY[@]#/dev/}' -- "$cur" ) ) + COMPREPLY=( $(printf '%s\n' /dev/tty*) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]} + ${COMPREPLY[@]#/dev/}' -- "$cur") ) ;; 2) - COMPREPLY=( $( compgen -W 'any ericsson digi xircom csr bboxes - swave bcsp 0x0105 0x080a 0x0160 0x0002' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'any ericsson digi xircom csr bboxes + swave bcsp 0x0105 0x080a 0x0160 0x0002' -- "$cur") ) ;; 3) - COMPREPLY=( $( compgen -W '9600 19200 38400 57600 115200 230400 - 460800 921600' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '9600 19200 38400 57600 115200 230400 + 460800 921600' -- "$cur") ) ;; 4) - COMPREPLY=( $( compgen -W 'flow noflow' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'flow noflow' -- "$cur") ) ;; 5) _bluetooth_addresses diff --git a/completions/hddtemp b/completions/hddtemp index 123b74a1..b7487cc9 100644 --- a/completions/hddtemp +++ b/completions/hddtemp @@ -6,19 +6,19 @@ _hddtemp() _init_completion -s || return case $prev in - -f|--file) + --file|-!(-*)f) _filedir db return ;; - -l|--listen) + --listen|-!(-*)l) _ip_addresses return ;; - -u|--unit) - COMPREPLY=( $( compgen -W 'C F' -- "$cur" ) ) + --unit|-!(-*)u) + COMPREPLY=( $(compgen -W 'C F' -- "$cur") ) return ;; - -p|--port|-s|--separator|-S|--syslog|-v|--version|-h|-\?|--help) + --port|--separator|--syslog|--version|--help|-!(-*)[psSvh?]) return ;; esac @@ -26,7 +26,7 @@ _hddtemp() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") --help' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else cur=${cur:=/dev/} diff --git a/completions/hid2hci b/completions/hid2hci index 9221c4d0..9e3305d0 100644 --- a/completions/hid2hci +++ b/completions/hid2hci @@ -6,8 +6,8 @@ _hid2hci() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --quiet -0 --tohci -1 --tohid' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --quiet -0 --tohci -1 --tohid' \ + -- "$cur") ) fi } && complete -F _hid2hci hid2hci diff --git a/completions/hostname b/completions/hostname index 48f4222f..68f9b4ed 100644 --- a/completions/hostname +++ b/completions/hostname @@ -6,17 +6,17 @@ _hostname() _init_completion || return case $prev in - -h|--help|-V|--version) + --help|--version|-!(-*)[hV]) return ;; - -F|--file) + --file|-!(-*)F) _filedir return ;; esac [[ $cur == -* ]] && \ - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _hostname hostname diff --git a/completions/hping2 b/completions/hping2 index 6344ed73..78d35b05 100644 --- a/completions/hping2 +++ b/completions/hping2 @@ -6,26 +6,26 @@ _hping2() _init_completion || return case $prev in - -I|--interface) + --interface|-!(-*)I) _available_interfaces return ;; - -a|--spoof) + --spoof|-!(-*)a) _known_hosts_real -- "$cur" return ;; - -o|--tos) - COMPREPLY=( $( compgen -W '02 04 08 10' ) ) + --tos|-!(-*)o) + COMPREPLY=( $(compgen -W '02 04 08 10') ) return ;; - -E|--file) + --file|-!(-*)E) _filedir return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else _known_hosts_real -- "$cur" fi diff --git a/completions/htop b/completions/htop index 13c06b15..3f1680b5 100644 --- a/completions/htop +++ b/completions/htop @@ -6,15 +6,15 @@ _htop() _init_completion -s || return case "$prev" in - -s|--sort-key) - COMPREPLY=( $( compgen -W '$( "$1" -s help )' -- "$cur" ) ) + --sort-key|-!(-*)s) + COMPREPLY=( $(compgen -W '$("$1" -s help)' -- "$cur") ) return ;; - -u|--user) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + --user|-!(-*)u) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; - -d|--delay) + --delay|-!(-*)d) # argument required but no completions available return ;; @@ -23,7 +23,7 @@ _htop() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/htpasswd b/completions/htpasswd index bf3acb22..827e6dcc 100644 --- a/completions/htpasswd +++ b/completions/htpasswd @@ -16,7 +16,7 @@ _htpasswd() if [[ $o -eq 0 || $o -eq $cword ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi # Password file (first non-option argument) @@ -24,8 +24,8 @@ _htpasswd() elif [[ $o -eq $cword-1 ]]; then # Username (second non-option argument) - COMPREPLY=( $( compgen -W \ - '$( cut -d: -f1 "${words[o]}" 2>/dev/null )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(cut -d: -f1 "${words[o]}" 2>/dev/null)' -- "$cur") ) fi } && complete -F _htpasswd htpasswd diff --git a/completions/hunspell b/completions/hunspell new file mode 100644 index 00000000..627f3e4b --- /dev/null +++ b/completions/hunspell @@ -0,0 +1,42 @@ +# hunspell(1) completion -*- shell-script -*- + +_hunspell() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--version|-vv|-[hPv]) + return + ;; + -d) + local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob + local -a dicts=( /usr/share/hunspell/*.dic + /usr/local/share/hunspell/*.dic ) + dicts=( "${dicts[@]##*/}" ) + dicts=( "${dicts[@]%.dic}" ) + $reset + IFS=$'\n' + COMPREPLY=( $(compgen -W '${dicts[@]}' -- "$cur") ) + return + ;; + -i) + _xfunc iconv _iconv_charsets + return + ;; + -p) + _filedir + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + _filedir +} && +complete -F _hunspell hunspell + +# ex: filetype=sh diff --git a/completions/iconv b/completions/iconv index 50edb4c5..2fb1c92d 100644 --- a/completions/iconv +++ b/completions/iconv @@ -1,21 +1,26 @@ # iconv(1) completion -*- shell-script -*- +_iconv_charsets() +{ + COMPREPLY+=( $(compgen -W '$(${1:-iconv} -l | \ + command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur") ) +} + _iconv() { local cur prev words cword split _init_completion -s || return case $prev in - -'?'|--help|--usage|-V|--version|--unicode-subst|--byte-subst|\ - --widechar-subst) + --help|--usage|--version|--unicode-subst|--byte-subst|\ + --widechar-subst|-!(-*)[?V]) return ;; - -f|--from-code|-t|--to-code) - COMPREPLY=( $( compgen -W '$( iconv -l | \ - command sed -e "s@/*\$@@" -e "s/[,()]//g" )' -- "$cur" ) ) + --from-code|--to-code|-!(-*)[ft]) + _iconv_charsets $1 return ;; - -o|--output) + --output|-!(-*)o) _filedir return ;; @@ -24,7 +29,7 @@ _iconv() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/id b/completions/id index 137a5f7e..3f3087cb 100644 --- a/completions/id +++ b/completions/id @@ -6,11 +6,11 @@ _id() _init_completion || return if [[ "$cur" == -* ]]; then - local opts=$( _parse_help "$1" ) + local opts=$(_parse_help "$1") [[ $opts ]] || opts="-G -g -u" # POSIX fallback - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) else - COMPREPLY=( $( compgen -u "$cur" ) ) + COMPREPLY=( $(compgen -u "$cur") ) fi } && complete -F _id id diff --git a/completions/idn b/completions/idn index 12f4bdd1..39d13021 100644 --- a/completions/idn +++ b/completions/idn @@ -6,18 +6,18 @@ _idn() _init_completion -s || return case $prev in - -h|--help|-V|--version) + --help|--version|-!(-*)[hV]) return ;; - -p|--profile) - COMPREPLY=( $( compgen -W 'Nameprep iSCSI Nodeprep Resourceprep - trace SASLprep' -- "$cur" ) ) + --profile|-!(-*)p) + COMPREPLY=( $(compgen -W 'Nameprep iSCSI Nodeprep Resourceprep + trace SASLprep' -- "$cur") ) return ;; esac if ! $split && [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/ifstat b/completions/ifstat new file mode 100644 index 00000000..9fac3d30 --- /dev/null +++ b/completions/ifstat @@ -0,0 +1,62 @@ +# bash completion for ifstat(1) -*- shell-script -*- + +_ifstat() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--version|--scan|--interval|-!(-*)[hvV]) + return + ;; + -!(-*)i) + # TODO comma separated + _available_interfaces -a + return + ;; + -!(-*)d) + # iproute2: no completion (scan delay) + # traditional: parse driver + if ! { "$1" --help 2>&1 || :; } | \ + command grep -q -- '-d.*--scan'; then + COMPREPLY=( $(compgen -W '$("$1" -v | command \ + sed -e "s/[,.]//g" -ne "s/^.*drivers://p")' -- "$cur") ) + fi + return + ;; + --noupdate|-!(-*)s) + # iproute2: pass through (skip history update) + # traditional: hostnames (snmp) + if ! { "$1" --help 2>&1 || :; } | \ + command grep -q -- '-s.*--noupdate'; then + _known_hosts_real -- "$cur" + return + fi + ;; + -!(-*)t) + # iproute2: no completion (interval) + # traditional: pass through (add timestamp) + ! { "$1" --help 2>&1 || :; } | \ + command grep -q -- '-t.*--interval' || return + ;; + --extended|-!(-*)x) + # iproute2: parse xstat types + COMPREPLY=( $(compgen -W '$("$1" -x nonexistent-xstat 2>&1 | + awk "found { print \$1 } /supported xstats:/ { found=1 }")' \ + -- "$cur") ) + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi +} && +complete -F _ifstat ifstat + +# ex: filetype=sh diff --git a/completions/iftop b/completions/iftop index 831e327b..6320316d 100644 --- a/completions/iftop +++ b/completions/iftop @@ -19,7 +19,7 @@ _iftop() ;; esac - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) } && complete -F _iftop iftop diff --git a/completions/ifup b/completions/ifup index 42cb8f80..db8de8e0 100644 --- a/completions/ifup +++ b/completions/ifup @@ -7,12 +7,33 @@ _ifupdown() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then + case $prev in + --help|--version|--allow|--exclude|--option|-!(-*)[hVXo]) + return + ;; + --interfaces|-!(-*)i) + _filedir + return + ;; + --state-dir) + _filedir -d + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + local args + _count_args "" "@(--allow|-i|--interfaces|--state-dir|-X|--exclude|-o)" + + if [[ $args -eq 1 ]]; then _configured_interfaces COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) fi - } && -complete -F _ifupdown ifup ifdown ifstatus +complete -F _ifupdown ifup ifdown ifquery ifstatus # ex: filetype=sh diff --git a/completions/info b/completions/info index ba2cf4cb..87179ac8 100644 --- a/completions/info +++ b/completions/info @@ -12,10 +12,10 @@ _info() fi case $prev in - -k|--apropos|--index-search|-n|--node|-h|--help|-v|--version) + --apropos|--index-search|--node|--help|--version|-!(-*)[knhv]) return ;; - -d) + -!(-*)d) if [[ ${1##*/} == info ]]; then _filedir -d return @@ -25,7 +25,7 @@ _info() _filedir -d return ;; - --dribble|-f|--file|-o|--output|--restore|-r|--raw-filename|--rcfile) + --dribble|--file|--output|--restore|--raw-filename|--rcfile|-!(-*)[for]) _filedir return ;; @@ -34,7 +34,7 @@ _info() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -57,7 +57,7 @@ _info() fi # redirect stderr for when path doesn't exist - COMPREPLY=( $( eval command ls "$infopath" 2>/dev/null ) ) + COMPREPLY=( $(eval command ls "$infopath" 2>/dev/null) ) # weed out directory path names and paths to info pages COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) # weed out info dir file @@ -66,7 +66,7 @@ _info() done # strip suffix from info pages COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}") ) } && complete -F _info info pinfo diff --git a/completions/inject b/completions/inject index 20ea9b7f..8becf274 100644 --- a/completions/inject +++ b/completions/inject @@ -15,7 +15,7 @@ _inject() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--listname --queue --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--listname --queue --help' -- "$cur") ) else _filedir fi diff --git a/completions/inotifywait b/completions/inotifywait new file mode 100644 index 00000000..637d4742 --- /dev/null +++ b/completions/inotifywait @@ -0,0 +1,47 @@ +# bash completion for inotifywait(1) and inotifywatch(1) -*- shell-script -*- + +_inotifywait_events() +{ + # Expecting line with "Events:", followed by ones starting with one + # tab. Word following the tab is event name, others are line + # wrapped explanations. + COMPREPLY+=( $(compgen -W "$($1 --help 2>/dev/null | \ + command sed -e '/^Events:/,/^[^'$'\t'']/!d' \ + -ne 's/^'$'\t''\([^ '$'\t'']\{1,\}\)[ '$'\t''].*/\1/p')" \ + -- "$cur") ) +} + +_inotifywait() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--exclude|--excludei|--format|--timefmt|--timeout|-!(-*)[ht]) + return + ;; + --fromfile|--outfile|-!(-*)o) + _filedir + return + ;; + --event|-!(-*)e) + _inotifywait_events "$1" + return + ;; + --ascending|--descending) + COMPREPLY=( $(compgen -W 'total' -- "$cur") ) + _inotifywait_events "$1" + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + _filedir +} && +complete -F _inotifywait inotifywait inotifywatch + +# ex: filetype=sh diff --git a/completions/insmod b/completions/insmod index ec81c93e..36c29dc4 100644 --- a/completions/insmod +++ b/completions/insmod @@ -9,8 +9,8 @@ _insmod() if [[ $cword -eq 1 ]]; then _filedir '@(?(k)o?(.gz))' else # do module parameter completion - COMPREPLY=( $( compgen -W "$( PATH="$PATH:/sbin" modinfo \ - -p ${words[1]} 2>/dev/null | cut -d: -f1 )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(PATH="$PATH:/sbin" modinfo \ + -p ${words[1]} 2>/dev/null | cut -d: -f1)" -- "$cur") ) fi } && complete -F _insmod insmod insmod.static diff --git a/completions/installpkg b/completions/installpkg index f002f775..3ebf1dfc 100644 --- a/completions/installpkg +++ b/completions/installpkg @@ -11,7 +11,7 @@ _installpkg() return ;; --priority) - COMPREPLY=( $( compgen -W 'ADD REC OPT SKP' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'ADD REC OPT SKP' -- "$cur") ) return ;; --tagfile) @@ -21,8 +21,8 @@ _installpkg() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--warn --md5sum --root --infobox --terse - --menu --ask --priority --tagfile' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--warn --md5sum --root --infobox --terse + --menu --ask --priority --tagfile' -- "$cur") ) return fi diff --git a/completions/interdiff b/completions/interdiff index cf71002e..e7923751 100644 --- a/completions/interdiff +++ b/completions/interdiff @@ -6,7 +6,7 @@ _interdiff() _init_completion -s || return case $prev in - -U|--unified|-p|--strip-match|-d|--drop-context) + --unified|--strip-match|--drop-context|-!(-*)[Upd]) return ;; esac @@ -14,13 +14,13 @@ _interdiff() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi local exts='@(?(d)patch|dif?(f))' word - for word in ${words[@]}; do + for word in "${words[@]}"; do if [[ $word == -@(z|-decompress) ]]; then exts+='?(.@(gz|bz2))' break diff --git a/completions/invoke-rc.d b/completions/invoke-rc.d index 777f6ace..e4b2afc9 100644 --- a/completions/invoke-rc.d +++ b/completions/invoke-rc.d @@ -12,22 +12,22 @@ _invoke_rc_d() [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d \ || sysvdir=/etc/init.d - services=( $( printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob) ) ) + services=( $(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)) ) services=( ${services[@]#$sysvdir/} ) options=( --help --quiet --force --try-anyway --disclose-deny --query \ --no-fallback ) if [[ ($cword -eq 1) || ("$prev" == --* ) ]]; then - valid_options=( $( \ - tr " " "\n" <<<"${words[@]} ${options[@]}" \ - | command sed -ne "/$( command sed "s/ /\\\\|/g" <<<"${options[@]}" )/p" \ + valid_options=( $(\ + tr " " "\n" <<<"${words[*]} ${options[*]}" \ + | command sed -ne "/$(command sed "s/ /\\\\|/g" <<<"${options[*]}")/p" \ | sort | uniq -u \ ) ) - COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${valid_options[@]} ${services[@]}' -- "$cur") ) elif [[ -x $sysvdir/$prev ]]; then - COMPREPLY=( $( compgen -W '`command sed -e "y/|/ /" \ + COMPREPLY=( $(compgen -W '`command sed -e "y/|/ /" \ -ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \ - $sysvdir/$prev`' -- "$cur" ) ) + $sysvdir/$prev`' -- "$cur") ) else COMPREPLY=() fi diff --git a/completions/ip b/completions/ip index 00dd839d..372d2d85 100644 --- a/completions/ip +++ b/completions/ip @@ -2,9 +2,9 @@ _iproute2_etc() { - COMPREPLY+=( $( compgen -W \ - "$( awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null )" \ - -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + "$(awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null)" \ + -- "$cur") ) } _ip() @@ -17,7 +17,7 @@ _ip() return ;; -f|-family) - COMPREPLY=( $( compgen -W 'inet inet6 ipx dnet link' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'inet inet6 ipx dnet link' -- "$cur") ) return ;; -b|-batch) @@ -25,7 +25,7 @@ _ip() return ;; -force) - COMPREPLY=( $( compgen -W '-batch' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-batch' -- "$cur") ) return ;; esac @@ -45,15 +45,15 @@ _ip() local c="-Version -statistics -details -resolve -family -oneline -timestamp -batch -rcvbuf" [[ $cword -eq 1 ]] && c+=" -force" - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$c" -- "$cur") ) return ;; *) - COMPREPLY=( $( compgen -W "help $( ip help 2>&1 | command sed -e \ + COMPREPLY=( $(compgen -W "help $(ip help 2>&1 | command sed -e \ '/OBJECT := /,/}/!d' -e \ 's/.*{//' -e \ 's/}.*//' -e \ - 's/|//g' )" -- "$cur" ) ) + 's/|//g')" -- "$cur") ) return ;; esac @@ -73,12 +73,12 @@ _ip() _available_interfaces ;; 2) - COMPREPLY=( $( compgen -W 'type' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'type' -- "$cur") ) ;; 3) [[ $prev == type ]] && \ - COMPREPLY=( $( compgen -W 'vlan veth vcan dummy - ifb macvlan can' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'vlan veth vcan dummy + ifb macvlan can' -- "$cur") ) ;; esac ;; @@ -89,8 +89,7 @@ _ip() case $prev in arp|dynamic|multicast|allmulticast|promisc|\ trailers) - COMPREPLY=( $( compgen -W 'on off' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) ;; txqueuelen|name|address|broadcast|mtu|netns|alias) ;; @@ -99,7 +98,7 @@ _ip() promisc trailers txqueuelen name address broadcast mtu netns alias" [[ $prev != @(up|down) ]] && c+=" up down" - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$c" -- "$cur") ) ;; esac fi @@ -107,7 +106,7 @@ _ip() show) if [[ $cword -eq $subcword+1 ]]; then _available_interfaces - COMPREPLY+=( $( compgen -W 'dev group up' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W 'dev group up' -- "$cur") ) elif [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == group ]]; then @@ -116,8 +115,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help add delete set show' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help add delete set show' \ + -- "$cur") ) ;; esac ;; @@ -145,9 +144,9 @@ _ip() show|flush) if [[ $cword -eq $subcword+1 ]]; then _available_interfaces - COMPREPLY+=( $( compgen -W 'dev scope to label dynamic + COMPREPLY+=( $(compgen -W 'dev scope to label dynamic permanent tentative deprecated dadfailed temporary - primary secondary up' -- "$cur" ) ) + primary secondary up' -- "$cur") ) elif [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == scope ]]; then @@ -156,8 +155,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help add change replace del - show flush' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help add change replace del + show flush' -- "$cur") ) ;; esac ;; @@ -173,8 +172,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help list add del flush' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help list add del flush' \ + -- "$cur") ) ;; esac ;; @@ -196,8 +195,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help list flush get add del - change append replace monitor' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help list flush get add del + change append replace monitor' -- "$cur") ) ;; esac ;; @@ -211,8 +210,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help list add del flush' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help list add del flush' \ + -- "$cur") ) ;; esac ;; @@ -227,8 +226,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help add del change replace - show flush' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help add del change replace + show flush' -- "$cur") ) ;; esac ;; @@ -243,8 +242,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help change show' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help change show' \ + -- "$cur") ) ;; esac ;; @@ -258,8 +257,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help add change del show prl - 6rd' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help add change del show prl + 6rd' -- "$cur") ) ;; esac ;; @@ -273,14 +272,14 @@ _ip() if [[ $cword -eq $subcword+1 || $prev == dev ]]; then _available_interfaces [[ $prev != dev ]] && \ - COMPREPLY=( $( compgen -W '${COMPREPLY[@]} dev' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]} dev' \ + -- "$cur") ) fi ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help add del show' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help add del show' \ + -- "$cur") ) ;; esac ;; @@ -292,7 +291,7 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help show' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help show' -- "$cur") ) ;; esac ;; @@ -302,7 +301,7 @@ _ip() all) ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'help all' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help all' -- "$cur") ) ;; esac ;; @@ -314,8 +313,8 @@ _ip() ;; *) [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $( compgen -W 'state policy monitor' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'state policy monitor' \ + -- "$cur") ) ;; esac ;; diff --git a/completions/iperf b/completions/iperf index 712ab946..43f9bcaf 100644 --- a/completions/iperf +++ b/completions/iperf @@ -3,37 +3,43 @@ _iperf() { local cur prev words cword split - _init_completion -s || return + _init_completion -s -n : || return case $prev in - -h|--help|-v|--version|-i|--interval|-l|--len|-p|--port|-w|--window|\ - -M|--mss|-b|--bandwidth|-n|--num|-t|--time|-L|--listenport|-P|\ - --parallel|-T|--ttl|-Z|--linux-congestion) + --help|--version|--interval|--len|--port|--window|--mss|--bandwidth|\ + --num|--time|--listenport|--parallel|--ttl|--linux-congestion|--omit|\ + --congestion|--bytes|--blockcount|--cport|--set-mss|--flowlabel|\ + --title|--tos|--affinity|-!(-*)[hvilpwMbntLPTZCkOSA]) return ;; - -f|--format) - COMPREPLY=( $( compgen -W 'k m K M' -- "$cur" ) ) + --format|-!(-*)f) + COMPREPLY=( $(compgen -W 'k m g K M G' -- "$cur") ) return ;; - -o|--output|-F|--fileinput) + --output|--fileinput|-!(-*)[oF]) _filedir return ;; - -B|--bind) + --bind|-!(-*)B) _available_interfaces -a - _ip_addresses + _ip_addresses -a + __ltrim_colon_completions "$cur" return ;; - -c|--client) + --client|-!(-*)c) _known_hosts_real -- "$cur" return ;; - -x|--reportexclude) - COMPREPLY=( $( compgen -W 'C D M S V' -- "$cur" ) ) + --reportexclude|-!(-*)x) + COMPREPLY=( $(compgen -W 'C D M S V' -- "$cur") ) return ;; - -y|--reportstyle) - COMPREPLY=( $( compgen -W 'C' -- "$cur" ) ) + --reportstyle|-!(-*)y) + COMPREPLY=( $(compgen -W 'C' -- "$cur") ) + return + ;; + --logfile) + _filedir log return ;; esac @@ -42,22 +48,22 @@ _iperf() # Filter mode specific options local i filter=cat - for i in ${words[@]}; do + for i in "${words[@]}"; do case $i in -s|--server) - filter='command sed -e /^Client.specific/,/^$/d' + filter='command sed -e /^Client.specific/,/^\(Server.specific.*\)\?$/d' ;; -c|--client) - filter='command sed -e /^Server.specific/,/^$/d' + filter='command sed -e /^Server.specific/,/^\(Client.specific.*\)\?$/d' ;; esac done [[ $filter != cat ]] && filter+=' -e /--client/d -e /--server/d' - COMPREPLY=( $( compgen -W \ - '$( "$1" --help 2>&1 | $filter | _parse_help - )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && -complete -F _iperf iperf +complete -F _iperf iperf iperf3 # ex: filetype=sh diff --git a/completions/ipmitool b/completions/ipmitool index 5a660733..f6307cfa 100644 --- a/completions/ipmitool +++ b/completions/ipmitool @@ -2,8 +2,8 @@ _ipmitool_singleline_help() { - COMPREPLY=( $( compgen -W "$( $1 $2 2>&1 | \ - command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 $2 2>&1 | \ + command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')" -- "$cur") ) } _ipmitool() @@ -12,53 +12,53 @@ _ipmitool() _init_completion || return case $prev in - -h|-V|-p|-U|-e|-k|-y|-P|-m|-b|-t|-B|-T|-l) + -*[hVpUekyPmbtBTl]) return ;; - -d) - COMPREPLY=( $( compgen -W "$( \ + -*d) + COMPREPLY=( $(compgen -W "$(\ command ls -d /dev/ipmi* /dev/ipmi/* /dev/ipmidev/* \ - 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p' )" \ - -- "$cur" ) ) + 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p')" \ + -- "$cur") ) return ;; - -I) - COMPREPLY=( $( compgen -W "$( $1 -h 2>&1 | \ + -*I) + COMPREPLY=( $(compgen -W "$($1 -h 2>&1 | \ command sed -e '/^Interfaces:/,/^[[:space:]]*$/!d' \ - -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p' )" \ - -- "$cur" ) ) + -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p')" \ + -- "$cur") ) return ;; - -H) + -*H) _known_hosts_real -- "$cur" return ;; - -f|-S|-O) + -*[fSO]) _filedir return ;; - -C) - COMPREPLY=( $( compgen -W '{0..14}' -- "$cur" ) ) + -*C) + COMPREPLY=( $(compgen -W '{0..14}' -- "$cur") ) return ;; - -L) - COMPREPLY=( $( compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \ - -- "$cur" ) ) + -*L) + COMPREPLY=( $(compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \ + -- "$cur") ) return ;; - -A) - COMPREPLY=( $( compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur" ) ) + -*A) + COMPREPLY=( $(compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur") ) return ;; - -o) - COMPREPLY=( $( compgen -W "$( $1 -o list 2>&1 | \ - awk '/^[ \t]+/ { print $1 }' ) list" -- "$cur" ) ) + -*o) + COMPREPLY=( $(compgen -W "$($1 -o list 2>&1 | \ + awk '/^[ \t]+/ { print $1 }') list" -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h)' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) return fi @@ -70,13 +70,13 @@ _ipmitool() local i c cmd subcmd for (( i=1; i < ${#words[@]}-1; i++ )); do [[ -n $cmd ]] && subcmd=${words[i]} && break - for c in ${cmds[@]}; do + for c in "${cmds[@]}"; do [[ ${words[i]} == $c ]] && cmd=$c && break done done if [[ -z $cmd ]]; then - COMPREPLY=( $( compgen -W '${cmds[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${cmds[@]}' -- "$cur") ) return fi @@ -101,15 +101,15 @@ _ipmitool() ;; alert) [[ $prev == alert ]] && \ - COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'print set' -- "$cur") ) ;; stats) [[ $prev == stats ]] && \ - COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'print set' -- "$cur") ) ;; *) - COMPREPLY=( $( compgen -W 'print set alert stats' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'print set alert stats' \ + -- "$cur") ) ;; esac ;; @@ -119,8 +119,8 @@ _ipmitool() get|info|type|list|entity) ;; elist) - COMPREPLY=( $( compgen -W 'all full compact event mclog fru - generic' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'all full compact event mclog fru + generic' -- "$cur") ) ;; dump) _filedir @@ -128,8 +128,7 @@ _ipmitool() fill) case $prev in fill) - COMPREPLY=( $( compgen -W 'sensors file' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'sensors file' -- "$cur") ) ;; file) _filedir @@ -137,8 +136,8 @@ _ipmitool() esac ;; *) - COMPREPLY=( $( compgen -W 'get info type list elist entity - dump fill' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'get info type list elist entity + dump fill' -- "$cur") ) ;; esac ;; @@ -148,7 +147,7 @@ _ipmitool() list|get|thresh) ;; *) - COMPREPLY=( $( compgen -W 'list get thresh' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'list get thresh' -- "$cur") ) ;; esac ;; @@ -162,11 +161,11 @@ _ipmitool() ;; time) [[ $prev == time ]] && \ - COMPREPLY=( $( compgen -W 'get set' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'get set' -- "$cur") ) ;; *) - COMPREPLY=( $( compgen -W 'info clear list elist delete add - get save writeraw readraw time' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'info clear list elist delete add + get save writeraw readraw time' -- "$cur") ) ;; esac ;; @@ -177,20 +176,19 @@ _ipmitool() ;; set) [[ $prev == set ]] && \ - COMPREPLY=( $( compgen -W 'name password' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'name password' -- "$cur") ) ;; *) - COMPREPLY=( $( compgen -W 'summary list set disable enable - priv test' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'summary list set disable enable + priv test' -- "$cur") ) ;; esac ;; set) [[ $prev == set ]] && \ - COMPREPLY=( $( compgen -W 'hostname username password privlvl - authtype localaddr targetaddr port csv verbose' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'hostname username password privlvl + authtype localaddr targetaddr port csv verbose' -- "$cur") ) ;; esac diff --git a/completions/ipsec b/completions/ipsec index 357d5055..00e6b7ea 100644 --- a/completions/ipsec +++ b/completions/ipsec @@ -10,7 +10,7 @@ _ipsec_connections() if [[ $keyword == [#]* ]]; then continue; fi [[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=( "$name" ) done - COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) } _ipsec_freeswan() @@ -19,28 +19,27 @@ _ipsec_freeswan() _init_completion || return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual + COMPREPLY=( $(compgen -W 'auto barf eroute klipsdebug look manual pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp - tncfg whack' -- "$cur" ) ) + tncfg whack' -- "$cur") ) return fi case ${words[1]} in auto) - COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete + COMPREPLY=( $(compgen -W '--asynchronous --up --add --delete --replace --down --route --unroute --ready --status - --rereadsecrets' -- "$cur" ) ) + --rereadsecrets' -- "$cur") ) ;; manual) - COMPREPLY=( $( compgen -W '--up --down --route --unroute --union' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--up --down --route --unroute --union' \ + -- "$cur") ) ;; ranbits) - COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--quick --continuous --bytes' -- "$cur") ) ;; setup) - COMPREPLY=( $( compgen -W '--start --stop --restart' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--start --stop --restart' -- "$cur") ) ;; *) ;; @@ -53,7 +52,7 @@ _ipsec_strongswan() _init_completion || return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'down irdumm leases listaacerts listacerts + COMPREPLY=( $(compgen -W 'down irdumm leases listaacerts listacerts listalgs listall listcacerts listcainfos listcards listcerts listcrls listgroups listocsp listocspcerts listpubkeys openac pki pluto pool purgecerts purgecrls purgeike purgeocsp ready reload @@ -61,25 +60,25 @@ _ipsec_strongswan() rereadgroups rereadocspcerts rereadsecrets restart route scdecrypt scencrypt scepclient secrets start starter status statusall stop stroke unroute uci up update version whack --confdir --copyright - --directory --help --version --versioncode' -- "$cur" ) ) + --directory --help --version --versioncode' -- "$cur") ) return fi case ${words[1]} in down|route|status|statusall|unroute|up) - local confdir=$( ipsec --confdir ) - _ipsec_connections < "$confdir/ipsec.conf" + local confdir=$(ipsec --confdir) + _ipsec_connections <"$confdir/ipsec.conf" ;; list*) - COMPREPLY=( $( compgen -W '--utc' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--utc' -- "$cur") ) ;; restart|start) - COMPREPLY=( $( compgen -W '--attach-gdb --auto-update --debug - --debug-all --debug-more --nofork' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--attach-gdb --auto-update --debug + --debug-all --debug-more --nofork' -- "$cur") ) ;; pki) - COMPREPLY=( $( compgen -W '--gen --issue --keyid --print --pub - --req --self --signcrl --verify' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--gen --issue --keyid --print --pub + --req --self --signcrl --verify' -- "$cur") ) ;; pool) ;; @@ -91,7 +90,7 @@ _ipsec_strongswan() esac } -case "$( ipsec --version 2>/dev/null )" in +case "$(ipsec --version 2>/dev/null)" in *strongSwan*) complete -F _ipsec_strongswan ipsec ;; diff --git a/completions/iptables b/completions/iptables index 5ef81037..69072613 100644 --- a/completions/iptables +++ b/completions/iptables @@ -7,44 +7,39 @@ _iptables() local table chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p' - if [[ ${words[@]} == *-t\ *filter* ]]; then - table="-t filter" - elif [[ ${words[@]} == *-t\ *nat* ]]; then - table="-t nat" - elif [[ ${words[@]} == *-t\ *mangle* ]]; then - table="-t mangle" - fi + [[ "${words[*]}" =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] \ + && table="-t ${BASH_REMATCH[2]}" case $prev in -*[AIDRPFXLZ]) - COMPREPLY=( $( compgen -W '`"$1" $table -nL 2>/dev/null | \ - command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '`"$1" $table -nL 2>/dev/null | \ + command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur") ) ;; -*t) - COMPREPLY=( $( compgen -W 'nat filter mangle' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'nat filter mangle' -- "$cur") ) ;; -j) if [[ "$table" == "-t filter" || -z "$table" ]]; then - COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT + COMPREPLY=( $(compgen -W 'ACCEPT DROP LOG ULOG REJECT `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ - "$cur" ) ) + "$cur") ) elif [[ $table == "-t nat" ]]; then - COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT + COMPREPLY=( $(compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT DNAT MASQUERADE `"$1" $table -nL 2>/dev/null | \ command sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ - -- "$cur" ) ) + -- "$cur") ) elif [[ $table == "-t mangle" ]]; then - COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS + COMPREPLY=( $(compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ - "$cur" ) ) + "$cur") ) fi ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( "$1" --help 2>&1 | - command sed -e "s/^\[\!\]//" | _parse_help - )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$("$1" --help 2>&1 | + command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi ;; diff --git a/completions/ipv6calc b/completions/ipv6calc index 0dacff94..f001999a 100644 --- a/completions/ipv6calc +++ b/completions/ipv6calc @@ -6,14 +6,14 @@ _ipv6calc() _init_completion -s || return case "$prev" in - -d|--debug) + --debug|-!(-*)d) return ;; - -I|--in|-O|--out|-A|--action) + --in|--out|--action|-!(-*)[IOA]) # With ipv6calc < 0.73.0, -m does nothing here, so use sed instead. - COMPREPLY=( $( compgen -W "$( $1 "$prev" -h 2>&1 | \ - command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p' )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 "$prev" -h 2>&1 | \ + command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p')" \ + -- "$cur") ) return ;; --db-geoip|--db-ip2location-ipv4|--db-ip2location-ipv6) @@ -28,13 +28,13 @@ _ipv6calc() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --debug --quiet --in --out --action + COMPREPLY=( $(compgen -W '--help --debug --quiet --in --out --action --examples --showinfo --show_types --machine_readable --db-geoip --db-geoip-default --db-ip2location-ipv4 --db-ip2location-ipv6 --lowercase --uppercase --printprefix --printsuffix --maskprefix --masksuffix --printstart --printend --printcompressed --printuncompressed --printfulluncompressed --printmirrored' \ - -- "$cur" ) ) + -- "$cur") ) fi } && diff --git a/completions/iscsiadm b/completions/iscsiadm index e5218d75..1fa30db6 100644 --- a/completions/iscsiadm +++ b/completions/iscsiadm @@ -6,21 +6,21 @@ _iscsiadm() _init_completion -s || return case $prev in - -m|--mode) - COMPREPLY=( $( compgen -W 'discovery node session iface fw host' \ - -- "$cur" ) ) + --mode|-!(-*)m) + COMPREPLY=( $(compgen -W 'discovery node session iface fw host' \ + -- "$cur") ) return ;; - -o|--op) - COMPREPLY=( $( compgen -W 'new delete update show' -- "$cur" ) ) + --op|-!(-*)o) + COMPREPLY=( $(compgen -W 'new delete update show' -- "$cur") ) return ;; - -t|--type) - COMPREPLY=( $( compgen -W 'sendtargets st slp isns fw' -- "$cur" ) ) + --type|-!(-*)t) + COMPREPLY=( $(compgen -W 'sendtargets st slp isns fw' -- "$cur") ) return ;; - -L|-U|--loginall|--logoutall) - COMPREPLY=( $( compgen -W 'all manual automatic' -- "$cur" ) ) + --loginall|--logoutall|-!(-*)[LU]) + COMPREPLY=( $(compgen -W 'all manual automatic' -- "$cur") ) return ;; esac @@ -28,7 +28,7 @@ _iscsiadm() $split && return local options - if [[ $cword -gt 1 ]] ; then + if [[ $cword -gt 1 ]]; then case ${words[2]} in discovery) @@ -59,7 +59,7 @@ _iscsiadm() options='--mode' fi - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) } && complete -F _iscsiadm iscsiadm diff --git a/completions/isort b/completions/isort new file mode 100644 index 00000000..e4a028be --- /dev/null +++ b/completions/isort @@ -0,0 +1,41 @@ +# isort completion -*- shell-script -*- + +_isort() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--add-import|--builtin|--future|--from-first|-ff|\ + --force-grid-wrap|-fgw|--indent|--lines|--lines-after-imports|-lai|\ + --lines-between-types|-lbt|--line-ending|-le|--no-lines-before|-nlb|\ + --dont-skip|-ns|--thirdparty|--project|--remove-import|--skip|\ + --skip-glob|-sg|--settings-path|-sp|--top|--virtual-env|--line-width|\ + --wrap-length|-wl|-[habfiloprstw]) + return + ;; + --jobs|-j) + COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + return + ;; + --multi-line|-m) + COMPREPLY=( $(compgen -W '{0..5}' -- "$cur") ) + return + ;; + --section-default|-sd) + COMPREPLY=( $(compgen -W 'FUTURE STDLIB THIRDPARTY FIRSTPARTY + LOCALFOLDER' -- "$cur") ) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + _filedir '@(py|pyi)' +} && +complete -F _isort isort + +# ex: filetype=sh diff --git a/completions/isql b/completions/isql index 862a9304..4bd24c41 100644 --- a/completions/isql +++ b/completions/isql @@ -7,7 +7,7 @@ _isql() _init_completion || return [[ -f $ODBCINI ]] \ - && COMPREPLY=( $( command grep "\[$cur" "$ODBCINI" | tr -d \[\] ) ) + && COMPREPLY=( $(command grep "\[$cur" "$ODBCINI" | tr -d \[\]) ) } && complete -F _isql isql diff --git a/completions/iwconfig b/completions/iwconfig index 114081dd..762ec2ea 100644 --- a/completions/iwconfig +++ b/completions/iwconfig @@ -7,81 +7,81 @@ _iwconfig() case $prev in mode) - COMPREPLY=( $( compgen -W 'managed ad-hoc master repeater secondary - monitor' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'managed ad-hoc master repeater secondary + monitor' -- "$cur") ) return ;; essid) - COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off any' -- "$cur") ) if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then - COMPREPLY+=( $( compgen -W \ - "$( iwlist ${words[1]} scan | \ - awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + "$(iwlist ${words[1]} scan | \ + awk -F'\"' '/ESSID/ {print $2}')" -- "$cur") ) fi return ;; nwid) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; channel) - COMPREPLY=( $( compgen -W "$( iwlist ${words[1]} channel | \ - awk '/^[ \t]*Channel/ {print $2}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(iwlist ${words[1]} channel | \ + awk '/^[ \t]*Channel/ {print $2}')" -- "$cur") ) return ;; freq) - COMPREPLY=( $( compgen -W "$( iwlist ${words[1]} channel | \ - awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(iwlist ${words[1]} channel | \ + awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur") ) return ;; ap) - COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off any' -- "$cur") ) if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then - COMPREPLY+=( $( compgen -W \ - "$( iwlist ${words[1]} scan | \ - awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + "$(iwlist ${words[1]} scan | \ + awk -F ': ' '/Address/ {print $2}')" -- "$cur") ) fi return ;; rate) - COMPREPLY=( $( compgen -W 'auto fixed' -- "$cur" ) ) - COMPREPLY+=( $( compgen -W \ - "$( iwlist ${words[1]} rate | \ - awk '/^[ \t]*[0-9]/ {print $1"M"}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'auto fixed' -- "$cur") ) + COMPREPLY+=( $(compgen -W \ + "$(iwlist ${words[1]} rate | \ + awk '/^[ \t]*[0-9]/ {print $1"M"}')" -- "$cur") ) return ;; rts|frag) - COMPREPLY=( $( compgen -W 'auto fixed off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'auto fixed off' -- "$cur") ) return ;; key|enc) - COMPREPLY=( $( compgen -W 'off on open restricted' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'off on open restricted' -- "$cur") ) return ;; power) - COMPREPLY=( $( compgen -W 'period timeout off on' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'period timeout off on' -- "$cur") ) return ;; txpower) - COMPREPLY=( $( compgen -W 'off on auto' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'off on auto' -- "$cur") ) return ;; retry) - COMPREPLY=( $( compgen -W 'limit lifetime' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'limit lifetime' -- "$cur") ) return ;; esac if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) else _available_interfaces -w fi else - COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode ap - nick rate rts frag enc key power txpower commit' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'essid nwid mode freq channel sens mode ap + nick rate rts frag enc key power txpower commit' -- "$cur") ) fi } && diff --git a/completions/iwlist b/completions/iwlist index b27dbe8b..65e0b2fb 100644 --- a/completions/iwlist +++ b/completions/iwlist @@ -7,14 +7,14 @@ _iwlist() if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) else _available_interfaces -w fi else - COMPREPLY=( $( compgen -W 'scan scanning freq frequency channel rate + COMPREPLY=( $(compgen -W 'scan scanning freq frequency channel rate bit bitrate key enc encryption power txpower retry ap accesspoint - peers event' -- "$cur" ) ) + peers event' -- "$cur") ) fi } && complete -F _iwlist iwlist diff --git a/completions/iwpriv b/completions/iwpriv index c7f8209e..83673b4e 100644 --- a/completions/iwpriv +++ b/completions/iwpriv @@ -7,23 +7,23 @@ _iwpriv() case $prev in roam) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; port) - COMPREPLY=( $( compgen -W 'ad-hoc managed' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'ad-hoc managed' -- "$cur") ) return ;; esac if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) else _available_interfaces -w fi else - COMPREPLY=( $( compgen -W '--all roam port' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--all roam port' -- "$cur") ) fi } && complete -F _iwpriv iwpriv diff --git a/completions/iwspy b/completions/iwspy index 1cf3a283..e4805116 100644 --- a/completions/iwspy +++ b/completions/iwspy @@ -7,12 +7,12 @@ _iwspy() if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) else _available_interfaces -w fi else - COMPREPLY=( $( compgen -W 'setthr getthr off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'setthr getthr off' -- "$cur") ) fi } && complete -F _iwspy iwspy diff --git a/completions/jar b/completions/jar index b7de930f..c839aa85 100644 --- a/completions/jar +++ b/completions/jar @@ -6,7 +6,7 @@ _jar() _init_completion || return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'c t x u' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'c t x u' -- "$cur") ) return fi diff --git a/completions/jarsigner b/completions/jarsigner index 2441bd1a..171865b2 100644 --- a/completions/jarsigner +++ b/completions/jarsigner @@ -7,7 +7,7 @@ _jarsigner() case $prev in -keystore) - COMPREPLY=( $( compgen -W 'NONE' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'NONE' -- "$cur") ) _filedir '@(jks|ks|p12|pfx)' return ;; @@ -21,7 +21,7 @@ _jarsigner() return ;; -storetype) - COMPREPLY=( $( compgen -W 'JKS PKCS11 PKCS12' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'JKS PKCS11 PKCS12' -- "$cur") ) return ;; -signedjar) @@ -34,20 +34,20 @@ _jarsigner() local i jar=false for (( i=0; i < ${#words[@]}-1; i++ )) ; do if [[ "${words[i]}" == *.jar && \ - "${words[i-1]}" != -signedjar ]] ; then + "${words[i-1]}" != -signedjar ]]; then jar=true break fi done if ! $jar ; then - if [[ "$cur" == -* ]] ; then + if [[ "$cur" == -* ]]; then # Documented as "should not be used": -internalsf, -sectionsonly - COMPREPLY=( $( compgen -W '-keystore -storepass -storetype + COMPREPLY=( $(compgen -W '-keystore -storepass -storetype -keypass -sigfile -signedjar -digestalg -sigalg -verify -verbose -certs -tsa -tsacert -altsigner -altsignerpath -protected -providerName -providerClass -providerArg' \ - -- "$cur" ) ) + -- "$cur") ) fi _filedir jar fi diff --git a/completions/java b/completions/java index e8d81fb4..3ca65869 100644 --- a/completions/java +++ b/completions/java @@ -62,18 +62,18 @@ _java_classes() for i in ${classpath//:/ }; do if [[ "$i" == *.@(jar|zip) && -r $i ]]; then if type zipinfo &>/dev/null; then - COMPREPLY+=( $( zipinfo -1 "$i" "$cur*" 2>/dev/null | \ - command grep '^[^$]*\.class$' ) ) + COMPREPLY+=( $(zipinfo -1 "$i" "$cur*" 2>/dev/null | \ + command grep '^[^$]*\.class$') ) else - COMPREPLY+=( $( jar tf "$i" "$cur" | \ - command grep '^[^$]*\.class$' ) ) + COMPREPLY+=( $(jar tf "$i" "$cur" | \ + command grep '^[^$]*\.class$') ) fi elif [[ -d $i ]]; then COMPREPLY+=( - $( compgen -d -- "$i/$cur" | command sed -e "s|^$i/\(.*\)|\1.|" ) - $( compgen -f -X '!*.class' -- "$i/$cur" | \ - command sed -e '/\$/d' -e "s|^$i/||" ) + $(compgen -d -- "$i/$cur" | command sed -e "s|^$i/\(.*\)|\1.|") + $(compgen -f -X '!*.class' -- "$i/$cur" | \ + command sed -e '/\$/d' -e "s|^$i/||") ) [[ $COMPREPLY == *.class ]] || compopt -o nospace @@ -102,12 +102,12 @@ _java_packages() # parse each sourcepath element for packages for i in ${sourcepath//:/ }; do if [[ -d $i ]]; then - COMPREPLY+=( $( command ls -F -d $i/$cur* 2>/dev/null | \ - command sed -e 's|^'$i'/||' ) ) + COMPREPLY+=( $(command ls -F -d $i/$cur* 2>/dev/null | \ + command sed -e 's|^'$i'/||') ) fi done # keep only packages - COMPREPLY=( $( tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$" ) ) + COMPREPLY=( $(tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$") ) # remove packages extension COMPREPLY=( ${COMPREPLY[@]%/} ) # convert path syntax to package syntax @@ -142,7 +142,7 @@ _java() case $cur in # standard option completions -verbose:*) - COMPREPLY=( $( compgen -W 'class gc jni' -- "${cur#*:}" ) ) + COMPREPLY=( $(compgen -W 'class gc jni' -- "${cur#*:}") ) return ;; -javaagent:*) @@ -166,17 +166,17 @@ _java() return ;; -Xcheck:*) - COMPREPLY=( $( compgen -W 'jni' -- "${cur#*:}" ) ) + COMPREPLY=( $(compgen -W 'jni' -- "${cur#*:}") ) return ;; -Xgc:*) - COMPREPLY=( $( compgen -W 'singlecon gencon singlepar genpar' \ - -- "${cur#*:}" ) ) + COMPREPLY=( $(compgen -W 'singlecon gencon singlepar genpar' \ + -- "${cur#*:}") ) return ;; -Xgcprio:*) - COMPREPLY=( $( compgen -W 'throughput pausetime deterministic' \ - -- "${cur#*:}" ) ) + COMPREPLY=( $(compgen -W 'throughput pausetime deterministic' \ + -- "${cur#*:}") ) return ;; -Xloggc:*|-Xverboselog:*) @@ -185,16 +185,16 @@ _java() return ;; -Xshare:*) - COMPREPLY=( $( compgen -W 'auto off on' -- "${cur#*:}" ) ) + COMPREPLY=( $(compgen -W 'auto off on' -- "${cur#*:}") ) return ;; -Xverbose:*) - COMPREPLY=( $( compgen -W 'memory load jni cpuinfo codegen opt - gcpause gcreport' -- "${cur#*:}" ) ) + COMPREPLY=( $(compgen -W 'memory load jni cpuinfo codegen opt + gcpause gcreport' -- "${cur#*:}") ) return ;; -Xverify:*) - COMPREPLY=( $( compgen -W 'all none remote' -- "${cur#*:}" ) ) + COMPREPLY=( $(compgen -W 'all none remote' -- "${cur#*:}") ) return ;; # the rest that we have no completions for @@ -211,9 +211,9 @@ _java() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) [[ $cur == -X* ]] && \ - COMPREPLY+=( $( compgen -W '$( _parse_help "$1" -X )' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '$(_parse_help "$1" -X)' -- "$cur") ) else if [[ "$prev" == -jar ]]; then # jar file completion @@ -271,7 +271,7 @@ _javadoc() fi if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) else # source files completion _filedir java @@ -304,16 +304,16 @@ _javac() # For some reason there may be -g:none AND -g:{lines,source,vars}; # convert the none case to the curly brace format so it parses like # the others. - local opts=$( "$1" $helpopt 2>&1 | command sed -e 's/-g:none/-g:{none}/' -ne \ - "s/^[[:space:]]*${cur%%:*}:{\([^}]\{1,\}\)}.*/\1/p" ) - COMPREPLY=( $( compgen -W "${opts//,/ }" -- "${cur#*:}" ) ) + local opts=$("$1" $helpopt 2>&1 | command sed -e 's/-g:none/-g:{none}/' -ne \ + "s/^[[:space:]]*${cur%%:*}:{\([^}]\{1,\}\)}.*/\1/p") + COMPREPLY=( $(compgen -W "${opts//,/ }" -- "${cur#*:}") ) return fi if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) [[ $cur == -X* ]] && \ - COMPREPLY+=( $( compgen -W '$( _parse_help "$1" -X )' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '$(_parse_help "$1" -X)' -- "$cur") ) else # source files completion _filedir java diff --git a/completions/javaws b/completions/javaws index 7d6e22c8..c21d3ac4 100644 --- a/completions/javaws +++ b/completions/javaws @@ -22,7 +22,7 @@ _javaws() if [[ $cur == *= ]]; then return elif [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W "$( _parse_help "$1" -help ) " -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(_parse_help "$1" -help) " -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/jpegoptim b/completions/jpegoptim index 754f16a2..044cc753 100644 --- a/completions/jpegoptim +++ b/completions/jpegoptim @@ -6,19 +6,19 @@ _jpegoptim() _init_completion -s || return case $prev in - -h|--help|-V|--version) + --help|--version|-!(-*)[hV]*) return ;; - -d|--dest) + --dest|-!(-*)d) _filedir -d return ;; - -m|--max|-T|--threshold) - COMPREPLY=( $( compgen -W '{0..100}' -- "$cur" ) ) + --max|--threshold|-!(-*)[mT]) + COMPREPLY=( $(compgen -W '{0..100}' -- "$cur") ) return ;; - -S|--size) - COMPREPLY=( $( compgen -W '{1..99}%' -- "$cur" ) ) + --size|-!(-*)S) + COMPREPLY=( $(compgen -W '{1..99}%' -- "$cur") ) return ;; esac @@ -26,7 +26,7 @@ _jpegoptim() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/jps b/completions/jps index e46c9f16..a6a60299 100644 --- a/completions/jps +++ b/completions/jps @@ -14,7 +14,7 @@ _jps() if [[ $cur == -* ]]; then # Not using _parse_usage because output has [-help] which does not # mean -h, -e, -l, -p... - COMPREPLY=( $( compgen -W "-q -m -l -v -V -J -help" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "-q -m -l -v -V -J -help" -- "$cur") ) [[ $COMPREPLY == -J* ]] && compopt -o nospace else _known_hosts_real -- "$cur" diff --git a/completions/jq b/completions/jq new file mode 100644 index 00000000..3fdbfb0c --- /dev/null +++ b/completions/jq @@ -0,0 +1,54 @@ +# jq(1) completion -*- shell-script -*- + +_jq() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--version|--arg|--argjson|--slurpfile|--argfile) + return + ;; + --indent) + COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") ) + return + ;; + --from-file|--run-tests|-!(-*)f) + _filedir + return + ;; + -!(-*)L) + _filedir -d + return + ;; + esac + + (( cword > 2 )) && \ + case ${words[cword-2]} in + --arg|--argjson) + return + ;; + --slurpfile|--argfile) + _filedir json + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + local args + # TODO: DTRT with args taking 2 options + _count_args "" "@(--arg|--arg?(json|file)|--?(slurp|from-)file|--indent|--run-tests|-!(-*)[fL])" + + # 1st arg is filter + [[ $args -eq 1 ]] && return + # 2... are input files + _filedir json + +} && +complete -F _jq jq + +# ex: filetype=sh diff --git a/completions/jshint b/completions/jshint index ea9bbeb5..ee89070a 100644 --- a/completions/jshint +++ b/completions/jshint @@ -14,11 +14,11 @@ _jshint() return ;; --reporter) - COMPREPLY=( $( compgen -W "jslint checkstyle unix" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "jslint checkstyle unix" -- "$cur") ) return ;; --extract) - COMPREPLY=( $( compgen -W "auto always never" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "auto always never" -- "$cur") ) return ;; esac @@ -26,7 +26,7 @@ _jshint() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/json_xs b/completions/json_xs new file mode 100644 index 00000000..98d0ba63 --- /dev/null +++ b/completions/json_xs @@ -0,0 +1,31 @@ +# json_xs completion -*- shell-script -*- + +_json_xs() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -*f) + COMPREPLY=( $(compgen -W 'json cbor storable storable-file bencode + clzf eval yaml string none' -- "$cur") ) + return + ;; + -*t) + COMPREPLY=( $(compgen -W 'json json-utf-8 json-pretty + json-utf-16le json-utf-16be json-utf-32le json-utf-32be + cbor storable storable-file bencode clzf yaml dump dumper + string none' -- "$cur") ) + return + ;; + -*e) + return + ;; + esac + + [[ $cur == -* ]] && + COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -f' -- "$cur") ) +} && +complete -F _json_xs json_xs + +# ex: filetype=sh diff --git a/completions/jsonschema b/completions/jsonschema new file mode 100644 index 00000000..441977e4 --- /dev/null +++ b/completions/jsonschema @@ -0,0 +1,29 @@ +# bash completion for jsonschema -*- shell-script -*- + +_jsonschema() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--error-format|--validator|-[hFV]) + return + ;; + --instance|-i) + _filedir json + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + local args; _count_args "" "-*" + [[ $args -eq 1 ]] || return + _filedir '@(json|schema)' +} && +complete -F _jsonschema jsonschema + +# ex: filetype=sh diff --git a/completions/k3b b/completions/k3b index 2cbcbb1b..b52e6de0 100644 --- a/completions/k3b +++ b/completions/k3b @@ -31,13 +31,13 @@ _k3b() return ;; --ao) - COMPREPLY=( $( compgen -W 'alsa arts' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'alsa arts' -- "$cur") ) return ;; esac - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir diff --git a/completions/kcov b/completions/kcov index 5d067778..8490a969 100644 --- a/completions/kcov +++ b/completions/kcov @@ -11,8 +11,8 @@ _kcov() return ;; --sort-type|-s) - COMPREPLY=( $( compgen -W 'filename percent reverse lines - uncovered' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'filename percent reverse lines + uncovered' -- "$cur") ) return ;; --include-path|--exclude-path) @@ -33,11 +33,11 @@ _kcov() if [[ "$cur" == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" - COMPREPLY=( $( compgen -W "{0..100}" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "{0..100}" -- "$cur") ) [[ ${#COMPREPLY[@]} -eq 1 ]] && \ COMPREPLY=( ${COMPREPLY/#/$prev,} ) else - COMPREPLY=( $( compgen -W "{0..100}" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "{0..100}" -- "$cur") ) [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/%/,} ) compopt -o nospace fi @@ -52,7 +52,7 @@ _kcov() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/kill b/completions/kill index ac179cd9..4cd5f911 100644 --- a/completions/kill +++ b/completions/kill @@ -18,7 +18,7 @@ _kill() if [[ $cword -eq 1 && "$cur" == -* ]]; then # return list of available signals _signals - - COMPREPLY+=( $( compgen -W "-s -l" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W "-s -l" -- "$cur") ) else # return list of available PIDs _pids diff --git a/completions/killall b/completions/killall index 6d1532c3..e1b56ce1 100644 --- a/completions/killall +++ b/completions/killall @@ -8,14 +8,14 @@ _killall() _init_completion -s || return case $prev in - -Z|--context|-o|--older-than|-y|--younger-than|-V|--version) + --context|--older-than|--younger-than|--version|-!(-*)@([Zoy]|V*)) return ;; - -s|--signal) + --signal|-!(-*)s) _signals return ;; - -u|--user) + --user|-!(-*)u) _allowed_users return ;; @@ -24,7 +24,7 @@ _killall() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $cword -eq 1 ]] && _signals - return fi diff --git a/completions/kldload b/completions/kldload index 0442e95e..4817679e 100644 --- a/completions/kldload +++ b/completions/kldload @@ -11,7 +11,7 @@ _kldload() [[ -d $moddir ]] || moddir=/boot/kernel/ compopt -o filenames - COMPREPLY=( $( compgen -f "$moddir$cur" ) ) + COMPREPLY=( $(compgen -f "$moddir$cur") ) COMPREPLY=( ${COMPREPLY[@]#$moddir} ) COMPREPLY=( ${COMPREPLY[@]%.ko} ) diff --git a/completions/kldunload b/completions/kldunload index 52634c1e..e1462677 100644 --- a/completions/kldunload +++ b/completions/kldunload @@ -7,7 +7,7 @@ _kldunload() local cur prev words cword _init_completion || return - COMPREPLY=( $( compgen -W '$(kldstat)' -X 'kernel' -X '!*.ko' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(kldstat)' -X 'kernel' -X '!*.ko' -- "$cur") ) COMPREPLY=( ${COMPREPLY[@]%.ko} ) } && complete -F _kldunload kldunload diff --git a/completions/koji b/completions/koji index 30b8d49a..be43f0a2 100644 --- a/completions/koji +++ b/completions/koji @@ -2,8 +2,8 @@ _koji_search() { - COMPREPLY+=( $( compgen -W \ - '$( "$1" -q search $2 "$cur*" 2>/dev/null )' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + '$("$1" -q search $2 "$cur*" 2>/dev/null)' -- "$cur") ) } _koji_build() @@ -23,14 +23,13 @@ _koji_user() _koji_tag() { - COMPREPLY+=( $( compgen -W '$( "$1" -q list-tags 2>/dev/null )' \ - -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '$("$1" -q list-tags 2>/dev/null)' -- "$cur") ) } _koji_target() { - COMPREPLY+=( $( compgen -W '$( "$1" -q list-targets 2>/dev/null | - awk "{ print \$1 }" )' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '$("$1" -q list-targets 2>/dev/null | + awk "{ print \$1 }")' -- "$cur") ) } _koji() @@ -47,10 +46,10 @@ _koji() done case $prev in - -h|--help|--help-commands) + --help|--help-commands|-!(-*)h*) return ;; - -c|--config|--keytab|-o) + --config|--keytab|-!(-*)[co]) _filedir return ;; @@ -59,8 +58,7 @@ _koji() return ;; --authtype) - COMPREPLY=( $( compgen -W 'noauth ssl password kerberos' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'noauth ssl password kerberos' -- "$cur") ) return ;; --topdir) @@ -70,7 +68,7 @@ _koji() --type) case $command in latest-pkg|list-tagged) - COMPREPLY=( $( compgen -W 'maven' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'maven' -- "$cur") ) ;; esac return @@ -109,8 +107,8 @@ _koji() if [[ $command ]]; then if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W \ - '$( _parse_help "$1" "$command --help" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(_parse_help "$1" "$command --help")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -199,8 +197,8 @@ _koji() search) case $nth in 1) - COMPREPLY=( $( compgen -W 'package build tag target - user host rpm' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'package build tag target + user host rpm' -- "$cur") ) ;; esac ;; @@ -235,11 +233,11 @@ _koji() fi if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace elif [[ ! $command ]]; then - COMPREPLY=( $( compgen -W '$( "$1" --help-commands 2>/dev/null | \ - awk "/^( +|\t)/ { print \$1 }" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$("$1" --help-commands 2>/dev/null | \ + awk "/^( +|\t)/ { print \$1 }")' -- "$cur") ) fi } && complete -F _koji koji arm-koji ppc-koji s390-koji sparc-koji diff --git a/completions/ktutil b/completions/ktutil index 2baa1c6c..572a2ec4 100644 --- a/completions/ktutil +++ b/completions/ktutil @@ -2,21 +2,21 @@ _heimdal_principals() { - COMPREPLY=( $( compgen -W "$( kadmin -l dump 2>/dev/null | \ - awk '{print $1}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(kadmin -l dump 2>/dev/null | \ + awk '{print $1}')" -- "$cur") ) } _heimdal_realms() { - COMPREPLY=( $( compgen -W "( kadmin -l dump 2>/dev/null | \ - awk '{print $1}' | awk -F@ '{print $2}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(kadmin -l dump 2>/dev/null | \ + awk '{print $1}' | awk -F@ '{print $2}')" -- "$cur") ) } _heimdal_encodings() { - COMPREPLY=( $( compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 + COMPREPLY=( $(compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 des3-cbc-sha1 arcfour-hmac-md5 aes128-cts-hmac-sha1-96 - aes256-cts-hmac-sha1-96' -- "$cur" ) ) + aes256-cts-hmac-sha1-96' -- "$cur") ) } _ktutil() @@ -57,7 +57,7 @@ _ktutil() for (( i=1; i < cword; i++ )); do case ${words[i]} in -k|--keytab) - i=$(($i+1)) + (( i++ )) ;; -*) ;; @@ -97,7 +97,7 @@ _ktutil() options='-k --keytab -v --verbose --version -v --help' ;; esac - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) else case $command in copy) @@ -110,7 +110,7 @@ _ktutil() _heimdal_principals ;; *) - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) ;; esac fi diff --git a/completions/larch b/completions/larch index 5b7ebd14..0773c2da 100644 --- a/completions/larch +++ b/completions/larch @@ -7,7 +7,7 @@ _larch() _init_completion || return if [[ $cword -eq 1 || "$prev" == -* ]]; then - COMPREPLY=( $( compgen -W ' \ + COMPREPLY=( $(compgen -W ' \ my-id my-default-archive register-archive whereis-archive archives \ init-tree tree-root tree-version set-tree-version inventory \ tagging-method tree-lint missing-tags add delete \ @@ -30,7 +30,7 @@ _larch() distribution-name notify my-notifier mail-new-categories \ mail-new-branches mail-new-versions mail-new-revisions \ notify-library notify-browser push-new-revisions sendmail-mailx' \ - "$cur" ) ) + "$cur") ) fi } && diff --git a/completions/lastlog b/completions/lastlog index 4ac6b520..19e928c2 100644 --- a/completions/lastlog +++ b/completions/lastlog @@ -6,18 +6,18 @@ _lastlog() _init_completion -s || return case $prev in - -b|--before|-h|--help|-t|--time) + --before|--help|--time|-!(-*)@([bt]|h*)) return ;; - -u|--user) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + --user|-!(-*)u) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; esac $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _lastlog lastlog diff --git a/completions/ldapsearch b/completions/ldapsearch index 9a6f25db..a0bdcb9d 100644 --- a/completions/ldapsearch +++ b/completions/ldapsearch @@ -2,12 +2,12 @@ _ldap_uris() { - COMPREPLY=( $( compgen -W 'ldap:// ldaps://' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'ldap:// ldaps://' -- "$cur") ) } _ldap_protocols() { - COMPREPLY=( $( compgen -W '2 3' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '2 3' -- "$cur") ) } _ldapsearch() @@ -16,39 +16,38 @@ _ldapsearch() _init_completion || return case $prev in - -h) + -*h) _known_hosts_real -- "$cur" return ;; - -H) + -*H) _ldap_uris return ;; - -T) + -*T) _filedir -d return ;; - -f|-y) + -*[fy]) _filedir return ;; - -s) - COMPREPLY=( $( compgen -W 'base one sub children' -- "$cur" ) ) + -*s) + COMPREPLY=( $(compgen -W 'base one sub children' -- "$cur") ) return ;; - -a) - COMPREPLY=( $( compgen -W 'never always search find' \ - -- "$cur" ) ) + -*a) + COMPREPLY=( $(compgen -W 'never always search find' -- "$cur") ) return ;; - -P) + -*P) _ldap_protocols return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) fi } && complete -F _ldapsearch ldapsearch @@ -59,26 +58,26 @@ _ldapaddmodify() _init_completion || return case $prev in - -h) + -*h) _known_hosts_real -- "$cur" return ;; - -H) + -*H) _ldap_uris return ;; - -S|-f|-y) + -*[Sfy]) _filedir return ;; - -P) + -*P) _ldap_protocols return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) fi } && complete -F _ldapaddmodify ldapadd ldapmodify @@ -89,26 +88,26 @@ _ldapdelete() _init_completion || return case $prev in - -h) + -*h) _known_hosts_real -- "$cur" return ;; - -H) + -*H) _ldap_uris return ;; - -f|-y) + -*[fy]) _filedir return ;; - -P) + -*P) _ldap_protocols return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) fi } && complete -F _ldapdelete ldapdelete @@ -119,26 +118,26 @@ _ldapcompare() _init_completion || return case $prev in - -h) + -*h) _known_hosts_real -- "$cur" return ;; - -H) + -*H) _ldap_uris return ;; - -y) + -*y) _filedir return ;; - -P) + -*P) _ldap_protocols return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) fi } && complete -F _ldapcompare ldapcompare @@ -149,26 +148,26 @@ _ldapmodrdn() _init_completion || return case $prev in - -h) + -*h) _known_hosts_real -- "$cur" return ;; - -H) + -*H) _ldap_uris return ;; - -f|-y) + -*[fy]) _filedir return ;; - -P) + -*P) _ldap_protocols return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -ZZ -MM' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") -ZZ -MM' -- "$cur") ) fi } && complete -F _ldapmodrdn ldapmodrdn @@ -179,26 +178,26 @@ _ldapwhoami() _init_completion || return case $prev in - -h) + -*h) _known_hosts_real -- "$cur" return ;; - -H) + -*H) _ldap_uris return ;; - -f|-y) + -*[fy]) _filedir return ;; - -P) + -*P) _ldap_protocols return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) fi } && complete -F _ldapwhoami ldapwhoami @@ -209,22 +208,22 @@ _ldappasswd() _init_completion || return case $prev in - -h) + -*h) _known_hosts_real -- "$cur" return ;; - -H) + -*H) _ldap_uris return ;; - -t|-T|-y) + -*[tTy]) _filedir return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) fi } && complete -F _ldappasswd ldappasswd diff --git a/completions/ldapvi b/completions/ldapvi index 7d3fcf66..a7b55fcc 100644 --- a/completions/ldapvi +++ b/completions/ldapvi @@ -6,44 +6,44 @@ _ldapvi() _init_completion || return case $prev in - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -Y|--sasl-mech) - COMPREPLY=( $( compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 - PLAIN ANONYMOUS' -- "$cur" ) ) + --sasl-mech|-!(-*)Y) + COMPREPLY=( $(compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 + PLAIN ANONYMOUS' -- "$cur") ) return ;; --bind) - COMPREPLY=( $( compgen -W 'simple sasl' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'simple sasl' -- "$cur") ) return ;; --bind-dialog) - COMPREPLY=( $( compgen -W 'never auto always' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'never auto always' -- "$cur") ) return ;; --scope) - COMPREPLY=( $( compgen -W 'base one sub' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'base one sub' -- "$cur") ) return ;; --deref) - COMPREPLY=( $( compgen -W 'never searching finding always' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'never searching finding always' \ + -- "$cur") ) return ;; --encoding) - COMPREPLY=( $( compgen -W 'ASCII UTF-8 binary' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'ASCII UTF-8 binary' -- "$cur") ) return ;; --tls) - COMPREPLY=( $( compgen -W 'never allow try strict' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'never allow try strict' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _ldapvi ldapvi diff --git a/completions/lftp b/completions/lftp index 3eb07399..41fb1356 100644 --- a/completions/lftp +++ b/completions/lftp @@ -6,22 +6,22 @@ _lftp() _init_completion || return case $prev in - -f) + -!(-*)f) _filedir return ;; - -c|-h|--help|-v|--version|-e|-u|-p) + --help|--version|-!(-*)[chveups]) return ;; esac - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -W \ - '$( cut -f 1 -s ~/.lftp/bookmarks ${XDG_DATA_HOME:-$HOME/.local/share}/lftp/bookmarks 2>/dev/null )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(cut -f 1 -s ~/.lftp/bookmarks ${XDG_DATA_HOME:-$HOME/.local/share}/lftp/bookmarks 2>/dev/null)' -- "$cur") ) _known_hosts_real -- "$cur" } && complete -F _lftp lftp diff --git a/completions/lftpget b/completions/lftpget index 8f1d4a2f..1583500c 100644 --- a/completions/lftpget +++ b/completions/lftpget @@ -5,8 +5,8 @@ _lftpget() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '-c -d -v' -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '-c -d -v' -- "$cur") ) fi } && complete -F _lftpget lftpget diff --git a/completions/lilo b/completions/lilo index 1ccca35c..03e3ee29 100644 --- a/completions/lilo +++ b/completions/lilo @@ -2,8 +2,8 @@ _lilo_labels() { - COMPREPLY=( $( compgen -W "$( awk -F'=' '/label/ {print $2}' \ - /etc/lilo.conf | command sed -e 's/\"//g' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(awk -F'=' '/label/ {print $2}' \ + /etc/lilo.conf | command sed -e 's/\"//g')" -- "$cur") ) } _lilo() @@ -33,16 +33,16 @@ _lilo() ;; -T) # topic completion - COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= table= - video' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help ChRul EBDA geom geom= table= + video' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then # relevant options completion - COMPREPLY=( $( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m -M -p -P - -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m -M -p -P + -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- "$cur") ) fi } && complete -F _lilo lilo diff --git a/completions/links b/completions/links index 8c72970e..6bfee654 100644 --- a/completions/links +++ b/completions/links @@ -3,31 +3,98 @@ _links() { local cur prev words cword - _init_completion || return + _init_completion -n : || return - case $cur in - --*) - COMPREPLY=( $( compgen -W '--help' -- "$cur" ) ) - ;; - -*) - COMPREPLY=( $( compgen -W '-async-dns -max-connections - -max-connections-to-host -retries -receive-timeout - -unrestartable-receive-timeout -format-cache-size - -memory-cache-size -http-proxy -ftp-proxy -download-dir - -assume-codepage -anonymous -dump -no-connect -source -version - -help' -- "$cur" ) ) - ;; - *) - if [[ -r ~/.links/links.his ]]; then - COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \ - -- "$cur" ) ) - fi - _filedir '@(htm|html)' + case $prev in + -html-t-text-color|-html-t-link-color) + COMPREPLY=( $(compgen -W '{0..15}' -- "$cur") ) + return + ;; + -http.fake-firefox|-html-[gt]-ignore-document-color) + COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) + return + ;; + --help|-help|-mode|-display|-source|-dump|-width|-max-connections|\ + -max-connections-to-host|-retries|-receive-timeout|\ + -unrestartable-receive-timeout|-*-size|-*-proxy|\ + -append-text-to-dns-lookups|-ssl.client-cert-passwd|-http.fake-*|\ + -http.extra-header|-ftp.anonymous-passwd|-*-color|-*-gamma|\ + -bfu-aspect|-html-image-scale|-html-margin) + return + ;; + -lookup) + _known_hosts_real -- "$cur" + return + ;; + -driver) + local drivers=$("$1" -driver foo 2>&1 | + command sed -ne '$!d' -e '/^[a-z0-9, ]\{1,\}$/s/,/ /gp') + [[ $drivers ]] || drivers='x svgalib fb directfb pmshell atheos' + COMPREPLY=( $(compgen -W "$drivers" -- "$cur") ) + return + ;; + -codepage|-bookmarks-codepage|-http-assume-codepage) + _xfunc iconv _iconv_charsets + return + ;; + -download-dir) + _filedir -d + return + ;; + -bind-address) + _ip_addresses + return + ;; + -bind-address-ipv6) + _ip_addresses -6 + __ltrim_colon_completions "$cur" + return + ;; + -async-dns|-download-utime|-aggressive-cache|-only-proxies|\ + -http-bugs.*|-http.do-not-track|-ftp.use-*|-ftp.fast|-ftp.set-iptos|\ + -smb.allow-hyperlinks-to-smb|-save-url-history|-dither-letters|\ + -dither-images|-overwrite-instead-of-scroll|-html-*) + COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) + return + ;; + -address-preference|-http.referer) + COMPREPLY=( $(compgen -W '{0..4}' -- "$cur") ) + return + ;; + -ssl-certificates|-display-optimize|-gamma-correction) + COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") ) + return + ;; + -ssl.client-cert-key) + _filedir '@(key|pem)' + return + ;; + -ssl.client-cert-crt) + _filedir '@(c?(e)rt|cer|pem|der)' + return + ;; + -bookmarks-file) + _filedir html return ;; esac + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1" | + command grep -vF -- "->")' -- "$cur") ) + return + fi + + local dir + for dir in .links .links2; do + if [[ -r ~/$dir/links.his ]]; then + COMPREPLY+=( $(compgen -W '$(cat ~/$dir/links.his)' -- "$cur") ) + __ltrim_colon_completions "$cur" + fi + done + _filedir '@(htm|html)' + } && -complete -F _links links +complete -F _links links links2 # ex: filetype=sh diff --git a/completions/lintian b/completions/lintian index e62a6265..fbf54f96 100644 --- a/completions/lintian +++ b/completions/lintian @@ -4,13 +4,13 @@ _lintian_tags() { local match search tags - tags=$( awk '/^Tag/ { print $2 }' /usr/share/lintian/checks/*.desc ) + tags=$(awk '/^Tag/ { print $2 }' /usr/share/lintian/checks/*.desc) if [[ "$cur" == *, ]]; then search=${cur//,/ } for item in $search; do - match=$( command grep -nE "^Tag: $item$" \ - /usr/share/lintian/checks/*.desc | cut -d: -f1 ) - tags=$( command sed -e "s/\<$item\>//g" <<<$tags ) + match=$(command grep -nE "^Tag: $item$" \ + /usr/share/lintian/checks/*.desc | cut -d: -f1) + tags=$(command sed -e "s/\<$item\>//g" <<<$tags) done COMPREPLY+=( $(compgen -W "$tags") ) elif [[ "$cur" == *,* ]]; then @@ -24,16 +24,16 @@ _lintian_checks() { local match search todisable checks - checks=$( awk '/^(Check-Script|Abbrev)/ { print $2 }' \ - /usr/share/lintian/checks/*.desc ) + checks=$(awk '/^(Check-Script|Abbrev)/ { print $2 }' \ + /usr/share/lintian/checks/*.desc) if [[ "$cur" == *, ]]; then search=${cur//,/ } for item in $search; do - match=$( command grep -nE "^(Check-Script|Abbrev): $item$" \ - /usr/share/lintian/checks/*.desc | cut -d: -f1 ) - todisable=$( awk '/^(Check-Script|Abbrev)/ { print $2 }' $match ) + match=$(command grep -nE "^(Check-Script|Abbrev): $item$" \ + /usr/share/lintian/checks/*.desc | cut -d: -f1) + todisable=$(awk '/^(Check-Script|Abbrev)/ { print $2 }' $match) for name in $todisable; do - checks=$( command sed -e "s/\<$name\>//g" <<<$checks ) + checks=$(command sed -e "s/\<$name\>//g" <<<$checks) done done COMPREPLY+=( $(compgen -W "$checks") ) @@ -48,14 +48,14 @@ _lintian_infos() { local match search infos - infos=$( awk '/^Collector/ { print $2 }' \ - /usr/share/lintian/collection/*.desc ) + infos=$(awk '/^Collector/ { print $2 }' \ + /usr/share/lintian/collection/*.desc) if [[ "$cur" == *, ]]; then search=${cur//,/ } for item in $search; do - match=$( command grep -nE "^Collector: $item$" \ - /usr/share/lintian/collection/*.desc | cut -d: -f1 ) - infos=$( command sed -e "s/\<$item\>//g" <<<$infos ) + match=$(command grep -nE "^Collector: $item$" \ + /usr/share/lintian/collection/*.desc | cut -d: -f1) + infos=$(command sed -e "s/\<$item\>//g" <<<$infos) done COMPREPLY+=( $(compgen -W "$infos") ) elif [[ "$cur" == *,* ]]; then diff --git a/completions/lisp b/completions/lisp index 279ffcdb..f9f68275 100644 --- a/completions/lisp +++ b/completions/lisp @@ -9,9 +9,9 @@ _lisp() # completing an option (may or may not be separated by a space) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-core -lib -batch -quit -edit -eval -init + COMPREPLY=( $(compgen -W '-core -lib -batch -quit -edit -eval -init -dynamic-space-size -hinit -noinit -nositeinit -load -slave' \ - -- "$cur" ) ) + -- "$cur") ) else _filedir fi diff --git a/completions/list_admins b/completions/list_admins index 06542f91..11f7414d 100644 --- a/completions/list_admins +++ b/completions/list_admins @@ -6,7 +6,7 @@ _list_admins() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--all-vhost --all --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--all-vhost --all --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/list_lists b/completions/list_lists index 629e4c07..c0807178 100644 --- a/completions/list_lists +++ b/completions/list_lists @@ -2,7 +2,7 @@ _mailman_lists() { - COMPREPLY=( $( compgen -W '$( list_lists -b 2>/dev/null )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(list_lists -b 2>/dev/null)' -- "$cur") ) } _list_lists() @@ -11,8 +11,8 @@ _list_lists() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--advertised --virtual-host-overview --bare - --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--advertised --virtual-host-overview --bare + --help' -- "$cur") ) fi } && diff --git a/completions/list_members b/completions/list_members index e60f61da..90db5cba 100644 --- a/completions/list_members +++ b/completions/list_members @@ -11,12 +11,12 @@ _list_members() return ;; -d|--digest) - COMPREPLY=( $( compgen -W 'mime plain' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'mime plain' -- "$cur") ) return ;; -n|--nomail) - COMPREPLY=( $( compgen -W 'byadmin byuser bybounce unknown' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'byadmin byuser bybounce unknown' \ + -- "$cur") ) return ;; esac @@ -24,8 +24,8 @@ _list_members() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--output --regular --digest --nomail - --fullnames --preserve --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--output --regular --digest --nomail + --fullnames --preserve --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/list_owners b/completions/list_owners index 88b25bb3..18b52476 100644 --- a/completions/list_owners +++ b/completions/list_owners @@ -6,8 +6,8 @@ _list_owners() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--with-listnames --moderators --help' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--with-listnames --moderators --help' \ + -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/locale-gen b/completions/locale-gen new file mode 100644 index 00000000..3dae76ff --- /dev/null +++ b/completions/locale-gen @@ -0,0 +1,32 @@ +# locale-gen(8) completion -*- shell-script -*- + +_locale_gen() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|-h) + return + ;; + --aliases) + _filedir alias + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + COMPREPLY=( $(compgen -W \ + '$(awk "{ print \$1 }" /usr/share/i18n/SUPPORTED 2>/dev/null)' \ + -- "$cur") ) +} && +complete -F _locale_gen locale-gen + +# ex: filetype=sh diff --git a/completions/lpq b/completions/lpq index b02705af..a1223268 100644 --- a/completions/lpq +++ b/completions/lpq @@ -7,17 +7,17 @@ _lpq() case $prev in -P) - COMPREPLY=( $( compgen -W "$( lpstat -a 2>/dev/null | cut -d' ' -f1 )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) return ;; -U) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; esac if [[ "$cur" == - ]]; then - COMPREPLY=( $( compgen -W '-E -P -U -a -h -l' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-E -P -U -a -h -l' -- "$cur") ) return fi diff --git a/completions/lpr b/completions/lpr index b1515bd5..9a9e8639 100644 --- a/completions/lpr +++ b/completions/lpr @@ -7,22 +7,22 @@ _lpr() case $prev in -P) - COMPREPLY=( $( compgen -W "$( lpstat -a 2>/dev/null | cut -d' ' -f1 )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) return ;; -U) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; -o) - COMPREPLY=( $( compgen -W "media= landscape orientation-requested= sides= fitplot number-up= scaling= cpi= lpi= page-bottom= page-top= page-left= page-right=" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "media= landscape orientation-requested= sides= fitplot number-up= scaling= cpi= lpi= page-bottom= page-top= page-left= page-right=" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return ;; esac if [[ "$cur" == - ]]; then - COMPREPLY=( $( compgen -W '-E -H -C -J -T -P -U -h -l -m -o -p -q -r' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-E -H -C -J -T -P -U -h -l -m -o -p -q -r' -- "$cur") ) return fi diff --git a/completions/lrzip b/completions/lrzip index 5338bd87..5eb2445b 100644 --- a/completions/lrzip +++ b/completions/lrzip @@ -8,36 +8,36 @@ _lrzip() local xspec="*.lrz" case $prev in - -w|-S|-V|-h|-'?'|-m) + -*@([wSm]|[Vh?]*)) return ;; - -d) + -*d) xspec="!"$xspec ;; - -o) + -*o) _filedir return ;; - -O) + -*O) _filedir -d return ;; - -L) - COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) + -*L) + COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) return ;; - -N) - COMPREPLY=( $( compgen -W '{-20..19}' -- "$cur" ) ) + -*N) + COMPREPLY=( $(compgen -W '{-20..19}' -- "$cur") ) return ;; - -p) - COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) + -*p) + COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi @@ -45,8 +45,7 @@ _lrzip() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) } && complete -F _lrzip lrzip diff --git a/completions/lsof b/completions/lsof index 329946d5..e904f406 100644 --- a/completions/lsof +++ b/completions/lsof @@ -18,11 +18,11 @@ _lsof() return ;; -D) - COMPREPLY=( $( compgen -W '? b i r u' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '? b i r u' -- "$cur") ) return ;; -f) - COMPREPLY=( $( compgen -W 'c f g G n' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'c f g G n' -- "$cur") ) return ;; -g) @@ -37,15 +37,15 @@ _lsof() ;; -u) # TODO: handle ^foo exclusions, comma separated lists - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; esac if [[ "$cur" == [-+]* ]]; then - COMPREPLY=( $( compgen -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g + COMPREPLY=( $(compgen -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g -i -k -l +L -L +m -m +M -M -n -N -o -O -p -P +r -r -R -s -S -T -t - -u -U -v -V +w -w -x -X -z -Z' -- "$cur" ) ) + -u -U -v -V +w -w -x -X -z -Z' -- "$cur") ) return fi diff --git a/completions/lspci b/completions/lspci index 70abc3c4..e31a5b57 100644 --- a/completions/lspci +++ b/completions/lspci @@ -6,34 +6,34 @@ _lspci() _init_completion || return case $prev in - -s|-D|-O) + -*[sDO]) return ;; - -i) + -*i) _filedir ids return ;; - -p) + -*p) _filedir pcimap return ;; - -A) - COMPREPLY+=( $( compgen -W '$( $1 -A help | command grep -vF : )' \ + -*A) + COMPREPLY+=( $(compgen -W '$($1 -A help | command grep -vF :)' \ -- "$cur") ) return ;; - -H) - COMPREPLY+=( $( compgen -W "1 2" -- "$cur" ) ) + -*H) + COMPREPLY+=( $(compgen -W "1 2" -- "$cur") ) return ;; - -F) + -*F) _filedir return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _lspci lspci diff --git a/completions/lsscsi b/completions/lsscsi index b64c5927..b401c8ab 100644 --- a/completions/lsscsi +++ b/completions/lsscsi @@ -6,10 +6,10 @@ _lsscsi() _init_completion -s || return case $prev in - -h|--help|-V|--version) + --help|--version|-!(-*)[hV]*) return ;; - -y|--sysfsroot) + --sysfsroot|-!(-*)y) _filedir -d return ;; @@ -18,7 +18,7 @@ _lsscsi() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/lsusb b/completions/lsusb index d6700beb..c315abd1 100644 --- a/completions/lsusb +++ b/completions/lsusb @@ -6,13 +6,13 @@ _lsusb() _init_completion || return case $prev in - -h|--help|-V|--version|-s|-D) + --help|--version|-!(-*)@([sD]|[hV]*)) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _lsusb lsusb diff --git a/completions/lua b/completions/lua index 9413319e..775eae20 100644 --- a/completions/lua +++ b/completions/lua @@ -12,7 +12,7 @@ _lua() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) return fi diff --git a/completions/luac b/completions/luac index 9c91f25a..15b562ae 100644 --- a/completions/luac +++ b/completions/luac @@ -16,7 +16,7 @@ _luac() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) return fi diff --git a/completions/luseradd b/completions/luseradd index 41769b00..2fa336db 100644 --- a/completions/luseradd +++ b/completions/luseradd @@ -6,20 +6,20 @@ _luseradd() _init_completion -s || return case $prev in - -\?|--help|--usage|-c|--gecos|-u|--uid|-l|--login|-P|--plainpassword|\ - -p|--password|--commonname|--givenname|--surname|--roomnumber|\ - --telephonenumber|--homephone) + --help|--usage|--gecos|--uid|--login|--plainpassword|--password|\ + --commonname|--givenname|--surname|--roomnumber|--telephonenumber|\ + --homephone|-!(-*)@([culPp]|[?]*)) return ;; - -d|--directory|-k|--skeleton) + --directory|--skeleton|-!(-*)[dk]) _filedir -d return ;; - -s|--shell) + --shell|-!(-*)s) _shells return ;; - -g|--gid) + --gid|-!(-*)g) _gids return ;; @@ -28,12 +28,12 @@ _luseradd() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi - [[ ${1##*/} == luseradd ]] || COMPREPLY=( $( compgen -u -- "$cur" ) ) + [[ ${1##*/} == luseradd ]] || COMPREPLY=( $(compgen -u -- "$cur") ) } && complete -F _luseradd luseradd lusermod diff --git a/completions/luserdel b/completions/luserdel index 83e1818b..ee2b4fdb 100644 --- a/completions/luserdel +++ b/completions/luserdel @@ -6,17 +6,17 @@ _luserdel() _init_completion || return case $prev in - -\?|--help|--usage) + --help|--usage|-!(-*)[?]*) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) } && complete -F _luserdel luserdel diff --git a/completions/lvm b/completions/lvm index fb83a3fb..63048aeb 100644 --- a/completions/lvm +++ b/completions/lvm @@ -8,30 +8,30 @@ _lvm_filedir() _lvm_volumegroups() { - COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \ - command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(vgscan 2>/dev/null | \ + command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur") ) } _lvm_physicalvolumes_all() { - COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \ - command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(pvscan 2>/dev/null | \ + command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p' )" -- "$cur") ) } _lvm_physicalvolumes() { - COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \ - command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(pvscan 2>/dev/null | \ + command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur") ) } _lvm_logicalvolumes() { - COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \ - command sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(lvscan 2>/dev/null | \ + command sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur") ) if [[ $cur == /dev/mapper/* ]]; then _filedir local i - for i in ${!COMPREPLY[@]}; do + for i in "${!COMPREPLY[@]}"; do [[ ${COMPREPLY[i]} == */control ]] && unset 'COMPREPLY[i]' done fi @@ -39,12 +39,12 @@ _lvm_logicalvolumes() _lvm_units() { - COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'h s b k m g t H K M G T' -- "$cur") ) } _lvm_sizes() { - COMPREPLY=( $( compgen -W 'k K m M g G t T' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'k K m M g G t T' -- "$cur") ) } # @param $1 glob matching args known to take an argument @@ -58,7 +58,7 @@ _lvm_count_args() local i prev=${words[$offset-1]} for (( i=$offset; i < cword; i++ )); do if [[ "${words[i]}" != -* && $prev != $1 ]]; then - args=$(($args + 1)) + (( args++ )) fi prev=${words[i]} done @@ -70,7 +70,7 @@ _lvmdiskscan() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) fi } && complete -F _lvmdiskscan lvmdiskscan @@ -81,9 +81,9 @@ _pvscan() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--debug --exported --novolumegroup --help + COMPREPLY=( $(compgen -W '--debug --exported --novolumegroup --help --ignorelockingfailure --partial --short --uuid --verbose - --version' -- "$cur" ) ) + --version' -- "$cur") ) fi } && complete -F _pvscan pvscan @@ -94,9 +94,9 @@ _pvs() _init_completion || return case $prev in - -o|-O|--options|--sort) - COMPREPLY=( $( compgen -W 'pv_fmt pv_uuid pv_size pv_free pv_used - pv_name pv_attr pv_pe_count pv_pe_alloc_count' -- "$cur" ) ) + --options|--sort|-!(-*)[oO]) + COMPREPLY=( $(compgen -W 'pv_fmt pv_uuid pv_size pv_free pv_used + pv_name pv_attr pv_pe_count pv_pe_alloc_count' -- "$cur") ) return ;; --units) @@ -106,7 +106,7 @@ _pvs() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_physicalvolumes_all fi @@ -126,7 +126,7 @@ _pvdisplay() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_physicalvolumes_all fi @@ -139,14 +139,14 @@ _pvchange() _init_completion || return case $prev in - -A|-x|--autobackup|--allocatable) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|--allocatable|-!(-*)[Ax]) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_physicalvolumes_all fi @@ -163,12 +163,12 @@ _pvcreate() _filedir return ;; - -M|--metadatatype) - COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) + --metadatatype|-!(-*)M) + COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) return ;; --metadatacopies) - COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '0 1 2' -- "$cur") ) return ;; --metadatasize|--setphysicalvolumesize) @@ -178,7 +178,7 @@ _pvcreate() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_filedir fi @@ -191,19 +191,19 @@ _pvmove() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -n|--name) + --name|-!(-*)n) _lvm_logicalvolumes return esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--abort --autobackup --background --debug + COMPREPLY=( $(compgen -W '--abort --autobackup --background --debug --force --help --interval --test --verbose --version --name' \ - -- "$cur" ) ) + -- "$cur") ) else _lvm_physicalvolumes fi @@ -216,7 +216,7 @@ _pvremove() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_physicalvolumes_all fi @@ -229,7 +229,7 @@ _vgscan() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) fi } && complete -F _vgscan vgscan @@ -240,11 +240,11 @@ _vgs() _init_completion || return case $prev in - -o|-O|--options|--sort) - COMPREPLY=( $( compgen -W 'vg_fmt vg_uuid vg_name vg_attr vg_size + --options|--sort|-!(-*)[oO]) + COMPREPLY=( $(compgen -W 'vg_fmt vg_uuid vg_name vg_attr vg_size vg_free vg_sysid vg_extent_size vg_extent_count vg_free_count max_lv max_pv pv_count lv_count snap_count vg_seqno' \ - -- "$cur" ) ) + -- "$cur") ) return ;; --units) @@ -254,7 +254,7 @@ _vgs() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -274,7 +274,7 @@ _vgdisplay() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -287,17 +287,17 @@ _vgchange() _init_completion || return case $prev in - -a|-A|-x|--available|--autobackup|--resizeable) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --available|--autobackup|--resizeable|-!(-*)[aAx]) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--autobackup --alloc --partial --debug + COMPREPLY=( $(compgen -W '--autobackup --alloc --partial --debug --help --ignorelockingfailure --test --uuid --verbose --version --available --resizeable --logicalvolume --addtag --deltag' \ - -- "$cur" ) ) + -- "$cur") ) else _lvm_volumegroups fi @@ -310,24 +310,24 @@ _vgcreate() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -M|--metadatatype) - COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) + --metadatatype|-!(-*)M) + COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) return ;; - -s|--physicalextentsize) + --physicalextentsize|-!(-*)s) _lvm_sizes return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--autobackup --addtag --alloc --debug --help + COMPREPLY=( $(compgen -W '--autobackup --addtag --alloc --debug --help --maxlogicalvolumes --metadatatype --maxphysicalvolumes - --physicalextentsize --test --verbose --version' -- "$cur" ) ) + --physicalextentsize --test --verbose --version' -- "$cur") ) else local args _lvm_count_args '@(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize)' @@ -346,7 +346,7 @@ _vgremove() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -359,14 +359,14 @@ _vgrename() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -379,14 +379,14 @@ _vgreduce() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else local args @@ -406,18 +406,18 @@ _vgextend() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -L|--size) + --size|-!(-*)L) _lvm_sizes return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' @@ -436,7 +436,7 @@ _vgport() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -449,7 +449,7 @@ _vgck() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -462,12 +462,12 @@ _vgconvert() _init_completion || return case $prev in - -M|--metadatatype) - COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) + --metadatatype|-!(-*)M) + COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) return ;; --metadatacopies) - COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '0 1 2' -- "$cur") ) return ;; --metadatasize) @@ -477,7 +477,7 @@ _vgconvert() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -490,14 +490,14 @@ _vgcfgbackup() _init_completion || return case $prev in - -f|--file) + --file|-!(-*)f) _filedir return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -510,22 +510,22 @@ _vgcfgrestore() _init_completion || return case $prev in - -f|--file) + --file|-!(-*)f) _filedir return ;; - -M|--metadatatype) - COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) + --metadatatype|-!(-*)M) + COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) return ;; - -n|--name) + --name|-!(-*)n) _lvm_volumegroups return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -538,14 +538,14 @@ _vgmerge() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -558,19 +558,19 @@ _vgsplit() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -M|--metadatatype) - COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) + --metadatatype|-!(-*)M) + COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--autobackup --debug --help --list - --metadatatype --test --verbose --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--autobackup --debug --help --list + --metadatatype --test --verbose --version' -- "$cur") ) else local args _lvm_count_args '@(-A|--autobackup|-M|--metadatatype)' @@ -589,7 +589,7 @@ _vgmknodes() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_volumegroups fi @@ -602,7 +602,7 @@ _lvscan() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) fi } && complete -F _lvscan lvscan @@ -613,10 +613,10 @@ _lvs() _init_completion || return case $prev in - -o|-O|--options|--sort) - COMPREPLY=( $( compgen -W 'lv_uuid lv_name lv_attr lv_minor lv_size + --options|--sort|-!(-*)[oO]) + COMPREPLY=( $(compgen -W 'lv_uuid lv_name lv_attr lv_minor lv_size seg_count origin snap_percent segtype stripes stripesize - chunksize seg_start seg_size' -- "$cur" ) ) + chunksize seg_start seg_size' -- "$cur") ) return ;; --units) @@ -626,7 +626,7 @@ _lvs() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_logicalvolumes fi @@ -646,7 +646,7 @@ _lvdisplay() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_logicalvolumes fi @@ -659,18 +659,18 @@ _lvchange() _init_completion || return case $prev in - -a|-A|-C|-M|--available|--autobackup|--contiguous|--persistent) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --available|--autobackup|--contiguous|--persistent|-!(-*)[aACM]) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -p|--permission) - COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) ) + --permission|-!(-*)p) + COMPREPLY=( $(compgen -W 'r rw' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_logicalvolumes fi @@ -683,26 +683,26 @@ _lvcreate() _init_completion || return case $prev in - -A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|--contiguous|--persistent|--zero|-!(-*)[ACMZ]) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -L|--size) + --size|-!(-*)L) _lvm_sizes return ;; - -p|--permission) - COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) ) + --permission|-!(-*)p) + COMPREPLY=( $(compgen -W 'r rw' -- "$cur") ) return ;; - -n|--name) + --name|-!(-*)n) _lvm_logicalvolumes return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else local args _lvm_count_args '@(-A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero|-L|--size|-p|--permission|-n|--name)' @@ -721,14 +721,14 @@ _lvremove() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_logicalvolumes fi @@ -741,14 +741,14 @@ _lvrename() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_logicalvolumes fi @@ -761,18 +761,18 @@ _lvreduce() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -L|--size) + --size|-!(-*)L) _lvm_sizes return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _lvm_logicalvolumes fi @@ -785,18 +785,18 @@ _lvresize() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -L|--size) + --size|-!(-*)L) _lvm_sizes return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' @@ -815,18 +815,18 @@ _lvextend() _init_completion || return case $prev in - -A|--autobackup) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + --autobackup|-!(-*)A) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; - -L|--size) + --size|-!(-*)L) _lvm_sizes return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' @@ -845,13 +845,13 @@ _lvm() _init_completion || return if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'dumpconfig help lvchange lvcreate lvdisplay + COMPREPLY=( $(compgen -W 'dumpconfig help lvchange lvcreate lvdisplay lvextend lvmchange lvmdiskscan lvmsadc lvmsar lvreduce lvremove lvrename lvresize lvs lvscan pvchange pvcreate pvdata pvdisplay pvmove pvremove pvresize pvs pvscan vgcfgbackup vgcfgrestore vgchange vgck vgconvert vgcreate vgdisplay vgexport vgextend vgimport vgmerge vgmknodes vgreduce vgremove vgrename vgs vgscan - vgsplit version' -- "$cur" ) ) + vgsplit version' -- "$cur") ) else case "${words[1]}" in pvchange|pvcreate|pvdisplay|pvmove|pvremove|pvresize|pvs|pvscan|\ diff --git a/completions/lz4 b/completions/lz4 index 365fef9d..db8198f8 100644 --- a/completions/lz4 +++ b/completions/lz4 @@ -13,9 +13,9 @@ _lz4() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W \ - '$( _parse_help "$1" -h | command sed -e "/#/d" ) -B{4..7} -i{1..9}' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(_parse_help "$1" -h | command sed -e "/#/d") -B{4..7} -i{1..9}' \ + -- "$cur") ) return fi @@ -23,7 +23,7 @@ _lz4() _count_args [[ $args -gt 2 ]] && return - for word in ${words[@]}; do + for word in "${words[@]}"; do case $word in -*[dt]*) case $args in @@ -46,8 +46,7 @@ _lz4() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) } && complete -F _lz4 lz4 lz4c diff --git a/completions/lzip b/completions/lzip index c1aab4a8..0f95722c 100644 --- a/completions/lzip +++ b/completions/lzip @@ -8,18 +8,18 @@ _lzip() local decompress=false case $prev in - -h|--help|-V|--version|-b|--member-size|-m|--match-length|\ - -s|--dictionary-size|-S|--volume-size|-B|--data-size) + --help|--version|--member-size|--match-length|--dictionary-size|\ + --volume-size|--data-size|-!(-*)@([bmsSB]|[hV]*)) return ;; - -d|--decompress) + --decompress-!(-*)d) decompress=true ;; - -n|--threads) - COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) + --threads-!(-*)n) + COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) return ;; - -o|--output) + --output-!(-*)o) _filedir return ;; @@ -28,8 +28,7 @@ _lzip() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) {-1..-9}' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -41,8 +40,7 @@ _lzip() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -f -X "*.lz" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "*.lz" -- "$cur") $(compgen -d -- "$cur") ) } && complete -F _lzip clzip lzip pdlzip plzip diff --git a/completions/lzma b/completions/lzma index 0a5ab355..81a626f5 100644 --- a/completions/lzma +++ b/completions/lzma @@ -3,14 +3,14 @@ _lzma() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return + + $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 - --help --decompress --compress --keep --force --suffix --test - --stdout --quiet --verbose --license --list --version --small - --fast --best --text' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1") -{1..9}' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -27,8 +27,7 @@ _lzma() _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) } && complete -F _lzma lzma diff --git a/completions/lzop b/completions/lzop index 900a36ad..bedc122e 100644 --- a/completions/lzop +++ b/completions/lzop @@ -6,7 +6,7 @@ _lzop() _init_completion || return case $prev in - -o|--output) + --output|-!(-*)o) _filedir return ;; @@ -14,19 +14,19 @@ _lzop() _filedir -d return ;; - -S|--suffix) + --suffix|-!(-*)S) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 -P + COMPREPLY=( $(compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 -P --fast --best --decompress --extract --test --list --ls --info --sysinfo --license --help --version --stdout --output --path --force --no-checksum --no-name --name --no-mode --no-time --suffix --keep --delete --crc32 --no-warn --ignore-warn --quiet --verbose --no-stdin --filter --checksum --no-color --mono --color' \ - -- "$cur" ) ) + -- "$cur") ) return fi @@ -52,8 +52,7 @@ _lzop() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) } && complete -F _lzop lzop diff --git a/completions/macof b/completions/macof index dacae2fd..c92a3864 100644 --- a/completions/macof +++ b/completions/macof @@ -14,7 +14,7 @@ _macof() if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) fi } && diff --git a/completions/mailmanctl b/completions/mailmanctl index 717df7b9..dac1c5bf 100644 --- a/completions/mailmanctl +++ b/completions/mailmanctl @@ -6,10 +6,10 @@ _mailmanctl() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--no-restart --run-as-user - --stale-lock-cleanup --quiet --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--no-restart --run-as-user + --stale-lock-cleanup --quiet --help' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'start stop restart reopen' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'start stop restart reopen' -- "$cur") ) fi } && diff --git a/completions/make b/completions/make index 45d51168..f119dcc3 100644 --- a/completions/make +++ b/completions/make @@ -6,7 +6,7 @@ _make_target_extract_script() shift local prefix="$1" - local prefix_pat=$( command sed 's/[][\,.*^$(){}?+|/]/\\&/g' <<<"$prefix" ) + local prefix_pat=$(command sed 's/[][\,.*^$(){}?+|/]/\\&/g' <<<"$prefix") local basename=${prefix##*/} local dirname_len=$(( ${#prefix} - ${#basename} )) @@ -89,24 +89,24 @@ _make() local file makef makef_dir=( "-C" "." ) makef_inc i case $prev in - -f|--file|--makefile|-o|--old-file|--assume-old|-W|--what-if|\ - --new-file|--assume-new) + --file|--makefile|--old-file|--assume-old|--what-if| --new-file|\ + --assume-new|-!(-*)[foW]) _filedir return ;; - -I|--include-dir|-C|--directory|-m) + --include-dir|--directory|-!(-*)[ICm]) _filedir -d return ;; - -E) - COMPREPLY=( $( compgen -v -- "$cur" ) ) + -!(-*)E) + COMPREPLY=( $(compgen -v -- "$cur") ) return ;; - --eval|-D|-V|-x) + --eval|-!(-*)[DVx]) return ;; - --jobs|-j) - COMPREPLY=( $( compgen -W "{1..$(( $(_ncpus)*2 ))}" -- "$cur" ) ) + --jobs|-!(-*)j) + COMPREPLY=( $(compgen -W "{1..$(( $(_ncpus)*2 ))}" -- "$cur") ) return ;; esac @@ -114,9 +114,8 @@ _make() $split && return if [[ "$cur" == -* ]]; then - local opts="$( _parse_help "$1" )" - [[ $opts ]] || opts="$( _parse_usage "$1" )" - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + local opts="$(_parse_help "$1")" + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace elif [[ $cur == *=* ]]; then prev=${cur%%=*} @@ -130,7 +129,7 @@ _make() for (( i=0; i < ${#words[@]}; i++ )); do if [[ ${words[i]} == -@(C|-directory) ]]; then # eval for tilde expansion - eval makef_dir=( -C "${words[i+1]}" ) + eval "makef_dir=( -C \"${words[i+1]}\" )" break fi done @@ -140,7 +139,7 @@ _make() for (( i=0; i < ${#words[@]}; i++ )); do if [[ ${words[i]} == -@(f|-?(make)file) ]]; then # eval for tilde expansion - eval makef=( -f "${words[i+1]}" ) + eval "makef=( -f \"${words[i+1]}\" )" break fi done @@ -152,11 +151,11 @@ _make() mode=-d # display-only mode fi - local IFS=$' \t\n' script=$( _make_target_extract_script $mode "$cur" ) - COMPREPLY=( $( LC_ALL=C \ + local IFS=$' \t\n' script=$(_make_target_extract_script $mode "$cur") + COMPREPLY=( $(LC_ALL=C \ $1 -npq __BASH_MAKE_COMPLETION__=1 \ "${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null | \ - command sed -ne "$script" ) ) + command sed -ne "$script") ) if [[ $mode != -d ]]; then # Completion will occur if there is only one suggestion diff --git a/completions/makepkg b/completions/makepkg index 84b4af79..98edda8f 100644 --- a/completions/makepkg +++ b/completions/makepkg @@ -1,25 +1,47 @@ -# Slackware Linux makepkg completion -*- shell-script -*- +# makepkg completion -*- shell-script -*- -_makepkg() +# Slackware Linux variant +_makepkg_slackware() { local cur prev words cword _init_completion || return case "$prev" in -l|--linkadd|-c|--chown) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-l --linkadd -p --prepend -c --chown' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$1 | command sed -e "s/^options://" | _parse_help -' -- "$cur") ) return fi _filedir +} + +_makepkg_bootstrap() +{ + local fname help + + # Use --help to detect variant; the Slackware one starts making + # a package for unknown args, including --version :P + help=$("$1" --help 2>&1) + case ${help,,} in + *slackware*) + fname=_makepkg_slackware + ;; + *) + fname=_minimal + ;; + esac + + unset -f _makepkg_bootstrap + complete -F $fname makepkg + $fname } && -complete -F _makepkg makepkg +complete -F _makepkg_bootstrap makepkg # ex: filetype=sh diff --git a/completions/man b/completions/man index 0668b8ee..02bd4f70 100644 --- a/completions/man +++ b/completions/man @@ -10,29 +10,29 @@ _man() local mansect="@([0-9lnp]|[0-9][px]|3?(gl|pm))" case $prev in - -C|--config-file) + --config-file|-!(-*)C) _filedir conf return ;; - -l|--local-file) + --local-file|-!(-*)l) _filedir "$manext" return ;; - -M|--manpath) + --manpath|-!(-*)M) _filedir -d return ;; - -P|--pager) + --pager|-!(-*)P) compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) return ;; - -p|--preprocessor) - COMPREPLY=( $( compgen -W 'e p t g r v' -- "$cur" ) ) + --preprocessor|-!(-*)p) + COMPREPLY=( $(compgen -W 'e p t g r v' -- "$cur") ) return ;; - -L|--locale|-m|--systems|-e|--extension|-r|--prompt|-R|--recode|\ - -E|--encoding) + --locale|--systems|--extension|--prompt|--recode|--encoding|\ + -!(-*)[LmerRE]) return ;; esac @@ -40,7 +40,7 @@ _man() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -51,7 +51,7 @@ _man() return fi - local manpath=$( manpath 2>/dev/null || command man -w 2>/dev/null ) + local manpath=$(manpath 2>/dev/null || command man -w 2>/dev/null) [[ -z $manpath ]] && manpath="/usr/share/man:/usr/local/share/man" # determine manual section to search @@ -67,13 +67,16 @@ _man() manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }" fi + local IFS=$' \t\n' reset=$(shopt -p failglob); shopt -u failglob # redirect stderr for when path doesn't exist - COMPREPLY=( $( eval command ls "$manpath" 2>/dev/null ) ) + COMPREPLY=( $(eval command ls "$manpath" 2>/dev/null) ) + $reset + # weed out directory path names and paths to man pages COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) # strip suffix from man pages COMPREPLY=( ${COMPREPLY[@]%$comprsuffix} ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}") ) if [[ "$prev" != $mansect ]]; then # File based completion for the rest, prepending ./ if needed diff --git a/completions/mc b/completions/mc index dc322a15..8e96dd97 100644 --- a/completions/mc +++ b/completions/mc @@ -6,16 +6,11 @@ _mc() _init_completion -s || return case $prev in - -e|--edit|-v|--view|-l|--ftplog|-P|--printwd) + --edit|--view|--ftplog|--printwd|-!(-*)[evlP]) _filedir return ;; - -C|--colors|-D|--debuglevel) - # argument required but no completions available - return - ;; - -h|--help|--help-*|-V|--version) - # all other arguments are noop with these + --help|--help-*|--version|--colors|--debuglevel|-!(-*)[hVCD]) return ;; esac @@ -23,8 +18,7 @@ _mc() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir -d diff --git a/completions/mcrypt b/completions/mcrypt index 6d6a898f..f6094a22 100644 --- a/completions/mcrypt +++ b/completions/mcrypt @@ -8,27 +8,27 @@ _mcrypt() case $prev in -g|--openpgp-z) - COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") ) return ;; -o|--keymode) - COMPREPLY=( $( compgen -W '$( $1 --list-keymodes \ - 2>/dev/null )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$($1 --list-keymodes 2>/dev/null )' \ + -- "$cur") ) return ;; -m|--mode) - COMPREPLY=( $( compgen -W "$( $1 --list 2>/dev/null | \ - cut -d: -f2- )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 --list 2>/dev/null | cut -d: -f2-)" \ + -- "$cur") ) return ;; -a|--algorithm) - COMPREPLY=( $( compgen -W "$( $1 --list 2>/dev/null | \ - awk '{print $1}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 --list 2>/dev/null | \ + awk '{print $1}')" -- "$cur") ) return ;; -h|--hash) - COMPREPLY=( $( compgen -W '$( $1 --list-hash 2>/dev/null | \ - command sed -e 1d )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$($1 --list-hash 2>/dev/null | \ + command sed -e 1d)' -- "$cur") ) return ;; -k|-s|--key|--keysize) @@ -45,7 +45,7 @@ _mcrypt() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) elif [[ ${words[0]} == mdecrypt ]]; then _filedir nc else diff --git a/completions/mdadm b/completions/mdadm index d19e89d2..5fbd9bf3 100644 --- a/completions/mdadm +++ b/completions/mdadm @@ -6,11 +6,11 @@ _mdadm_raid_level() for (( i=1; i < cword; i++ )); do case ${words[i]} in - -C|--create) + -!(-*)C*|--create) mode=create break ;; - -B|--build) + -!(-*)B*|--build) mode=build break ;; @@ -19,13 +19,13 @@ _mdadm_raid_level() case $mode in create) - COMPREPLY=( $( compgen -W 'linear raid0 0 stripe raid1 1 mirror + COMPREPLY=( $(compgen -W 'linear raid0 0 stripe raid1 1 mirror raid4 4 raid5 5 raid6 6 raid10 10 multipath mp faulty' \ - -- "$cur" ) ) + -- "$cur") ) ;; build) - COMPREPLY=( $( compgen -W 'linear stripe raid0 0 raid1 multipath mp - faulty' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'linear stripe raid0 0 raid1 multipath mp + faulty' -- "$cur") ) ;; esac } @@ -42,29 +42,29 @@ _mdadm_raid_layout() case $level in raid5) - COMPREPLY=( $( compgen -W 'left-asymmetric left-symmetric - right-asymmetric right-symmetric la ra ls rs' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'left-asymmetric left-symmetric + right-asymmetric right-symmetric la ra ls rs' -- "$cur") ) ;; raid10) - COMPREPLY=( $( compgen -W 'n o p' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'n o p' -- "$cur") ) ;; faulty) - COMPREPLY=( $( compgen -W 'write-transient wt read-transient rt + COMPREPLY=( $(compgen -W 'write-transient wt read-transient rt write-persistent wp read-persistent rp write-all read-fixable - rf clear flush none' -- "$cur" ) ) + rf clear flush none' -- "$cur") ) ;; esac } _mdadm_auto_flag() { - COMPREPLY=( $( compgen -W 'no yes md mdp part p' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'no yes md mdp part p' -- "$cur") ) } _mdadm_update_flag() { - COMPREPLY=( $( compgen -W 'sparc2.2 summaries uuid name homehost resync - byteorder super-minor' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'sparc2.2 summaries uuid name homehost resync + byteorder super-minor' -- "$cur") ) } @@ -74,23 +74,23 @@ _mdadm() _init_completion -s || return case $prev in - -c|--config|-b|--bitmap|--backup-file) + --config|--bitmap|--backup-file|-!(-*)[cb]) _filedir return ;; - -l|--level) + --level|-!(-*)l) _mdadm_raid_level return ;; - -p|--layout|--parity) + --layout|--parity|-!(-*)p) _mdadm_raid_layout return ;; - -a|--auto) + --auto|-!(-*)a) _mdadm_auto_flag return ;; - -U|--update) + --update|-!(-*)U) _mdadm_update_flag return ;; @@ -102,40 +102,40 @@ _mdadm() --force --config= --scan --metadata= --homehost=' if [[ "$cur" == -* ]]; then - if [[ $cword -eq 1 ]] ; then - COMPREPLY=( $( compgen -W "$options --assemble --build --create - --monitor --grow" -- "$cur" ) ) + if [[ $cword -eq 1 ]]; then + COMPREPLY=( $(compgen -W "$options --assemble --build --create + --monitor --grow" -- "$cur") ) else case ${words[cword-1]} in - -A|--assemble) - COMPREPLY=( $( compgen -W "$options --uuid= --super-minor= + --assemble|-!(-*)A*) + COMPREPLY=( $(compgen -W "$options --uuid= --super-minor= --name= --force --run --no-degraded --auto= --bitmap= --backup-file= --update= --auto-update-homehost" \ - -- "$cur" ) ) + -- "$cur") ) ;; - -B|-C|-G|--build|--create|--grow) - COMPREPLY=( $( compgen -W "$options --raid-devices= + --build|--create|--grow|-!(-*)[BCG]*) + COMPREPLY=( $(compgen -W "$options --raid-devices= --spare-devices= --size= --chunk= --rounding= --level= --layout= --parity= --bitmap= --bitmap-chunk= --write-mostly --write-behind= --assume-clean --backup-file= --name= --run --force --auto=" \ - -- "$cur" ) ) + -- "$cur") ) ;; - -F|--follow|--monitor) - COMPREPLY=( $( compgen -W "$options --mail --program + --follow|--monitor|-!(-*)F) + COMPREPLY=( $(compgen -W "$options --mail --program --alert --syslog --delay --daemonise --pid-file - --oneshot --test" -- "$cur" ) ) + --oneshot --test" -- "$cur") ) ;; /dev/*|--add|--fail|--remove) - COMPREPLY=( $( compgen -W "$options --add --re-add - --remove --fail --set-faulty" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options --add --re-add + --remove --fail --set-faulty" -- "$cur") ) ;; *) - COMPREPLY=( $( compgen -W "$options --query --detail + COMPREPLY=( $(compgen -W "$options --query --detail --examine --sparc2.2 --examine-bitmap --run --stop --readonly --readwrite --zero-superblock --test" \ - -- "$cur" ) ) + -- "$cur") ) ;; esac fi diff --git a/completions/mdtool b/completions/mdtool index b4f36e56..67a3c7c3 100644 --- a/completions/mdtool +++ b/completions/mdtool @@ -16,16 +16,16 @@ _mdtool() if [[ -n "$command" ]]; then case $command in "build") - COMPREPLY=( $( compgen -W '--f --buildfile --p --project' \ - -S":" -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--f --buildfile --p --project' \ + -S":" -- "$cur") ) # TODO: This does not work :( #if [[ "$prev" == *: ]]; then # case $prev in # @(--p:|--project:)) - # COMPREPLY=( $( compgen -f -G "*.mdp" -- "$cur" ) ) + # COMPREPLY=( $(compgen -f -G "*.mdp" -- "$cur") ) # ;; # @(--f:|--buildfile:)) - # COMPREPLY=( $( compgen -f -G "*.mdp" -G "*.mds" -- "$cur" ) ) + # COMPREPLY=( $(compgen -f -G "*.mdp" -G "*.mds" -- "$cur") ) # ;; # esac #fi @@ -33,27 +33,27 @@ _mdtool() ;; "generate-makefiles") compopt -o filenames - COMPREPLY=( $( compgen -o filenames -G"*.mds" -- "$cur" ) ) + COMPREPLY=( $(compgen -o filenames -G"*.mds" -- "$cur") ) if [[ "$prev" == *mds ]]; then - COMPREPLY=( $( compgen -W '--simple-makefiles --s --d:' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--simple-makefiles --s --d:' \ + -- "$cur") ) fi return ;; "setup") # TODO: at least return filenames after these options. - COMPREPLY=( $( compgen -W 'install i uninstall u check-install + COMPREPLY=( $(compgen -W 'install i uninstall u check-install ci update up list l list-av la list-update lu rep-add ra rep-remove rr rep-update ru rep-list rl reg-update reg-build rgu info rep-build rb pack p help h dump-file' \ - -- "$cur" ) ) + -- "$cur") ) return ;; esac fi - COMPREPLY=( $( compgen -W 'gsetup build dbgen project-export - generate-makefiles gettext-update setup -q' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'gsetup build dbgen project-export + generate-makefiles gettext-update setup -q' -- "$cur") ) } && complete -F _mdtool mdtool diff --git a/completions/medusa b/completions/medusa index 017d163d..f0ca7022 100644 --- a/completions/medusa +++ b/completions/medusa @@ -6,23 +6,23 @@ _medusa() _init_completion || return case $prev in - -h) + -*h) _known_hosts_real -- "$cur" return ;; - -H|-U|-P|-C|-O) + -*[HUPCO]) _filedir return ;; - -M) - COMPREPLY=( $( compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' \ - | command sed -e 's/\.mod$//')" ) ) + -*M) + COMPREPLY=( $(compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' \ + | command sed -e 's/\.mod$//')") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _medusa medusa diff --git a/completions/mii-diag b/completions/mii-diag index 87f5d8d5..b62174e7 100644 --- a/completions/mii-diag +++ b/completions/mii-diag @@ -7,8 +7,8 @@ _mii_diag() case $prev in -F|-A|--advertise|--fixed-speed) - COMPREPLY=( $( compgen -W '100baseT4 100baseTx 100baseTx-FD - 100baseTx-HD 10baseT 10baseT-FD 10baseT-HD' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '100baseT4 100baseTx 100baseTx-FD + 100baseTx-HD 10baseT 10baseT-FD 10baseT-HD' -- "$cur") ) return ;; esac @@ -16,7 +16,7 @@ _mii_diag() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else _available_interfaces -a fi diff --git a/completions/mii-tool b/completions/mii-tool index 3c5f9b45..9c88ba14 100644 --- a/completions/mii-tool +++ b/completions/mii-tool @@ -6,14 +6,14 @@ _mii_tool() _init_completion -s || return case $prev in - -F|--force) - COMPREPLY=( $( compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD - 10baseT-HD' -- "$cur" ) ) + --force|-!(-*)F) + COMPREPLY=( $(compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD + 10baseT-HD' -- "$cur") ) return ;; - -A|--advertise) - COMPREPLY=( $( compgen -W '100baseT4 100baseTx-FD 100baseTx-HD - 10baseT-FD 10baseT-HD' -- "$cur" ) ) + --advertise|-!(-*)A) + COMPREPLY=( $(compgen -W '100baseT4 100baseTx-FD 100baseTx-HD + 10baseT-FD 10baseT-HD' -- "$cur") ) return ;; esac @@ -21,7 +21,7 @@ _mii_tool() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _available_interfaces -a diff --git a/completions/minicom b/completions/minicom index 897475ed..2e98229a 100644 --- a/completions/minicom +++ b/completions/minicom @@ -2,37 +2,38 @@ _minicom() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return case $prev in - -a|-c) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + --attrib|--color|-!(-*)[ac]) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; - -S|-C) + --script|--capturefile|-!(-*)[SC]) _filedir return ;; - -P) - COMPREPLY=( $( printf '%s\n' /dev/tty* ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \ - -- "$cur" ) ) + --ptty|-!(-*)p) + COMPREPLY=( $(printf '%s\n' /dev/tty*) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \ + -- "$cur") ) return ;; esac + $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-s -o -m -M -z -l -L -w -a -t -c -S -d -p -C - -T -7 -8' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace return fi COMPREPLY=( - $( printf '%s\n' /etc/minirc.* /etc/minicom/minirc.* ~/.minirc.* \ + $(printf '%s\n' /etc/minirc.* /etc/minicom/minirc.* ~/.minirc.* \ | command sed -e '/\*$/d' -e 's/^.*minirc\.//' \ - | command grep "^${cur}" ) ) + | command grep "^${cur}") ) } && complete -F _minicom -o default minicom diff --git a/completions/mkinitrd b/completions/mkinitrd index f0efb294..2e131227 100644 --- a/completions/mkinitrd +++ b/completions/mkinitrd @@ -23,12 +23,12 @@ _mkinitrd() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version --help -v -f --preload \ + COMPREPLY=( $(compgen -W '--version --help -v -f --preload \ --force-scsi-probe --omit-scsi-modules \ --omit-ide-modules --image-version --force-raid-probe \ --omit-raid-modules --with= --force-lvm-probe \ --omit-lvm-modules --builtin --omit-dmraid --net-dev \ - --fstab --nocompress --dsdt --bootchart' -- "$cur" ) ) + --fstab --nocompress --dsdt --bootchart' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else local args diff --git a/completions/mktemp b/completions/mktemp index a8903c16..96c7a118 100644 --- a/completions/mktemp +++ b/completions/mktemp @@ -9,7 +9,7 @@ _mktemp() --help|--version|--suffix) return ;; - --tmpdir|-p) + --tmpdir|-!(-*)p) _filedir -d return ;; @@ -18,9 +18,9 @@ _mktemp() $split && return if [[ "$cur" == -* ]]; then - local opts=$( _parse_help "$1" ) + local opts=$(_parse_help "$1") [[ $opts ]] || opts="-d -u -q -p -t" # non-GNU fallback - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/mmsitepass b/completions/mmsitepass index db1cbf74..fc938d82 100644 --- a/completions/mmsitepass +++ b/completions/mmsitepass @@ -6,7 +6,7 @@ _mmsitepass() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--listcreator --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--listcreator --help' -- "$cur") ) fi } && diff --git a/completions/modinfo b/completions/modinfo index 28f19308..c151fad4 100644 --- a/completions/modinfo +++ b/completions/modinfo @@ -2,31 +2,34 @@ _modinfo() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return case "$prev" in - -F|--field) - COMPREPLY=( $( compgen -W 'alias author depends description + --field|-!(-*)F) + COMPREPLY=( $(compgen -W 'alias author depends description filename firmware license parm srcversion staging vermagic - version' -- "${cur,,}" ) ) + version' -- "${cur,,}") ) return ;; - -k) + --set-version|-!(-*)k) _kernel_versions return ;; esac + $split && return + if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-V --version -F --field -k -0 --null -a -d - -l -p -n' -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace return fi local i version=$(uname -r) for (( i=${#words[@]}-1; i>0; i-- )); do - if [[ ${words[i]} == -k ]]; then + if [[ ${words[i]} == -@(!(-*)k*|-set-version) ]]; then version=${words[i+1]} break fi diff --git a/completions/modprobe b/completions/modprobe index 43a2b01b..16c8453a 100644 --- a/completions/modprobe +++ b/completions/modprobe @@ -6,18 +6,18 @@ _modprobe() _init_completion -s || return case "$prev" in - -h|--help|-V|--version) + --help|--version|-!(-*)[hV]) return ;; - -C|--config) + --config|-!(-*)C) _filedir return ;; - -d|--dirname|-t|--type) + --dirname|--type|-!(-*)[dt]) _filedir -d return ;; - -S|--set-version) + --set-version|-!(-*)S) _kernel_versions return ;; @@ -26,36 +26,36 @@ _modprobe() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) if [[ ! $COMPREPLY ]]; then - COMPREPLY=( $( compgen -W '-a --all -b --use-blacklist -C --config + COMPREPLY=( $(compgen -W '-a --all -b --use-blacklist -C --config -c --showconfig --dump-modversions -d --dirname --first-time --force-vermagic --force-modversion -f --force -i --ignore-install --ignore-remove -l --list -n --dry-run -q --quiet -R --resolve-alias -r --remove -S --set-version --show-depends -s --syslog -t --type -V --version -v - --verbose' -- "$cur" ) ) + --verbose' -- "$cur") ) fi [[ $COMPREPLY == *= ]] && compopt -o nospace return fi - local i mode=insert module= version=$(uname -r) + local i mode=insert module="" version=$(uname -r) for (( i=1; i < $cword; i++ )); do case "${words[i]}" in - -r|--remove) + --remove|-!(-*)r*) mode=remove ;; - -l|--list) + --list|-!(-*)l*) mode=list ;; --dump-modversions) mode=file ;; - -S|--set-version) + --set-version|-!(-*)S) version=${words[i+1]} # -S is not $prev and not $cur ;; - -C|--config|-d|--dirname|-t|--type) + --config|--dirname|--type|-!(-*)[Cdt]) ((i++)) # skip option and its argument ;; -*) @@ -83,17 +83,29 @@ _modprobe() _filedir '@(?(k)o?(.gz))' elif [[ -n "$module" ]]; then # do module parameter completion - COMPREPLY=( $( compgen -W "$( PATH="$PATH:/sbin" modinfo \ - -p "$module" 2>/dev/null | \ - awk -F: '!/^[ \t]/ { print $1 }' )" -- "$cur" ) ) + if [[ $cur == *=* ]]; then + prev=${cur%%=*} + cur=${cur#*=} + if PATH="$PATH:/sbin" modinfo -p "$module" 2>/dev/null \ + | command grep -q "^$prev:.*(bool)"; then + local choices="on off" + [[ $cur ]] && choices="1 0 y Y n N on off" + COMPREPLY=( $(compgen -W "$choices" -- "$cur") ) + fi + else + COMPREPLY=( $(compgen -S = -W "$(PATH="$PATH:/sbin" \ + modinfo -p "$module" 2>/dev/null | \ + awk -F: '!/^[ \t]/ { print $1 }')" -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + fi else _modules $version if [[ $COMPREPLY ]]; then # filter out already installed modules local -a mods=( "${COMPREPLY[@]}" ) _installed_modules "$cur" - for i in ${!mods[@]}; do - for module in ${COMPREPLY[@]}; do + for i in "${!mods[@]}"; do + for module in "${COMPREPLY[@]}"; do if [[ ${mods[i]} == $module ]]; then unset 'mods[i]' break diff --git a/completions/monodevelop b/completions/monodevelop index 13685dfb..4aa213b7 100644 --- a/completions/monodevelop +++ b/completions/monodevelop @@ -8,7 +8,7 @@ _monodevelop() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir diff --git a/completions/mount b/completions/mount deleted file mode 100644 index a8748d1b..00000000 --- a/completions/mount +++ /dev/null @@ -1,62 +0,0 @@ -# mount(8) completion -*- shell-script -*- - -if [[ $OSTYPE == *linux* ]]; then - . "$BASH_SOURCE.linux" - return -fi - -# This will pull a list of possible mounts out of -# /etc/{,v}fstab, unless the word being completed contains a ':', which -# would indicate the specification of an NFS server. In that case, we -# query the server for a list of all available exports and complete on -# that instead. -# -_mount() -{ - local cur prev words cword - _init_completion -n : || return - - local sm host - - case $prev in - -t|--types) - _fstypes - return - ;; - esac - - [[ "$cur" == \\ ]] && cur="/" - - if [[ "$cur" == *:* ]]; then - for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do - [[ -x $sm ]] || continue - COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \ - awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) ) - return - done - fi - - if [[ "$cur" == //* ]]; then - host=${cur#//} - host=${host%%/*} - if [[ -n $host ]]; then - COMPREPLY=( $( compgen -P "//$host" -W \ - "$( smbclient -d 0 -NL $host 2>/dev/null | - command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | - command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p' )" \ - -- "${cur#//$host}" ) ) - fi - elif [[ -r /etc/vfstab ]]; then - # Solaris - COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- "$cur" ) ) - elif [[ ! -e /etc/fstab ]]; then - # probably Cygwin - COMPREPLY=( $( compgen -W "$( $1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" ) ) - else - # probably BSD - COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab )" -- "$cur" ) ) - fi -} && -complete -F _mount -o default -o dirnames mount - -# ex: filetype=sh diff --git a/completions/mount.linux b/completions/mount.linux deleted file mode 100644 index ed198ad8..00000000 --- a/completions/mount.linux +++ /dev/null @@ -1,245 +0,0 @@ -# mount(8) completion -*- shell-script -*- - -_mount() -{ - local cur prev words cword - _init_completion -n =: || return - - local split=false - case "$prev" in - -t|--types) - # find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1 - # FIXME: no - if [[ "$cur" == ?*,* ]]; then - prev="${cur%,*}" - cur="${cur##*,}" - split=true - fi - COMPREPLY=( $( compgen -W 'auto adfs affs autofs btrfs cifs coda - cramfs davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus - hpfs iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g - proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs - udf ufs umsdos usbfs vfat xfs' -- "$cur" ) ) - _fstypes - $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) - return - ;; - --bind|-B|--rbind|-R) - _filedir -d - return - ;; - -p|--pass-fd) - COMPREPLY=( $(compgen -W '{0..9}') ) - compopt -o nospace - return - ;; - -L) - COMPREPLY=( $( cd "/dev/disk/by-label/" 2>/dev/null || return; \ - compgen -f -- "$cur" ) ) - return - ;; - -U) - COMPREPLY=( $( cd "/dev/disk/by-uuid/" 2>/dev/null || return; \ - compgen -f -- "$cur" ) ) - return - ;; - -O|--test-opts) - # argument required but no completions available - return - ;; - -o|--options) - local fstype=auto # default fstype - for (( i=${#words[@]}-1; i>0; i-- )); do - if [[ "${words[i]}" == -@(t|-types)* ]]; then - if [[ "${words[i]}" == *=* ]]; then - [[ "${words[i]}" == ?*,* ]] && break - fstype="${words[i]#-*=}" - else - [[ "${words[i+1]}" == ?*,* ]] && break - fstype="${words[i+1]}" - fi - break - fi - done - # no is not a real fstype, reset to "auto" - [[ "$fstype" == no?* ]] && fstype=auto - # split options list - if [[ "$cur" == ?*,* ]]; then - prev="${cur%,*}" - cur="${cur##*,}" - split=true - fi - # no completion if $cur is opt=smth - [[ "$cur" == *=* ]] && return - # mount options - COMPREPLY=( $(compgen -W 'loop {,a}sync {,no}atime {,no}auto - {,fs,def,root}context= defaults {,no}dev {,no}diratime dirsync - {,no}exec group {,no}iversion {,no}mand _netdev nofail - {,no}relatime {,no}strictatime {,no}suid owner remount ro rw - {,no}user users' -- "$cur") ) - case "$fstype" in - adfs|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= {own,oth}mask=' -- "$cur") ) - ;;& - affs|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= set{u,g}id= mode= protect - usemp verbose prefix= volume= reserved= root= bs= - {,no,usr,grp}quota' -- "$cur") ) - ;;& - btrfs|auto) - COMPREPLY+=( $(compgen -W 'degraded subvol= subvolid= device= - nodatasum nodatacow nobarrier max_inline= alloc_start= - thread_pool= compress= compress-force= ssd noacl notreelog - flushoncommit metadata_ratio= {,no}space_cache clear_cache - user_subvol_rm_allowed autodefrag inode_cache' -- "$cur") ) - ;;& - cifs|auto) - COMPREPLY+=( $(compgen -W 'user= password= credentials= {u,g}id= - force{u,g}id port= servern= netbiosname= {file,dir}_mode= - ip= domain= guest iocharset {,no}setuids {,no,dyn}perm - directio {,no}mapchars {,no}intr hard soft noacl nocase sec= - nobrl sfu {,no}serverino nounix nouser_xattr {r,w}size= - rwpidforward backup{u,g}id cache=' -- "$cur") ) - ;;& - davfs|auto) - COMPREPLY+=( $(compgen -W 'conf= {file,dir}_mode= {u,g}id= - username=' -- "$cur") ) - ;;& - ext[2-4]|auto) - COMPREPLY+=( $(compgen -W '{,no}acl bsddf minixdf check= debug - errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota - nobh nouid32 oldalloc orlov res{u,g}id= sb= - {,no}user_xattr' -- "$cur") ) - ;;& - ext[34]|auto) - COMPREPLY+=( $(compgen -W 'journal= journal_dev= norecovery - noload data= barrier= commit=' -- "$cur") ) - ;;& - ext4|auto) - COMPREPLY+=( $(compgen -W 'journal_checksum journal_async_commit - nobarrier inode_readahead= stripe= {,no}delalloc abort - {max,min}_batch_time= journal_ioprio= {,no}auto_da_alloc - {,no}discard nouid32 resize {,no}block_validity - dioread_{,no}lock max_dir_size_kb= i_version' -- "$cur") ) - ;;& - msdos|umsdos|vfat|auto) - COMPREPLY+=( $(compgen -W 'blocksize= {u,g}id= {u,d,f}mask= - allow_utime= check= codepage= conv= cvf_format= cvf_option= - debug fat= iocharset= tz= quiet showexec sys_immutable flush - usefree {,no}dots dotsOK=' -- "$cur") ) - ;;& - vfat|auto) - COMPREPLY+=( $(compgen -W 'uni_xlate posix nonumtail utf8 - shortname=' -- "$cur") ) - ;;& - iso9660|auto) - COMPREPLY+=( $(compgen -W 'norock nojoliet check= {u,g}id= map= - mode= unhide block= conv= cruft session= sbsector= - iocharset= utf8' -- "$cur") ) - ;;& - jffs2|auto) - COMPREPLY+=( $(compgen -W 'compr= rp_size=' -- "$cur") ) - ;;& - jfs|auto) - COMPREPLY+=( $(compgen -W 'iocharset= resize= {,no}integrity - errors= {,no,usr,grp}quota' -- "$cur") ) - ;;& - nfs|nfs4|auto) - COMPREPLY+=( $(compgen -W 'soft hard timeo= retrans= {r,w}size= - {,no}ac acreg{min,max}= acdir{min,max}= actimeo= bg fg - retry= sec= {,no}sharecache {,no}resvport lookupcache= - proto= port= {,no}intr {,no}cto {,nfs}vers= ' -- "$cur") ) - ;;& - nfs|auto) - COMPREPLY+=( $(compgen -W 'udp tcp rdma mount{port,proto,host}= - mountvers= namlen={,no}lock {,no}acl {,no}rdirplus - {,no}fsc' -- "$cur") ) - ;;& - nfs4|auto) - COMPREPLY+=( $(compgen -W 'clientaddr= {,no}migration' \ - -- "$cur") ) - ;;& - ntfs-3g) - COMPREPLY+=( $(compgen -W '{u,g}id= {u,f,d}mask= usermapping= - permissions inherit locale= force {,no}recover - ignore_case remove_hiberfile show_sys_files - hide_{hid,dot}_files windows_names allow_other max_read= - silent no_def_opts streams_interface= user_xattr efs_raw - {,no}compression debug no_detach' -- "$cur") ) - ;;& - proc|auto) - COMPREPLY+=( $(compgen -W '{u,g}id=' -- "$cur") ) - ;;& - reiserfs|auto) - COMPREPLY+=( $(compgen -W 'conv hash= {,no_un}hashed_relocation - noborder nolog notail replayonly resize= user_xattr acl - barrier=' -- "$cur") ) - ;;& - tmpfs|auto) - COMPREPLY+=( $(compgen -W 'size= nr_blocks= nr_inodes= mode= - {u,g}id= mpol=' -- "$cur") ) - ;;& - udf|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= umask= unhide undelete - nostrict iocharset bs= novrs session= anchor= volume= - partition= lastblock= fileset= rootdir=' -- "$cur") ) - ;;& - usbfs|auto) - COMPREPLY+=( $(compgen -W 'dev{u,g}id= devmode= bus{u,g}id= - busmode= list{u,g}id= listmode=' -- "$cur") ) - ;;& - xfs|auto) - COMPREPLY+=( $(compgen -W 'allocsize= {,no}attr2 barrier dmapi - {,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep - inode{32,64} {,no}largeio logbufs= logbsize= logdev= - rtdev= mtpt= noalign norecovery nouuid osyncisosync - {u,g,p}qnoenforce {,u,usr,g,grp,p,prj}quota sunit= swidth= - swalloc' -- "$cur") ) - ;;& - esac - # COMP_WORDBREAKS is a real pain in the ass - prev="${prev##*[$COMP_WORDBREAKS]}" - $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - return - ;; - esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version --help --verbose --all --fork - --fake --internal-only -l --no-mtab --no-canonicalize --pass-fd -s - --read-only --rw -L -U --types --test-opts --options --bind --rbind - --move' -- "$cur" ) ) - [[ $COMPREPLY ]] && return - fi - - [[ "$cur" == \\ ]] && cur="/" - - local sm host - - if [[ "$cur" == *:* ]]; then - for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do - [[ -x $sm ]] || continue - COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \ - awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) ) - return - done - fi - - if [[ "$cur" == //* ]]; then - host=${cur#//} - host=${host%%/*} - if [[ -n $host ]]; then - COMPREPLY=( $( compgen -P "//$host" -W \ - "$( smbclient -d 0 -NL $host 2>/dev/null | - command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | - command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p' )" \ - -- "${cur#//$host}" ) ) - fi - fi - - _filedir -} && -complete -F _mount mount - -# ex: filetype=sh diff --git a/completions/mplayer b/completions/mplayer index e43e6c08..525c63e2 100644 --- a/completions/mplayer +++ b/completions/mplayer @@ -3,9 +3,9 @@ _mplayer_options_list() { cur=${cur%\\} - COMPREPLY=( $( compgen -W "$( $1 -noconfig all $2 help 2>/dev/null | \ + COMPREPLY=( $(compgen -W "$($1 -noconfig all $2 help 2>/dev/null | \ command sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' | \ - command sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' )" -- "$cur" ) ) + command sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//')" -- "$cur") ) } _mplayer() @@ -36,7 +36,7 @@ _mplayer() _filedir ttf fi local IFS=$'\n' - COMPREPLY+=( $( compgen -W '$( fc-list 2>/dev/null )' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") ) return ;; -sub|-sub-file) @@ -46,22 +46,22 @@ _mplayer() -vobsub) _filedir '@(idx|ifo|sub)' local IFS=$'\n' - COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do + COMPREPLY=( $(for i in "${COMPREPLY[@]}"; do if [[ -f $i && -r $i ]]; then printf '%s\n' ${i%.*} else printf '%s\n' $i fi - done ) ) + done) ) return ;; -subcp|-msgcharset) local cp - cp=( $( iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null ) ) + cp=( $(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null) ) if [[ "$cur" == "${cur,,}" ]]; then - COMPREPLY=( $( compgen -W '${cp[@],,}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${cp[@],,}' -- "$cur") ) else - COMPREPLY=( $( compgen -W '${cp[@]^^}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${cp[@]^^}' -- "$cur") ) fi return ;; @@ -84,11 +84,10 @@ _mplayer() fi local IFS=$'\n' - for i in ~/.mplayer/skins ${dirs[@]}; do + for i in ~/.mplayer/skins "${dirs[@]}"; do if [[ -d $i && -r $i ]]; then - for j in $( compgen -d -- $i/$cur ); do - COMPREPLY[$k]=${j#$i/} - k=$((++k)) + for j in $(compgen -d -- $i/$cur); do + COMPREPLY[k++]=${j#$i/} done fi done @@ -138,23 +137,23 @@ _mplayer() return ;; -channels) - COMPREPLY=( $( compgen -W '2 4 6 8' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '2 4 6 8' -- "$cur") ) return ;; -aspect|-monitoraspect) - COMPREPLY=( $( compgen -W '1:1 3:2 4:3 5:4 14:9 14:10 16:9 16:10 - 2.35:1' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '1:1 3:2 4:3 5:4 14:9 14:10 16:9 16:10 + 2.35:1' -- "$cur") ) __ltrim_colon_completions "$cur" return ;; -lavdopts) - COMPREPLY=( $( compgen -W 'bitexact bug= debug= ec= er= fast gray + COMPREPLY=( $(compgen -W 'bitexact bug= debug= ec= er= fast gray idct= lowres= sb= st= skiploopfilter= skipidct= skipframe= - threads= vismv= vstats' -- "$cur" ) ) + threads= vismv= vstats' -- "$cur") ) return ;; -lavcopts) - COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= + COMPREPLY=( $(compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= mbqmax= vqdiff= vmax_b_frames= vme= vhq v4mv keyint= vb_strategy= vpass= aspect= vbitrate= vratetol= vrc_maxrate= vrc_minrate= vrc_buf_size= vb_qfactor= vi_qfactor= vb_qoffset= @@ -163,100 +162,99 @@ _mplayer() vpsize= gray vfdct= idct= lumi_mask= dark_mask= tcplx_mask= scplx_mask= naq ildct format= pred qpel precmp= cmp= subcmp= predia= dia= trell last_pred= preme= subq= psnr mpeg_quant aic - umv' -- "$cur" ) ) + umv' -- "$cur") ) return ;; -ssf) - COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= cvs=' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'lgb= cgb= ls= cs= chs= cvs=' -- "$cur") ) return ;; -jpeg) - COMPREPLY=( $( compgen -W 'noprogressive progressive nobaseline - baseline optimize= smooth= quality= outdir=' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'noprogressive progressive nobaseline + baseline optimize= smooth= quality= outdir=' -- "$cur") ) return ;; -xvidopts) - COMPREPLY=( $( compgen -W 'dr2 nodr2' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'dr2 nodr2' -- "$cur") ) return ;; -xvidencopts) - COMPREPLY=( $( compgen -W 'pass= bitrate= fixed_quant= me_quality= + COMPREPLY=( $(compgen -W 'pass= bitrate= fixed_quant= me_quality= 4mv rc_reaction_delay_factor= rc_averaging_period= rc_buffer= quant_range= min_key_interval= max_key_interval= mpeg_quant mod_quant lumi_mask hintedme hintfile debug keyframe_boost= - kfthreshold= kfreduction=' -- "$cur" ) ) + kfthreshold= kfreduction=' -- "$cur") ) return ;; -divx4opts) - COMPREPLY=( $( compgen -W 'br= key= deinterlace q= min_quant= + COMPREPLY=( $(compgen -W 'br= key= deinterlace q= min_quant= max_quant= rc_period= rc_reaction_period= crispness= - rc_reaction_ratio= pass= vbrpass= help' -- "$cur" ) ) + rc_reaction_ratio= pass= vbrpass= help' -- "$cur") ) return ;; -info) - COMPREPLY=( $( compgen -W 'name= artist= genre= subject= - copyright= srcform= comment= help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'name= artist= genre= subject= + copyright= srcform= comment= help' -- "$cur") ) return ;; -lameopts) - COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= ratio= vol= - mode= padding= fast preset= help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'vbr= abr cbr br= q= aq= ratio= vol= + mode= padding= fast preset= help' -- "$cur") ) return ;; -rawaudio) - COMPREPLY=( $( compgen -W 'on channels= rate= samplesize= format=' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on channels= rate= samplesize= format=' \ + -- "$cur") ) return ;; -rawvideo) - COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w= - h= y420 yv12 yuy2 y8 format= size=' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w= + h= y420 yv12 yuy2 y8 format= size=' -- "$cur") ) return ;; -aop) - COMPREPLY=( $( compgen -W 'list= delay= format= fout= volume= mul= - softclip' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'list= delay= format= fout= volume= mul= + softclip' -- "$cur") ) return ;; -dxr2) - COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded iec958-decoded + COMPREPLY=( $(compgen -W 'ar-mode= iec958-encoded iec958-decoded mute ucode= 75ire bw color interlaced macrovision= norm= square-pixel ccir601-pixel cr-left= cr-right= cr-top= cr-bot= ck-rmin= ck-gmin= ck-bmin= ck-rmax= ck-gmax= ck-bmax= ck-r= ck-g= ck-b= ignore-cache= ol-osd= olh-cor= olw-cor= olx-cor= - oly-cor= overlay overlay-ratio= update-cache' -- "$cur" ) ) + oly-cor= overlay overlay-ratio= update-cache' -- "$cur") ) return ;; -tv) - COMPREPLY=( $( compgen -W 'on noaudio driver= device= input= freq= + COMPREPLY=( $(compgen -W 'on noaudio driver= device= input= freq= outfmt= width= height= buffersize= norm= channel= chanlist= audiorate= forceaudio alsa amode= forcechan= adevice= audioid= volume= bass= treble= balance= fps= channels= immediatemode=' \ - -- "$cur" ) ) + -- "$cur") ) return ;; -mf) - COMPREPLY=( $( compgen -W 'on w= h= fps= type=' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on w= h= fps= type=' -- "$cur") ) return ;; -cdda) - COMPREPLY=( $( compgen -W 'speed= paranoia= generic-dev= + COMPREPLY=( $(compgen -W 'speed= paranoia= generic-dev= sector-size= overlap= toc-bias toc-offset= skip noskip' \ - -- "$cur" ) ) + -- "$cur") ) return ;; -input) - COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate keylist cmdlist - js-dev file' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'conf= ar-delay ar-rate keylist cmdlist + js-dev file' -- "$cur") ) return ;; -af-adv) - COMPREPLY=( $( compgen -W 'force= list=' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'force= list=' -- "$cur") ) return ;; -noconfig) - COMPREPLY=( $( compgen -W 'all gui system user' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'all gui system user' -- "$cur") ) return ;; -*) @@ -274,13 +272,13 @@ _mplayer() case $cur in -*) - COMPREPLY=( $( compgen -W '$( $cmd -noconfig all -list-options 2>/dev/null | \ + COMPREPLY=( $(compgen -W '$($cmd -noconfig all -list-options 2>/dev/null | \ command sed -ne '1,/^[[:space:]]*Name/d' \ -e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \ - -e "/^-\(Total\|.*\*\)\{0,1\}$/!p" )' -- "$cur" ) ) + -e "/^-\(Total\|.*\*\)\{0,1\}$/!p")' -- "$cur") ) ;; *) - _filedir '@(m?(j)p?(e)g|M?(J)P?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|mts|MTS|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|web[am]|WEB[AM]|amr|AMR|awb|AWB|iso|ISO|opus|OPUS)?(.part)' + _filedir '@(m?(j)p?(e)g|M?(J)P?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|mts|MTS|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|web[am]|WEB[AM]|amr|AMR|awb|AWB|iso|ISO|opus|OPUS|m[eo]d|M[EO]D|xm|XM|it|IT|s[t3]m|S[T3]M|mtm|MTM|w64|W64)?(.@(crdownload|part))' ;; esac diff --git a/completions/mr b/completions/mr index 9229e309..15f634a3 100644 --- a/completions/mr +++ b/completions/mr @@ -37,18 +37,18 @@ _mr() { ;; clean) if [[ "${cur}" == -* ]]; then - COMPREPLY=( $( compgen -W '-f' -- "${cur}" ) ) + COMPREPLY=( $(compgen -W '-f' -- "${cur}") ) fi return ;; commit|ci|record) if [[ "${cur}" == -* ]]; then - COMPREPLY=( $( compgen -W '-m' -- "${cur}" ) ) + COMPREPLY=( $(compgen -W '-m' -- "${cur}") ) fi return ;; run) - COMPREPLY=( $( compgen -c -- "${cur}" ) ) + COMPREPLY=( $(compgen -c -- "${cur}") ) return ;; *) @@ -60,11 +60,11 @@ _mr() { # Complete top-level options and commands. case $prev in - -c|--config) + --config|-!(-*)c) _filedir return ;; - -d|--directory) + --directory|-!(-*)d) _filedir -d return ;; @@ -76,9 +76,9 @@ _mr() { options="${options//-[a-z]$'\n'/}" # Remove deprecated options. options="${options//--path/}" - COMPREPLY=( $( compgen -W "${options}" -- "${cur}" ) ) + COMPREPLY=( $(compgen -W "${options}" -- "${cur}") ) else - COMPREPLY=( $( compgen -W "${commands}" -- "${cur}" ) ) + COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") ) fi } && complete -F _mr mr diff --git a/completions/msynctool b/completions/msynctool index 3eae1dfa..4fd51618 100644 --- a/completions/msynctool +++ b/completions/msynctool @@ -7,35 +7,35 @@ _msynctool() case $words in --configure) - COMPREPLY=( $( compgen -W "$($1 --showgroup \ + COMPREPLY=( $(compgen -W "$($1 --showgroup \ $prev | awk '/^Member/ {print $2}' | command sed \ - -e 's/:$//' )" -- "$cur" ) ) + -e 's/:$//')" -- "$cur") ) return ;; --addmember) - COMPREPLY=( $( compgen -W '$($1 --listplugins \ - | command sed -e '1d' )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$($1 --listplugins \ + | command sed -e 1d)' -- "$cur") ) return ;; esac case $prev in --configure|--addgroup|--delgroup|--showgroup|--sync|--addmember) - COMPREPLY=( $( compgen -W '$($1 --listgroups \ - | command sed -e '1d' )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$($1 --listgroups \ + | command sed -e 1d)' -- "$cur") ) return ;; --showformats|--filter-objtype|--slow-sync) - COMPREPLY=( $( compgen -W '$($1 --listobjects \ - | command sed -e '1d' )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$($1 --listobjects \ + | command sed -e 1d)' -- "$cur") ) return ;; esac - COMPREPLY=( $( compgen -W '--listgroups --listplugins --listobjects + COMPREPLY=( $(compgen -W '--listgroups --listplugins --listobjects --showformats --showgroup --sync --filter-objtype --slow-sync --wait --multi --addgroup --delgroup --addmember --configure --manual - --configdir --conflict' -- "$cur" ) ) + --configdir --conflict' -- "$cur") ) } && complete -F _msynctool msynctool diff --git a/completions/mtx b/completions/mtx index c52c6173..9266687c 100644 --- a/completions/mtx +++ b/completions/mtx @@ -23,10 +23,10 @@ _mtx() if [[ $cword -gt 1 ]]; then case $prev in load) - COMPREPLY=( $( compgen -W "$tapes" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$tapes" -- "$cur") ) ;; unload|first|last|next) - COMPREPLY=( $( compgen -W "$drives" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$drives" -- "$cur") ) ;; -f) true @@ -36,7 +36,7 @@ _mtx() ;; esac else - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) fi } && complete -F _mtx mtx diff --git a/completions/munin-node-configure b/completions/munin-node-configure index a2021727..1d564d3f 100644 --- a/completions/munin-node-configure +++ b/completions/munin-node-configure @@ -19,13 +19,13 @@ _munin_node_configure() return ;; --snmpversion) - COMPREPLY=( $( compgen -W '1 2c 3' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '1 2c 3' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _munin_node_configure munin-node-configure diff --git a/completions/munin-run b/completions/munin-run index 72228522..6855e02d 100644 --- a/completions/munin-run +++ b/completions/munin-run @@ -17,10 +17,10 @@ _munin_run() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else - COMPREPLY=( $( compgen -W \ - '$( command ls /etc/munin/plugins 2>/dev/null )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(command ls /etc/munin/plugins 2>/dev/null)' -- "$cur") ) fi } && complete -F _munin_run munin-run diff --git a/completions/munin-update b/completions/munin-update index ef8bf5b5..ac770a6b 100644 --- a/completions/munin-update +++ b/completions/munin-update @@ -17,9 +17,9 @@ _munin_update() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--force-root --noforce-root --service --host + COMPREPLY=( $(compgen -W '--force-root --noforce-root --service --host --config --help --debug --nodebug --fork --nofork --stdout - --nostdout --timeout' -- "$cur" ) ) + --nostdout --timeout' -- "$cur") ) fi } && complete -F _munin_update munin-update diff --git a/completions/munindoc b/completions/munindoc index f603d87b..a08399ba 100644 --- a/completions/munindoc +++ b/completions/munindoc @@ -5,8 +5,8 @@ _munindoc() local cur prev words cword _init_completion || return - COMPREPLY=( $( compgen -W \ - '$( command ls /usr/share/munin/plugins 2>/dev/null )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(command ls /usr/share/munin/plugins 2>/dev/null)' -- "$cur") ) } && complete -F _munindoc munindoc diff --git a/completions/mussh b/completions/mussh index 185f9d30..e76817c7 100644 --- a/completions/mussh +++ b/completions/mussh @@ -10,11 +10,11 @@ _mussh() return ;; -d) - COMPREPLY=( $( compgen -W '{0..2}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") ) return ;; -v) - COMPREPLY=( $( compgen -W '{0..3}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) return ;; -i|-H|-C) @@ -26,7 +26,7 @@ _mussh() return ;; -l|-L) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; -s) @@ -39,13 +39,13 @@ _mussh() ;; -c) compopt -o filenames - COMPREPLY+=( $( compgen -c -- "$cur" ) ) + COMPREPLY+=( $(compgen -c -- "$cur") ) return ;; esac [[ $cur != -* ]] || \ - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _mussh mussh diff --git a/completions/mutt b/completions/mutt index 568479ec..43a8842e 100644 --- a/completions/mutt +++ b/completions/mutt @@ -9,7 +9,7 @@ _muttaddr() _muttaliases "$1" _muttquery "$1" - COMPREPLY+=( $( compgen -u -- "$1" ) ) + COMPREPLY+=( $(compgen -u -- "$1") ) } @@ -78,9 +78,9 @@ _muttaliases() [[ -z $muttrc ]] && return conffiles=( $(eval _muttconffiles $muttrc $muttrc) ) - aliases=( $( command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ - $(eval echo "${conffiles[@]}") ) ) - COMPREPLY+=( $( compgen -W "${aliases[*]}" -- "$cur" ) ) + aliases=( $(command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ + $(eval echo "${conffiles[@]}")) ) + COMPREPLY+=( $(compgen -W "${aliases[*]}" -- "$cur") ) } @@ -90,16 +90,16 @@ _muttquery() local cur=$1 querycmd muttcmd=${words[0]} local -a queryresults - querycmd="$( $muttcmd -Q query_command 2>/dev/null | command sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|' )" + querycmd="$($muttcmd -Q query_command 2>/dev/null | command sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|')" if [[ -z "$cur" || -z "$querycmd" ]]; then queryresults=() else __expand_tilde_by_ref querycmd - queryresults=( $( $querycmd | \ - command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p' ) ) + queryresults=( $($querycmd | \ + command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p') ) fi - COMPREPLY+=( $( compgen -W "${queryresults[*]}" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W "${queryresults[*]}" -- "$cur") ) } @@ -110,18 +110,18 @@ _muttfiledir() muttrc=$(_muttrc) if [[ $cur == [=+]* ]]; then - folder="$( $muttcmd -F "$muttrc" -Q folder 2>/dev/null | command sed -e 's|^folder=\"\(.*\)\"$|\1|' )" + folder="$($muttcmd -F "$muttrc" -Q folder 2>/dev/null | command sed -e 's|^folder=\"\(.*\)\"$|\1|')" : folder:=~/Mail # Match any file in $folder beginning with $cur # (minus the leading '=' sign). compopt -o filenames - COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) ) + COMPREPLY=( $(compgen -f -- "$folder/${cur:1}") ) COMPREPLY=( ${COMPREPLY[@]#$folder/} ) return elif [[ $cur == !* ]]; then - spoolfile="$( $muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | \ - command sed -e 's|^spoolfile=\"\(.*\)\"$|\1|' )" + spoolfile="$($muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | \ + command sed -e 's|^spoolfile=\"\(.*\)\"$|\1|')" [[ ! -z $spoolfile ]] && eval cur="${cur/^!/$spoolfile}" fi _filedir @@ -135,21 +135,21 @@ _mutt() case $cur in -*) - COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n -p -Q -R -s - -v -x -y -z -Z -h' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-A -a -b -c -e -f -F -H -i -m -n -p -Q -R -s + -v -x -y -z -Z -h' -- "$cur") ) return ;; *) case $prev in - -a|-f|-F|-H|-i) + -*[afFHi]) _muttfiledir "$cur" return ;; - -A) + -*A) _muttaliases "$cur" return ;; - -e|-m|-Q|-s|-h|-p|-R|-v|-y|-z|-Z) + -*[emQshpRvyzZ]) return ;; *) diff --git a/completions/mypy b/completions/mypy new file mode 100644 index 00000000..82da1f08 --- /dev/null +++ b/completions/mypy @@ -0,0 +1,57 @@ +# mypy completion -*- shell-script -*- + +_mypy() +{ + local cur prev words cword split + _init_completion -s || return + + [[ $cword -gt 2 && ${words[cword-2]} == --shadow-file ]] && \ + prev=--shadow-file # hack; takes two args + + case $prev in + --help|--version|--python-version|--platform|--always-true|\ + --always-false|--find-occurrences|--package|--command|-!(-*)[hVpc]) + return + ;; + --config-file) + _filedir + return + ;; + --follow-imports) + COMPREPLY=( $(compgen -W 'normal silent skip error' -- "$cur") ) + return + ;; + --python-executable) + COMPREPLY=( $(compgen -c -- "${cur:-py}") ) + return + ;; + --*-dir|--*-report) + _filedir -d + return + ;; + --custom-typing|--module|-!(-*)m) + _xfunc python _python_modules + return + ;; + --shadow-file) + _filedir '@(py|pyi)' + return + ;; + --junit-xml) + _filedir xml + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + return + fi + + _filedir '@(py|pyi)' +} && +complete -F _mypy mypy + +# ex: filetype=sh diff --git a/completions/mysql b/completions/mysql index 48fe0e39..ffb4bcd7 100644 --- a/completions/mysql +++ b/completions/mysql @@ -1,31 +1,36 @@ # mysql(1) completion -*- shell-script -*- +_mysql_character_sets() +{ + local IFS=$' \t\n' reset=$(shopt -p failglob); shopt -u failglob + local -a charsets=( /usr/share/m{ariadb,ysql}/charsets/*.xml ) + $reset + charsets=( "${charsets[@]##*/}" ) + charsets=( "${charsets[@]%%?(Index|\*).xml}" utf8 ) + COMPREPLY+=( $(compgen -W '${charsets[@]}' -- "$cur") ) +} + _mysql() { local cur prev words cword split _init_completion -s || return case $prev in - -u|--user) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + --user|-!(-*)u) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; - -D|--database) - COMPREPLY=( $( compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur" ) ) + --database|-!(-*)D) + COMPREPLY=( $(compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur") ) return ;; - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; --default-character-set) - local IFS=$' \t\n' reset=$( shopt -p failglob ); shopt -u failglob - local -a charsets=( /usr/share/m{ariadb,ysql}/charsets/*.xml ) - $reset - charsets=( "${charsets[@]##*/}" ) - charsets=( "${charsets[@]%%?(Index|\*).xml}" utf8 ) - COMPREPLY=( $( compgen -W '${charsets[@]}' -- "$cur" ) ) + _mysql_character_sets return ;; @@ -33,38 +38,45 @@ _mysql() _filedir -d return ;; - -S|--socket) + --socket|-!(-*)S) _filedir sock return ;; --protocol) - COMPREPLY=( $( compgen -W 'tcp socket pipe memory' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'tcp socket pipe memory' -- "$cur") ) return ;; --defaults-file|--defaults-extra-file|--tee) _filedir return ;; - --default-character-set|-P|--port|--set-variable|\ - --ssl-ca|--ssl-cert|--ssl-cipher|--ssl-key|\ - --connect_timeout|--max_allowed_packet|--prompt|\ - --net_buffer_length|--select_limit|--max_join_size|\ - --server-arg|--debug|--delimiter|--execute|-e|--pager) - # Argument required but no completions available + --ssl-ca|--ssl-cert) + _filedir '@(pem|cer|c?(e)rt)' + return + ;; + --ssl-key) + _filedir '@(pem|key)' return ;; - '-?'|-I|--help|-V|--version) - # All other options are noop with these + --port|--set-variable|--ssl-cipher|--connect_timeout|\ + --max_allowed_packet|--prompt|--net_buffer_length|--select_limit|\ + --max_join_size|--server-arg|--debug|--delimiter|--execute|--pager|\ + -!(-*)[Pe]) + return + ;; + --help|--version|-!(-*)[?IV]) return ;; esac + $split && return + case $cur in --*) local help=$(_parse_help "$1") help+=" --skip-comments --skip-ssl" - COMPREPLY=( $( compgen -W "$help" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$help" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return ;; @@ -77,9 +89,9 @@ _mysql() ;; esac - COMPREPLY=( $( compgen -W \ + COMPREPLY=( $(compgen -W \ "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" \ - -- "$cur" ) ) + -- "$cur") ) } && complete -F _mysql mysql diff --git a/completions/mysqladmin b/completions/mysqladmin index bb7ba869..1e34a34d 100644 --- a/completions/mysqladmin +++ b/completions/mysqladmin @@ -6,11 +6,11 @@ _mysqladmin() _init_completion -s || return case $prev in - -u|--user) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + --user|-!(-*)u) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; @@ -18,7 +18,11 @@ _mysqladmin() _filedir -d return ;; - -S|--socket) + --default-character-set) + _xfunc mysql _mysql_character_sets + return + ;; + --socket|-!(-*)S) _filedir sock return ;; @@ -26,26 +30,31 @@ _mysqladmin() _filedir return ;; - -c|--count|--default-character-set|-P|--port|-O|--set-variable|\ - -i|--sleep|--ssl-ca|--ssl-cert|--ssl-cipher|--ssl-key|-w|--wait|\ - --connect_timeout|--shutdown_timeout) - # Argument required but no completions available + --ssl-ca|--ssl-cert) + _filedir '@(pem|cer|c?(e)rt)' + return + ;; + --ssl-key) + _filedir '@(pem|key)' + return + ;; + --count|--port|--set-variable|--sleep|--ssl-cipher|--wait|\ + --connect_timeout|--shutdown_timeout|-!(-*)[cPOiw]) return ;; - '-?'|--help|-V|--version) - # All other options are noop with these + --help|--version|-!(-*)[?V]) return ;; esac $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - COMPREPLY+=( $( compgen -W 'create debug drop extended-status flush-hosts + COMPREPLY+=( $(compgen -W 'create debug drop extended-status flush-hosts flush-logs flush-status flush-tables flush-threads flush-privileges kill password old-password ping processlist reload refresh shutdown - status start-slave stop-slave variables version' -- "$cur" ) ) + status start-slave stop-slave variables version' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && diff --git a/completions/nc b/completions/nc index 63cb9d14..0ba61808 100644 --- a/completions/nc +++ b/completions/nc @@ -3,41 +3,45 @@ _nc() { local cur prev words cword - _init_completion || return + _init_completion -n : || return case $prev in - -h|-I|-i|-O|-P|-p|-V|-w) + -*[hIiMmOPpqVWw]) return ;; - -s) - _ip_addresses + -*s) + if [[ "${words[*]}" == *-6* ]]; then + _ip_addresses -6 + __ltrim_colon_completions "$cur" + else + _ip_addresses + fi return ;; - -T) - COMPREPLY=( $( compgen -W 'critical inetcontrol lowdelay netcontrol - throughput reliability ef af{11..43} cs{0..7}' -- "$cur" ) ) + -*T) + COMPREPLY=( $(compgen -W 'critical inetcontrol lowcost lowdelay + netcontrol throughput reliability ef af{11..43} cs{0..7}' \ + -- "$cur") ) return ;; - -X) - COMPREPLY=( $( compgen -W '4 5 connect' -- "$cur" ) ) + -*X) + COMPREPLY=( $(compgen -W '4 5 connect' -- "$cur") ) return ;; - -x) + -*x) _known_hosts_real -- "$cur" return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) return fi # Complete 1st non-option arg only - local i - for (( i=1; i < cword; i++ )); do - [[ ${words[i]} != -* && ${words[i-1]} != -[IiOPpsTVwXx] ]] && return - done + local args; _count_args "" "-*[IiMmOPpqsTVWwXx]" + [[ $args -eq 1 ]] || return _known_hosts_real -- "$cur" } && diff --git a/completions/ncftp b/completions/ncftp index 4c073ce6..35146f3c 100644 --- a/completions/ncftp +++ b/completions/ncftp @@ -12,13 +12,13 @@ _ncftp() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) return fi if [[ $cword -eq 1 && -f ~/.ncftp/bookmarks ]]; then - COMPREPLY=( $( compgen -W '$( command sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ - ~/.ncftp/bookmarks )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(command sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ + ~/.ncftp/bookmarks)' -- "$cur") ) fi } && diff --git a/completions/nethogs b/completions/nethogs index 8eeb4ff5..85fc1cb4 100644 --- a/completions/nethogs +++ b/completions/nethogs @@ -8,14 +8,14 @@ _nethogs() case "$prev" in -d) # expect integer value - COMPREPLY+=( $( compgen -W '{0..9}' ) ) + COMPREPLY+=( $(compgen -W '{0..9}') ) compopt -o nospace return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h)' -- "$cur") ) return fi diff --git a/completions/newlist b/completions/newlist index 04bf17d1..793928c3 100644 --- a/completions/newlist +++ b/completions/newlist @@ -14,7 +14,7 @@ _newlist() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _xfunc list_lists _mailman_lists diff --git a/completions/newusers b/completions/newusers index 068b7a92..b7792b54 100644 --- a/completions/newusers +++ b/completions/newusers @@ -7,8 +7,7 @@ _newusers() case $prev in -c|--crypt) - COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'DES MD5 NONE SHA256 SHA512' -- "$cur") ) return ;; -s|--sha-rounds) @@ -19,7 +18,7 @@ _newusers() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/ngrep b/completions/ngrep index bbfbbd2f..65f4dc6d 100644 --- a/completions/ngrep +++ b/completions/ngrep @@ -10,15 +10,16 @@ _ngrep() return ;; -I|-O) - _filedir pcap + _filedir 'pcap?(ng)' return ;; -d) _available_interfaces -a + COMPREPLY+=( $(compgen -W 'any' -- "$cur") ) return ;; -W) - COMPREPLY=( $( compgen -W 'normal byline single none' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'normal byline single none' -- "$cur") ) return ;; -F) @@ -28,7 +29,7 @@ _ngrep() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) return fi } && diff --git a/completions/nmap b/completions/nmap index c56c7210..b4e76baf 100644 --- a/completions/nmap +++ b/completions/nmap @@ -25,7 +25,7 @@ _nmap() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-iL -iR --exclude --excludefile -sL -sP -PN + COMPREPLY=( $(compgen -W '-iL -iR --exclude --excludefile -sL -sP -PN -PS -PA -PU -PY -PE -PP -PM -PO -n -R --dns-servers --system-dns --traceroute -sS -sT -sA -sW -sM -sU -sN -sF -sX --scanflags -sI -sY -sZ -sO -b -p -F -r --top-ports --port-ratio -sV @@ -40,7 +40,7 @@ _nmap() -oA -v -d --reason --open --packet-trace --iflist --log-errors --append-output --resume --stylesheet --webxml --no-stylesheet -6 -A --datadir --send-eth --send-ip --privilege--unprivileged -V - -h' -- "$cur" ) ) + -h' -- "$cur") ) else _known_hosts_real -- "$cur" fi diff --git a/completions/nproc b/completions/nproc index 8903940e..84092679 100644 --- a/completions/nproc +++ b/completions/nproc @@ -14,8 +14,10 @@ _nproc() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && complete -F _nproc nproc + +# ex: filetype=sh diff --git a/completions/nslookup b/completions/nslookup index 65770629..267d0c30 100644 --- a/completions/nslookup +++ b/completions/nslookup @@ -2,15 +2,15 @@ _bind_queryclass() { - COMPREPLY+=( $( compgen -W 'IN CH HS ANY' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W 'IN CH HS ANY' -- "$cur") ) } _bind_querytype() { # http://en.wikipedia.org/wiki/List_of_DNS_record_types - COMPREPLY+=( $( compgen -W 'A AAAA AFSDB APL CERT CNAME DHCID DLV DNAME + COMPREPLY+=( $(compgen -W 'A AAAA AFSDB APL CERT CNAME DHCID DLV DNAME DNSKEY DS HIP IPSECKEY KEY KX LOC MX NAPTR NS NSEC NSEC3 NSEC3PARAM PTR - RRSIG RP SIG SOA SPF SRV SSHFP TXT' -- "$cur" ) ) + RRSIG RP SIG SOA SPF SRV SSHFP TXT' -- "$cur") ) } _nslookup() @@ -35,9 +35,9 @@ _nslookup() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-all -class= -debug -nodebug -d2 -nod2 + COMPREPLY=( $(compgen -W '-all -class= -debug -nodebug -d2 -nod2 -domain= -search -nosearch -port= -querytype= -recurse -norecurse - -retry= -timeout= -vc -novc -fail -nofail' -- "$cur" ) ) + -retry= -timeout= -vc -novc -fail -nofail' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -66,7 +66,7 @@ _host() return ;; -m) - COMPREPLY=( $( compgen -W 'trace record usage' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'trace record usage' -- "$cur") ) return ;; -N|-R|-W) @@ -75,7 +75,7 @@ _host() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi diff --git a/completions/nsupdate b/completions/nsupdate new file mode 100644 index 00000000..ff3b9a47 --- /dev/null +++ b/completions/nsupdate @@ -0,0 +1,40 @@ +# bash completion for nsupdate(1) -*- shell-script -*- + +_nsupdate() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -*[VLprtu]) + return + ;; + -*k) + _filedir key + return + ;; + -*R) + cur=${cur:=/dev/} + _filedir + return + ;; + -*y) + if [[ $cur == h* ]]; then + COMPREPLY=( $(compgen -W "hmac-{md5,sha{1,224,256,384,512}}" \ + -S : -- "$cur") ) + [[ $COMPREPLY == *: ]] && compopt -o nospace + fi + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + return + fi + + _filedir +} && +complete -F _nsupdate nsupdate + +# ex: filetype=sh diff --git a/completions/ntpdate b/completions/ntpdate index ff0c9f00..5291336c 100644 --- a/completions/ntpdate +++ b/completions/ntpdate @@ -6,26 +6,26 @@ _ntpdate() _init_completion || return case $prev in - -k) + -*k) _filedir return ;; - -U) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + -*U) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; - -p) - COMPREPLY=( $( compgen -W '{1..8}' -- "$cur" ) ) + -*p) + COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") ) return ;; - -a|-e|-o|-t) + -*[aeot]) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _known_hosts_real -- "$cur" fi diff --git a/completions/oggdec b/completions/oggdec index 0493087d..9bdf5019 100644 --- a/completions/oggdec +++ b/completions/oggdec @@ -6,18 +6,18 @@ _oggdec() _init_completion -s || return case $prev in - --help|-h|--version|-V) + --help|--version|-!(-*)[hV]*) return ;; - --bits|-b) - COMPREPLY=( $( compgen -W "8 16" -- "$cur" ) ) + --bits|-!(-*)b) + COMPREPLY=( $(compgen -W "8 16" -- "$cur") ) return ;; - --endianness|-e|--sign|-s) - COMPREPLY=( $( compgen -W "0 1" -- "$cur" ) ) + --endianness|--sign|-!(-*)[es]) + COMPREPLY=( $(compgen -W "0 1" -- "$cur") ) return ;; - --output|-o) + --output|-!(-*)o) _filedir wav return ;; @@ -26,7 +26,7 @@ _oggdec() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/op b/completions/op new file mode 100644 index 00000000..b99bd2de --- /dev/null +++ b/completions/op @@ -0,0 +1,56 @@ +# op (1Password CLI) completion -*- shell-script -*- + +_op_commands() +{ + "$@" --help | + awk "/^(Available |Sub)commands/{flag=1;next}/^ /&&flag{print \$1}" +} + +_op_command_options() +{ + case $cur in + -*) + for i in "${!words[@]}"; do + [[ ${words[i]} == -* || $i -eq 0 ]] && unset words[i] + done + COMPREPLY=( $(compgen -W \ + '$(_parse_usage "$1" "${words[*]} --help") --help' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return 0 + ;; + esac + return 1 +} + +_op() +{ + local cur prev words cword split + _init_completion -s || return + + local command i + for (( i=1; i < cword; i++ )); do + case ${words[i]} in + --help|--version) return ;; + -*) ;; + *) command=${words[i]}; break ;; + esac + done + + if [[ -z $command && $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + [[ $command ]] && _op_command_options "$1" && return + + if [[ -z $command || $command == $prev ]]; then + COMPREPLY=( $(compgen -W '$(_op_commands "$1" $command)' -- "$cur") ) + [[ $COMPREPLY ]] && return + fi + + # TODO specific command and subcommand completions +} && +complete -F _op op + +# ex: filetype=sh diff --git a/completions/openssl b/completions/openssl index 73e56a44..50300a43 100644 --- a/completions/openssl +++ b/completions/openssl @@ -22,8 +22,7 @@ _openssl_sections() [[ ! -f $config ]] && return - COMPREPLY=( $( compgen -W "$( awk '/\[.*\]/ {print $2}' $config )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(awk '/\[.*\]/ {print $2}' $config)" -- "$cur") ) } _openssl_digests() @@ -53,7 +52,7 @@ _openssl() sha224 sha256 sha384 sha512 genpkey pkey pkeyparam pkeyutl' if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) else command=${words[1]} case $prev in @@ -87,7 +86,7 @@ _openssl() formats+=" ENGINE" ;; esac - COMPREPLY=( $( compgen -W "$formats" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$formats" -- "$cur") ) return ;; -connect) @@ -95,16 +94,15 @@ _openssl() return ;; -starttls) - COMPREPLY=( $( compgen -W 'smtp pop3 imap ftp' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'smtp pop3 imap ftp' -- "$cur") ) return ;; -cipher) - COMPREPLY=( $( IFS=: compgen -W "$( $1 ciphers )" \ - -- "$cur" ) ) + COMPREPLY=( $(IFS=: compgen -W "$($1 ciphers)" -- "$cur") ) return ;; -kdf) - COMPREPLY=( $( compgen -W 'TLS1-PRF HKDF' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'TLS1-PRF HKDF' -- "$cur") ) return ;; esac @@ -137,7 +135,7 @@ _openssl() ;; dgst) options="-c -d -hex -binary -out -sign -verify -prverify - -signature $( _openssl_digests $1 )" + -signature $(_openssl_digests $1)" ;; dsa) options='-inform -outform -in -passin -out -passout -des @@ -189,7 +187,7 @@ _openssl() req) options="-inform -outform -in -passin -out -passout -text -noout -verify -modulus -new -rand -newkey -newkey - -nodes -key -keyform -keyout $( _openssl_digests $1 ) + -nodes -key -keyform -keyout $(_openssl_digests $1) -config -x509 -days -asn1-kludge -newhdr -extensions -reqexts section" ;; @@ -248,19 +246,19 @@ _openssl() -clrtrust -clrreject -addtrust -addreject -setalias -days -set_serial -signkey -x509toreq -req -CA -CAkey -CAcreateserial -CAserial -text -C -clrext - -extfile -extensions -engine $( _openssl_digests $1 )" + -extfile -extensions -engine $(_openssl_digests $1)" ;; md*|sha*|ripemd160) options='-c -d' ;; esac - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) else if [[ "$command" == speed ]]; then - COMPREPLY=( $( compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 + COMPREPLY=( $(compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 idea-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 rsa512 rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 idea - rc2 des rsa blowfish' -- "$cur" ) ) + rc2 des rsa blowfish' -- "$cur") ) else _filedir fi diff --git a/completions/opera b/completions/opera index 26343c62..dc0859ea 100644 --- a/completions/opera +++ b/completions/opera @@ -16,14 +16,14 @@ _opera() return ;; ?(-)-remote) - COMPREPLY=( $( compgen -W 'openURL\\( openFile\\( openM2\\( + COMPREPLY=( $(compgen -W 'openURL\\( openFile\\( openM2\\( openComposer\\( addBookmark\\( raise\\(\\) lower\\(\\)' \ - -- "$cur" ) ) + -- "$cur") ) [[ $COMPREPLY == *\( ]] && compopt -o nospace return ;; ?(-)-windowname) - COMPREPLY=( $( compgen -W 'first last opera{1..9}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'first last opera{1..9}' -- "$cur") ) return ;; ?(-)-geometry|?(-)-window|?(-)-display|?(-)-urllistloadtimeout|\ @@ -35,7 +35,7 @@ _opera() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/optipng b/completions/optipng index 7c614abe..22889bf4 100644 --- a/completions/optipng +++ b/completions/optipng @@ -10,7 +10,7 @@ _optipng() return ;; -o) - COMPREPLY=( $( compgen -W '{0..7}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") ) return ;; -out|-log) @@ -22,26 +22,26 @@ _optipng() return ;; -i) - COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) return ;; -zc|-zm) - COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) return ;; -zw) - COMPREPLY=( $( compgen -W '256 512 1k 2k 4k 8k 16k 32k' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '256 512 1k 2k 4k 8k 16k 32k' \ + -- "$cur") ) return ;; -strip) - COMPREPLY=( $( compgen -W 'all' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'all' -- "$cur") ) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/p4 b/completions/p4 index beea4687..e383c8cf 100644 --- a/completions/p4 +++ b/completions/p4 @@ -9,22 +9,22 @@ _p4() local p4commands p4filetypes # rename isn't really a command - p4commands="$( p4 help commands 2>/dev/null | awk 'NF>3 {print $1}' )" + p4commands="$(p4 help commands 2>/dev/null | awk 'NF>3 {print $1}')" p4filetypes="ctext cxtext ktext kxtext ltext tempobj ubinary \ uresource uxbinary xbinary xltext xtempobj xtext \ text binary resource" if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W "$p4commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$p4commands" -- "$cur") ) elif [[ $cword -eq 2 ]]; then case $prev in help) - COMPREPLY=( $( compgen -W "simple commands environment + COMPREPLY=( $(compgen -W "simple commands environment filetypes jobview revisions usage views $p4commands" \ - -- "$cur" ) ) + -- "$cur") ) ;; admin) - COMPREPLY=( $( compgen -W "checkpoint stop" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "checkpoint stop" -- "$cur") ) ;; *) ;; @@ -34,7 +34,7 @@ _p4() -t) case ${words[$cword-2]} in add|edit|reopen) - COMPREPLY=( $( compgen -W "$p4filetypes" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$p4filetypes" -- "$cur") ) ;; *) ;; diff --git a/completions/pack200 b/completions/pack200 index 37c57749..f35840b0 100644 --- a/completions/pack200 +++ b/completions/pack200 @@ -12,19 +12,19 @@ _pack200() return ;; -E|--effort) - COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") ) return ;; -H|--deflate-hint) - COMPREPLY=( $( compgen -W 'true false keep' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'true false keep' -- "$cur") ) return ;; -m|--modification-time) - COMPREPLY=( $( compgen -W 'latest keep' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'latest keep' -- "$cur") ) return ;; -U|--unknown-attribute) - COMPREPLY=( $( compgen -W 'error strip pass' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'error strip pass' -- "$cur") ) return ;; -f|--config-file) @@ -32,7 +32,7 @@ _pack200() return ;; -l|--log-file) - COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-' -- "$cur") ) _filedir log return ;; @@ -54,13 +54,13 @@ _pack200() done if ! $pack ; then - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '--no-gzip --gzip --strip-debug + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '--no-gzip --gzip --strip-debug --no-keep-file-order --segment-limit= --effort= --deflate-hint= --modification-time= --pass-file= --unknown-attribute= --class-attribute= --field-attribute= --method-attribute= --code-attribute= --config-file= --verbose --quiet --log-file= - --help --version -J --repack' -- "$cur" ) ) + --help --version -J --repack' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir 'pack?(.gz)' diff --git a/completions/passwd b/completions/passwd index ce6d4c0e..5a1e5629 100644 --- a/completions/passwd +++ b/completions/passwd @@ -6,13 +6,14 @@ _passwd() _init_completion || return case $prev in - -n|--minimum|-x|--maximum|-w|--warning|-i|--inactive|-\?|--help|--usage) + --minimum|--maximum|--warning|--inactive|--help|--usage|-!(-*)[nxwi?]) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) return fi diff --git a/completions/patch b/completions/patch index 1a9edca1..df85211d 100644 --- a/completions/patch +++ b/completions/patch @@ -6,42 +6,42 @@ _patch() _init_completion -s || return case $prev in - -p|--strip|-D|--ifdef|-B|--prefix|-Y|--basename-prefix|-z|--suffix|\ - -g|--get) + --strip|--ifdef|--prefix|--basename-prefix|--suffix|--get|\ + -!(-*)[pDBYzg]) return ;; - -F|--fuzz) - COMPREPLY=( $( compgen -W '{0..3}' -- "$cur" ) ) + --fuzz|-!(-*)F) + COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) return ;; - -i|--input) + --input|-!(-*)i) _filedir '@(?(d)patch|dif?(f))' return ;; - -o|--output|-r|--reject-file) + --output|--reject-file|-!(-*)[or]) [[ ! $cur || $cur == - ]] && COMPREPLY=( - ) _filedir return ;; --quoting-style) - COMPREPLY=( $( compgen -W 'literal shell shell-always c escape' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'literal shell shell-always c escape' \ + -- "$cur") ) return ;; - -V|--version-control) - COMPREPLY=( $( compgen -W 'simple numbered existing' -- "$cur" ) ) + --version-control|-!(-*)V) + COMPREPLY=( $(compgen -W 'simple numbered existing' -- "$cur") ) return ;; - -d|--directory) + --directory|-!(-*)d) _filedir -d return ;; --reject-format) - COMPREPLY=( $( compgen -W 'context unified' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'context unified' -- "$cur") ) return ;; --read-only) - COMPREPLY=( $( compgen -W 'ignore warn fail' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'ignore warn fail' -- "$cur") ) return ;; esac @@ -49,7 +49,7 @@ _patch() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/pdftotext b/completions/pdftotext index aed6b2c2..79c837e0 100644 --- a/completions/pdftotext +++ b/completions/pdftotext @@ -10,24 +10,24 @@ _pdftotext() return ;; -enc) - COMPREPLY=( $( compgen -W '$( "$1" -listenc 2>/dev/null | - command sed -e 1d )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$("$1" -listenc 2>/dev/null | + command sed -e 1d)' -- "$cur") ) return ;; -eol) - COMPREPLY=( $( compgen -W "unix dos mac" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "unix dos mac" -- "$cur") ) return ;; esac if [[ $cur == -* && ${prev,,} != *.pdf ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi case ${prev,,} in -|*.txt) ;; - *.pdf) COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) ; _filedir txt ;; + *.pdf) COMPREPLY=( $(compgen -W '-' -- "$cur") ) ; _filedir txt ;; *) _filedir pdf ;; esac } && diff --git a/completions/perl b/completions/perl index 250039ee..98ddb9eb 100644 --- a/completions/perl +++ b/completions/perl @@ -2,9 +2,9 @@ _perl_helper() { - COMPREPLY=( $( compgen -P "$prefix" -W \ - "$( ${2:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl $1 $cur )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -P "$prefix" -W \ + "$(${2:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl $1 $cur)" \ + -- "$cur") ) [[ $1 == functions ]] || __ltrim_colon_completions "$prefix$cur" } @@ -30,35 +30,35 @@ _perl() fi case $prev in - -D|-e|-E|-i|-F|-l) + -*[DeEiFl]) return ;; - -I|-x) + -*[Ix]) local IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -d $optPrefix $optSuffix -- "$cur" ) ) + COMPREPLY=( $(compgen -d $optPrefix $optSuffix -- "$cur") ) return ;; - -m|-M) + -*[mM]) temp="${cur#-}" prefix+="${cur%$temp}" cur="$temp" _perl_helper modules $1 return ;; - -V) + -*V) if [[ $cur == :* ]]; then temp="${cur##+(:)}" prefix+="${cur%$temp}" local IFS=$'\n' - COMPREPLY=( $( compgen -P "$prefix" -W \ - '$( $1 -MConfig -e "print join \"\\n\", - keys %Config::Config" 2>/dev/null )' -- "$temp" ) ) + COMPREPLY=( $(compgen -P "$prefix" -W \ + '$($1 -MConfig -e "print join \"\\n\", + keys %Config::Config" 2>/dev/null)' -- "$temp") ) __ltrim_colon_completions "$prefix$temp" fi return ;; - -d|-dt) + -*d|-*dt) if [[ $cur == :* ]]; then temp="${cur#:}" prefix="$prefix${cur%$temp}" @@ -69,8 +69,8 @@ _perl() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p - -n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p + -n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur") ) else _filedir fi @@ -96,31 +96,31 @@ _perldoc() [[ $perl == $1 ]] || ! type $perl &>/dev/null && perl= case $prev in - -h|-V|-n|-o|-M|-w|-L) + -*[hVnoMwL]) return ;; - -d) + -*d) _filedir return ;; - -f) + -*f) _perl_helper functions $perl return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) else # return available modules (unless it is clearly a file) if [[ "$cur" != @(*/|[.~])* ]]; then _perl_helper perldocs $perl if [[ $cur == p* ]]; then - COMPREPLY+=( $( compgen -W \ - '$( PERLDOC_PAGER=cat "$1" -u perl | \ - command sed -ne "/perl.*Perl overview/,/perlwin32/p" | \ - awk "\$NF=2 && \$1 ~ /^perl/ { print \$1 }" )' \ - -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + '$(PERLDOC_PAGER=cat "$1" -u perl | \ + command sed -ne "/perl.*Perl overview/,/perlwin32/p" | \ + awk "\$NF=2 && \$1 ~ /^perl/ { print \$1 }")' \ + -- "$cur") ) fi fi _filedir 'p@([lm]|od)' diff --git a/completions/perlcritic b/completions/perlcritic new file mode 100644 index 00000000..d9a4063d --- /dev/null +++ b/completions/perlcritic @@ -0,0 +1,51 @@ +# perlcritic(1) completion -*- shell-script -*- + +_perlcritic() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--version|--top|--include|--exclude|--single-policy|\ + --colo?(u)r-severity-*|--program-extensions|-[?HVs]) + return + ;; + --severity) + COMPREPLY=( $(compgen -W "{1..5} brutal cruel harsh stern gentle" \ + -- "$cur") ) + return + ;; + --profile|-p) + _filedir perlcriticrc + return + ;; + --theme) + COMPREPLY=( $(compgen -W '$("$1" --list-themes 2>/dev/null)' \ + -- "$cur") ) + return + ;; + --profile-strictness) + COMPREPLY=( $(compgen -W 'warn fatal quiet' -- "$cur") ) + return + ;; + --verbose) + COMPREPLY=( $(compgen -W '{1..11}' -- "$cur") ) + return + ;; + --pager) + compopt -o filenames + COMPREPLY=( $(compgen -c -- "$cur") ) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + return + fi + + _filedir 'p[lm]' +} && +complete -F _perlcritic perlcritic + +# ex: filetype=sh diff --git a/completions/perltidy b/completions/perltidy index 10c49cab..ce93b2a5 100644 --- a/completions/perltidy +++ b/completions/perltidy @@ -22,20 +22,20 @@ _perltidy() return ;; -ole=*) - COMPREPLY=( $( compgen -W 'dos win mac unix' -- "${cur#*=}" ) ) + COMPREPLY=( $(compgen -W 'dos win mac unix' -- "${cur#*=}") ) return ;; -bt=*|-pt=*|-sbt=*|-bvt=*|-pvt=*|-sbvt=*|-bvtc=*|-pvtc=*|-sbvtc=*|\ -cti=*|-kbl=*|-vt=*) - COMPREPLY=( $( compgen -W '0 1 2' -- "${cur#*=}" ) ) + COMPREPLY=( $(compgen -W '0 1 2' -- "${cur#*=}") ) return ;; -vtc=*) - COMPREPLY=( $( compgen -W '0 1' -- "${cur#*=}" ) ) + COMPREPLY=( $(compgen -W '0 1' -- "${cur#*=}") ) return ;; -cab=*) - COMPREPLY=( $( compgen -W '0 1 2 3' -- "${cur#*=}" ) ) + COMPREPLY=( $(compgen -W '0 1 2 3' -- "${cur#*=}") ) return ;; -*=) @@ -44,10 +44,12 @@ _perltidy() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir 'p[lm]' fi } && complete -F _perltidy perltidy + +# ex: filetype=sh diff --git a/completions/pgrep b/completions/pgrep index 82985acf..e45d7d7f 100644 --- a/completions/pgrep +++ b/completions/pgrep @@ -6,41 +6,41 @@ _pgrep() _init_completion || return case $prev in - -c|-d|--delimiter|-g|--pgroup|-J|-M|-N|-s|--session|-t|--terminal|-T|-z) + --delimiter|--pgroup|--session|--terminal|-!(-*)[cdgJMNstTz]) return ;; --signal) _signals return ;; - -F|--pidfile) + --pidfile|-!(-*)F) _filedir return ;; - -G|--group) + --group|-!(-*)G) _gids return ;; -j) - COMPREPLY=( $( compgen -W 'any none' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'any none' -- "$cur") ) return ;; - -P|--parent) + --parent|-!(-*)P) _pids return ;; - -u|--euid|-U|--uid) + --euid|--uid|-!(-*)[uU]) _uids return ;; esac if [[ $cur == -* ]]; then - local help='$( _parse_help "$1" )' - [[ $help ]] || help='$( "$1" --usage 2>&1 | + local help='$(_parse_help "$1")' + [[ $help ]] || help='$("$1" --usage 2>&1 | command sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//" | - _parse_usage - )' - COMPREPLY=( $( compgen -W "$help" -- "$cur" ) ) + _parse_usage -)' + COMPREPLY=( $(compgen -W "$help" -- "$cur") ) [[ $cword -eq 1 && $1 == *pkill ]] && _signals - return fi diff --git a/completions/pidof b/completions/pidof index 223e25d4..9e5c012b 100644 --- a/completions/pidof +++ b/completions/pidof @@ -6,17 +6,17 @@ _pidof() _init_completion || return case $prev in - -h|--help|-V|--version) + --help|-V|--version|-!(-*)[hV]*) return ;; - -o|--omit-pid) + --omit-pid|-!(-*)o) _pids return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/pine b/completions/pine index d99a3808..bf6056e0 100644 --- a/completions/pine +++ b/completions/pine @@ -14,17 +14,17 @@ _pine() return ;; -sort) - COMPREPLY=( $( compgen -W 'arrival subject threaded orderedsubject + COMPREPLY=( $(compgen -W 'arrival subject threaded orderedsubject date from size score to cc' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) else - COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook \ - 2>/dev/null)' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(awk "{print \$1}" ~/.addressbook \ + 2>/dev/null)' -- "$cur") ) fi } && complete -F _pine pine alpine diff --git a/completions/ping b/completions/ping index cc1bca7a..d611ae87 100644 --- a/completions/ping +++ b/completions/ping @@ -8,54 +8,58 @@ _ping() local ipvx case $prev in - -c|-F|-G|-g|-h|-i|-l|-m|-P|-p|-s|-t|-V|-W|-w|-z) + -*[cFGghilmPpstVWwz]) return ;; - -I) + -*I) _available_interfaces -a return ;; - -M) + -*M) # Path MTU strategy in Linux, mask|time in FreeBSD local opts="do want dont" [[ $OSTYPE == *bsd* ]] && opts="mask time" - COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$opts' -- "$cur") ) return ;; - -N) + -*N) if [[ $cur != *= ]]; then - COMPREPLY=( $( compgen -W 'name ipv6 ipv6-global ipv6-sitelocal + COMPREPLY=( $(compgen -W 'name ipv6 ipv6-global ipv6-sitelocal ipv6-linklocal ipv6-all ipv4 ipv4-all subject-ipv6= - subject-ipv4= subject-name= subject-fqdn=' -- "$cur" ) ) + subject-ipv4= subject-name= subject-fqdn=' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi return ;; - -Q) + -*Q) # TOS in Linux, "somewhat quiet" (no args) in FreeBSD if [[ $OSTYPE != *bsd* ]]; then - COMPREPLY=( $( compgen -W '{0..7}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") ) return fi ;; - -S) + -*S) # Socket sndbuf in Linux, source IP in FreeBSD [[ $OSTYPE == *bsd* ]] && _ip_addresses return ;; - -T) + -*T) # Timestamp option in Linux, TTL in FreeBSD [[ $OSTYPE == *bsd* ]] || \ - COMPREPLY=( $( compgen -W 'tsonly tsandaddr' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'tsonly tsandaddr' -- "$cur") ) return ;; - -4|-6) - ipvx=$prev + -*4*) + ipvx=-4 + ;; + -*6*) + ipvx=-6 ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) return fi diff --git a/completions/pkg-config b/completions/pkg-config index a537d497..57191370 100644 --- a/completions/pkg-config +++ b/completions/pkg-config @@ -15,9 +15,9 @@ _pkg_config() local i for (( i=1; i < ${#words[@]}; i++ )); do if [[ ${words[i]} != -* ]]; then - COMPREPLY=( $( compgen -W \ - '$( "$1" ${words[i]} --print-variables 2>/dev/null )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$("$1" ${words[i]} --print-variables 2>/dev/null)' \ + -- "$cur") ) break fi done @@ -32,11 +32,12 @@ _pkg_config() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else - COMPREPLY=( $( compgen -W "$( $1 --list-all \ - 2>/dev/null | awk '{print $1}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 --list-all \ + 2>/dev/null | awk '{print $1}')" -- "$cur") ) + _filedir pc fi } && complete -F _pkg_config pkg-config diff --git a/completions/pkg-get b/completions/pkg-get index d5382eb2..ea300b8b 100644 --- a/completions/pkg-get +++ b/completions/pkg-get @@ -38,8 +38,7 @@ _pkg_get() i=${#COMP_WORDS[*]} while [[ $i -gt 0 ]]; do - i=$((i-1)) - if [[ "${COMP_WORDS[$i]}" == -s ]]; then + if [[ "${COMP_WORDS[--i]}" == -s ]]; then url="${COMP_WORDS[$((i+1))]}" fi if [[ "${COMP_WORDS[$i]}" == @(-[aDdiUu]|available|describe|download|install|list|updatecatalog|upgrade) ]]; then @@ -58,7 +57,7 @@ _pkg_get() return fi - if [[ ${cur} == -* ]] ; then + if [[ ${cur} == -* ]]; then local opts="-c -d -D -f -i -l -s -S -u -U -v" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return diff --git a/completions/pkg_delete b/completions/pkg_delete index 9125829d..b1a93c20 100644 --- a/completions/pkg_delete +++ b/completions/pkg_delete @@ -11,7 +11,7 @@ _pkg_delete() [[ "$prev" == -o || "$prev" == -p || "$prev" == -W ]] && return - COMPREPLY=( $( compgen -d -- "$pkgdir$cur" ) ) + COMPREPLY=( $(compgen -d -- "$pkgdir$cur") ) COMPREPLY=( ${COMPREPLY[@]#$pkgdir} ) } && diff --git a/completions/pkgadd b/completions/pkgadd index 009f3a25..576b4114 100644 --- a/completions/pkgadd +++ b/completions/pkgadd @@ -35,7 +35,7 @@ _pkgadd () -P|-k|-x) ;; *) - if [[ ${cur} == -* ]] ; then + if [[ ${cur} == -* ]]; then local opts="-a -A -d -k -n -M -P -r -R -s -v -V -x" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) else diff --git a/completions/pkgrm b/completions/pkgrm index 891507f8..ef3b2a8d 100644 --- a/completions/pkgrm +++ b/completions/pkgrm @@ -13,7 +13,7 @@ _pkgrm () local spool=/var/sadm/pkg local i=$cword while [[ $((i--)) -gt 0 ]]; do - i=$((i-1)) + (( i-- )) case "${words[$i]}" in -s) spool="${words[$((i+1))]}" diff --git a/completions/pkgtool b/completions/pkgtool index 95d42aaa..8bea9cdd 100644 --- a/completions/pkgtool +++ b/completions/pkgtool @@ -15,7 +15,7 @@ _pkgtool() return ;; --source_device) - COMPREPLY=( $( compgen -f -d -- "${cur:-/dev/}" ) ) + COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") ) return ;; --tagfile) @@ -25,9 +25,9 @@ _pkgtool() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--sets --ignore-tagfiles --tagfile + COMPREPLY=( $(compgen -W '--sets --ignore-tagfiles --tagfile --source-mounted --source_dir --target_dir --source_device' \ - -- "$cur" ) ) + -- "$cur") ) fi } && complete -F _pkgtool pkgtool diff --git a/completions/pkgutil b/completions/pkgutil index 4b2fcdcd..bafb9aab 100644 --- a/completions/pkgutil +++ b/completions/pkgutil @@ -66,7 +66,7 @@ _pkgutil() if [[ -n "$command" ]] && [[ ! "$cur" == -* ]]; then local mirrors mirror_url - mirrors=$(awk -F= ' $1 ~ /^ *mirror *$/ { print $2 }' ${configuration_files[@]}) + mirrors=$(awk -F= ' $1 ~ /^ *mirror *$/ { print $2 }' "${configuration_files[@]}") mirrors=${mirrors:-http://mirror.opencsw.org/opencsw/testing} for mirror_url in $mirrors; do local catalog=$(_pkgutil_url2catalog "$mirror_url") diff --git a/completions/plague-client b/completions/plague-client index 6fd22f75..d8b2140e 100644 --- a/completions/plague-client +++ b/completions/plague-client @@ -6,8 +6,8 @@ _plague_client() _init_completion || return [[ $cword -eq 1 ]] && \ - COMPREPLY=( $( compgen -W 'build detail finish help is_paused kill list - list_builders pause requeue unpause update_builders' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'build detail finish help is_paused kill list + list_builders pause requeue unpause update_builders' -- "$cur") ) } && complete -F _plague_client plague-client diff --git a/completions/pm-hibernate b/completions/pm-hibernate index fcabbfaf..1deadd11 100644 --- a/completions/pm-hibernate +++ b/completions/pm-hibernate @@ -5,7 +5,7 @@ _pm_action() local cur prev words cword _init_completion || return - COMPREPLY=( $( compgen -W "--help $( _parse_help "$1" )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "--help $(_parse_help "$1")" -- "$cur") ) } && complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid diff --git a/completions/pm-is-supported b/completions/pm-is-supported index 2eeb634d..6a112aeb 100644 --- a/completions/pm-is-supported +++ b/completions/pm-is-supported @@ -5,8 +5,8 @@ _pm_is_supported() local cur prev words cword _init_completion || return - COMPREPLY=( $( compgen -W '--help --suspend --hibernate --suspend-hybrid' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --suspend --hibernate --suspend-hybrid' \ + -- "$cur") ) } && complete -F _pm_is_supported pm-is-supported diff --git a/completions/pm-powersave b/completions/pm-powersave index f61833cf..06f93de0 100644 --- a/completions/pm-powersave +++ b/completions/pm-powersave @@ -5,7 +5,7 @@ _pm_powersave() local cur prev words cword _init_completion || return - COMPREPLY=( $( compgen -W "true false" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "true false" -- "$cur") ) } && complete -F _pm_powersave pm-powersave diff --git a/completions/pngfix b/completions/pngfix index b1f630ed..b4b58e83 100644 --- a/completions/pngfix +++ b/completions/pngfix @@ -14,8 +14,9 @@ _pngfix() return ;; --strip) - COMPREPLY=( $( IFS='|' compgen -W '$( "$1" --help 2>&1 | - command sed -ne "s/.*--strip=\[\([^]]*\)\].*/\1/p" )' -- "$cur" ) ) + COMPREPLY=( $(IFS='|' compgen -W '$("$1" --help 2>&1 | + command sed -ne "s/.*--strip=\[\([^]]*\)\].*/\1/p")' \ + -- "$cur") ) return ;; esac @@ -23,7 +24,7 @@ _pngfix() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/portinstall b/completions/portinstall index 314e936f..8a70b136 100644 --- a/completions/portinstall +++ b/completions/portinstall @@ -18,10 +18,10 @@ _portinstall() [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return - COMPREPLY=( $( command grep -E "^$cur" 2>/dev/null < $indexfile | \ - cut -d'|' -f1 ) ) - COMPREPLY2=( $( command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \ - < $indexfile | cut -d'|' -f2 ) ) + COMPREPLY=( $(command grep -E "^$cur" 2>/dev/null <$indexfile | \ + cut -d'|' -f1) ) + COMPREPLY2=( $(command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \ + <$indexfile | cut -d'|' -f2) ) COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} ) COMPREPLY+=( "${COMPREPLY2[@]}" ) diff --git a/completions/portupgrade b/completions/portupgrade index 64d983df..42538077 100644 --- a/completions/portupgrade +++ b/completions/portupgrade @@ -9,7 +9,7 @@ _portupgrade() local pkgdir=${PKG_DBDIR:-/var/db/pkg}/ - COMPREPLY=( $( compgen -d -- "$pkgdir$cur" ) ) + COMPREPLY=( $(compgen -d -- "$pkgdir$cur") ) COMPREPLY=( ${COMPREPLY[@]#$pkgdir} ) COMPREPLY=( ${COMPREPLY[@]%-*} ) diff --git a/completions/postcat b/completions/postcat index 69214354..22006233 100644 --- a/completions/postcat +++ b/completions/postcat @@ -13,7 +13,7 @@ _postcat() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi @@ -23,12 +23,10 @@ _postcat() done if [[ $qfile -eq 1 ]]; then local len=${#cur} pval - idx=0 - for pval in $( mailq 2>/dev/null | \ - command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do + for pval in $(mailq 2>/dev/null | \ + command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//'); do if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]=$pval - idx=$(($idx+1)) + COMPREPLY+=( $pval ) fi done return diff --git a/completions/postconf b/completions/postconf index c1f17d9d..45b376be 100644 --- a/completions/postconf +++ b/completions/postconf @@ -23,15 +23,14 @@ _postconf() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi - local len=${#cur} idx=0 pval - for pval in $( /usr/sbin/postconf 2>/dev/null | cut -d ' ' -f 1 ); do + local len=${#cur} pval + for pval in $(/usr/sbin/postconf 2>/dev/null | cut -d ' ' -f 1); do if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]="$pval$eqext" - idx=$(($idx+1)) + COMPREPLY+=( "$pval$eqext" ) fi done } && diff --git a/completions/postfix b/completions/postfix index 9b116be1..89ff4dd4 100644 --- a/completions/postfix +++ b/completions/postfix @@ -11,18 +11,18 @@ _postfix() return ;; -D) - COMPREPLY=( $( compgen -W 'start' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'start' -- "$cur") ) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -W 'check start stop abort flush reload status - set-permissions upgrade-configuration' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'check start stop abort flush reload status + set-permissions upgrade-configuration' -- "$cur") ) } && complete -F _postfix postfix diff --git a/completions/postmap b/completions/postmap index 1b415f69..66756c1e 100644 --- a/completions/postmap +++ b/completions/postmap @@ -16,24 +16,23 @@ _postmap() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi if [[ "$cur" == *:* ]]; then compopt -o filenames - COMPREPLY=( $( compgen -f -- "${cur#*:}" ) ) + COMPREPLY=( $(compgen -f -- "${cur#*:}") ) else - local len=${#cur} idx=0 pval - for pval in $( /usr/sbin/postconf -m 2>/dev/null ); do + local len=${#cur} pval + for pval in $(/usr/sbin/postconf -m 2>/dev/null); do if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]="$pval:" - idx=$(($idx+1)) + COMPREPLY+=( "$pval:" ) fi done - if [[ $idx -eq 0 ]]; then + if [[ ! $COMPREPLY ]]; then compopt -o filenames - COMPREPLY=( $( compgen -f -- "$cur" ) ) + COMPREPLY=( $(compgen -f -- "$cur") ) fi fi } && diff --git a/completions/postsuper b/completions/postsuper index e69cbea0..509d2484 100644 --- a/completions/postsuper +++ b/completions/postsuper @@ -5,7 +5,7 @@ _postsuper() local cur prev words cword _init_completion || return - local pval len idx + local pval len case $prev in -c) @@ -14,36 +14,30 @@ _postsuper() ;; -[dr]) len=${#cur} - idx=0 - for pval in ALL $( mailq 2>/dev/null | \ - command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do + for pval in ALL $(mailq 2>/dev/null | \ + command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//'); do if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]=$pval - idx=$(($idx+1)) + COMPREPLY+=( $pval ) fi done return ;; -h) len=${#cur} - idx=0 - for pval in ALL $( mailq 2>/dev/null | \ - command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d' ); do + for pval in ALL $(mailq 2>/dev/null | \ + command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d'); do if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]=$pval - idx=$(($idx+1)) + COMPREPLY+=( $pval ) fi done return ;; -H) len=${#cur} - idx=0 - for pval in ALL $( mailq 2>/dev/null | \ - command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do + for pval in ALL $(mailq 2>/dev/null | \ + command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//'); do if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]=$pval - idx=$(($idx+1)) + COMPREPLY+=( $pval ) fi done return @@ -51,11 +45,11 @@ _postsuper() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'hold incoming active deferred' -- "$cur") ) } && complete -F _postsuper postsuper diff --git a/completions/povray b/completions/povray index e90279b3..c5af018a 100644 --- a/completions/povray +++ b/completions/povray @@ -21,14 +21,14 @@ _povray() ;; [-+]O*) # guess what output file type user may want - case $( ( IFS=$'\n'; command grep '^[-+]F' <<<"${words[*]}" ) ) in + case $(IFS=$'\n'; command grep '^[-+]F' <<<"${words[*]}") in [-+]FN) oext=png ;; [-+]FP) oext=ppm ;; [-+]F[CT]) oext=tga ;; *) oext=$defoext ;; esac # complete filename corresponding to previously specified +I - COMPREPLY=( $( ( IFS=$'\n'; command grep '^[-+]I' <<<"${words[*]}" ) ) ) + COMPREPLY=( $(IFS=$'\n'; command grep '^[-+]I' <<<"${words[*]}") ) COMPREPLY=( ${COMPREPLY[@]#[-+]I} ) COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} ) cur="${povcur#[-+]O}" # to confuse _filedir @@ -44,7 +44,7 @@ _povray() COMPREPLY=( $(command sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \ -e 't' -e 'd' -- "$pfx") ) # to prevent [bar] expand to nothing. can be done more easily? - COMPREPLY=( "${COMPREPLY[@]/#/$pfx[}" ) + COMPREPLY=( "${COMPREPLY[@]/#/${pfx}[}" ) return ;; *) diff --git a/completions/prelink b/completions/prelink index 0db3140c..62580a95 100644 --- a/completions/prelink +++ b/completions/prelink @@ -30,7 +30,7 @@ _prelink() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/protoc b/completions/protoc index 1d4bef16..d4381446 100644 --- a/completions/protoc +++ b/completions/protoc @@ -18,13 +18,13 @@ _protoc() return ;; --error_format) - COMPREPLY=( $( compgen -W 'gcc msvs' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'gcc msvs' -- "$cur") ) return ;; --plugin) if [[ $cur != *=* ]]; then compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) fi return ;; @@ -46,9 +46,9 @@ _protoc() return ;; -*) - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) local i - for i in ${!COMPREPLY[@]}; do + for i in "${!COMPREPLY[@]}"; do [[ ${COMPREPLY[i]} == -oFILE ]] && unset 'COMPREPLY[i]' done [[ $COMPREPLY == *= ]] && compopt -o nospace diff --git a/completions/psql b/completions/psql index 86a66030..ceedf07e 100644 --- a/completions/psql +++ b/completions/psql @@ -4,16 +4,16 @@ _pg_databases() { # -w was introduced in 8.4, https://launchpad.net/bugs/164772 # "Access privileges" in output may contain linefeeds, hence the NF > 1 - COMPREPLY=( $( compgen -W "$( psql -XAtqwlF $'\t' 2>/dev/null | \ - awk 'NF > 1 { print $1 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(psql -XAtqwlF $'\t' 2>/dev/null | \ + awk 'NF > 1 { print $1 }')" -- "$cur") ) } _pg_users() { # -w was introduced in 8.4, https://launchpad.net/bugs/164772 - COMPREPLY=( $( compgen -W "$( psql -XAtqwc 'select usename from pg_user' \ - template1 2>/dev/null )" -- "$cur" ) ) - [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(psql -XAtqwc 'select usename from pg_user' \ + template1 2>/dev/null)" -- "$cur") ) + [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $(compgen -u -- "$cur") ) } # createdb(1) completion @@ -24,20 +24,15 @@ _createdb() _init_completion -s || return case $prev in - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username|-O|--owner) + --username|--owner|-!(-*)[UO]) _pg_users return ;; - -p|--port|-D|--tablespace|-E|--encoding|-T|--template) - # argument required but no completions available - return - ;; - --help|--version) - # all other arguments are noop with these + --help|--version|--port|--tablespace|--encoding|--template|-!(-*)[pDET]) return ;; esac @@ -45,7 +40,7 @@ _createdb() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _pg_databases @@ -61,14 +56,14 @@ _createuser() _init_completion -s || return case $prev in - --help|--version|-p|--port|-c|--connection-limit) + --help|--version|--port|--connection-limit|-!(-*)[pc]) return ;; - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username) + --username|-!(-*)U) _pg_users return ;; @@ -77,7 +72,7 @@ _createuser() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && @@ -91,16 +86,15 @@ _dropdb() _init_completion -s || return case $prev in - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username) + --username|-!(-*)U) _pg_users return ;; --help|--version) - # all other arguments are noop with these return ;; esac @@ -108,7 +102,7 @@ _dropdb() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _pg_databases @@ -124,14 +118,14 @@ _dropuser() _init_completion -s || return case $prev in - --help|--version|-p|--port) + --help|--version|--port|-!(-*)p) return ;; - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username) + --username|-!(-*)U) _pg_users return ;; @@ -140,7 +134,7 @@ _dropuser() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _pg_users @@ -156,29 +150,24 @@ _psql() _init_completion -s || return case $prev in - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username) + --username|-!(-*)U) _pg_users return ;; - -d|--dbname) + --dbname|-!(-*)d) _pg_databases return ;; - -o|--output|-f|--file|-L|--log-file) + --output|--file|--log-file|-!(-*)[ofL]) _filedir return ;; - -c|--command|-F|--field-separator|-p|--port|-P|--pset|\ - -R|--record-separator|-T|--table-attr|-v|--set|--variable) - # argument required but no completions available - return - ;; - -\?|--help|-V|--version) - # all other arguments are noop with these + --help|--version|--command|--field-separator|--port|--pset|\ + --record-separator|--table-attr|--set|--variable|-!(-*)[?VcFpPRTv]) return ;; esac @@ -187,7 +176,7 @@ _psql() if [[ "$cur" == -* ]]; then # return list of available options - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else # return list of available databases diff --git a/completions/puppet b/completions/puppet index 59a477ed..b9e1bcd6 100644 --- a/completions/puppet +++ b/completions/puppet @@ -3,16 +3,16 @@ _puppet_logdest() { if [[ -z $cur ]]; then - COMPREPLY=( $( compgen -W 'syslog console /' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'syslog console /' -- "$cur") ) else - COMPREPLY=( $( compgen -W 'syslog console' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'syslog console' -- "$cur") ) _filedir fi } _puppet_digest() { - COMPREPLY=( $( compgen -W 'MD5 MD2 SHA1 SHA256' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'MD5 MD2 SHA1 SHA256' -- "$cur") ) } _puppet_certs() @@ -22,17 +22,17 @@ _puppet_certs() && puppetca=puppetca if [[ "$1" == --all ]]; then - cert_list=$( $puppetca --list --all | command sed -e 's/^[+-]\{0,1\}\s*\(\S\+\)\s\+.*$/\1/' ) + cert_list=$($puppetca --list --all | command sed -e 's/^[+-]\{0,1\}\s*\(\S\+\)\s\+.*$/\1/') else - cert_list=$( $puppetca --list ) + cert_list=$($puppetca --list) fi - COMPREPLY+=( $( compgen -W "$cert_list" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W "$cert_list" -- "$cur") ) } _puppet_types() { - puppet_types=$( puppet describe --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/' ) - COMPREPLY+=( $( compgen -W "$puppet_types" -- "$cur" ) ) + puppet_types=$(puppet describe --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/') + COMPREPLY+=( $(compgen -W "$puppet_types" -- "$cur") ) } _puppet_references() @@ -41,16 +41,16 @@ _puppet_references() PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetdoc &>/dev/null \ && puppetdoc=puppetdoc - puppet_doc_list=$( $puppetdoc --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/' ) - COMPREPLY+=( $( compgen -W "$puppet_doc_list" -- "$cur" ) ) + puppet_doc_list=$($puppetdoc --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/') + COMPREPLY+=( $(compgen -W "$puppet_doc_list" -- "$cur") ) } _puppet_subcmd_opts() { # puppet cmd help is somewhat slow, avoid if possible [[ -z $cur || $cur == -* ]] && \ - COMPREPLY+=( $( compgen -W \ - '$( _parse_usage "$1" "help $2" )' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + '$(_parse_usage "$1" "help $2")' -- "$cur") ) } _puppet() @@ -103,9 +103,9 @@ _puppet() subcommand=apply ;; *) - COMPREPLY=( $( compgen -W 'agent apply cert describe doc + COMPREPLY=( $(compgen -W 'agent apply cert describe doc filebucket kick master parser queue resource' \ - -- "$cur" ) ) + -- "$cur") ) return ;; esac @@ -131,24 +131,24 @@ _puppet() return ;; --masterport) - COMPREPLY=( $( compgen -W '8140' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '8140' -- "$cur") ) return ;; -w|--waitforcert) - COMPREPLY=( $( compgen -W '0 15 30 60 120' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '0 15 30 60 120' -- "$cur") ) return ;; *) _puppet_subcmd_opts "$1" $subcommand # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize] - COMPREPLY+=( $( compgen -W '--no-daemonize' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '--no-daemonize' -- "$cur") ) return esac ;; apply) case $prev in --catalog) - COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-' -- "$cur") ) _filedir json return ;; @@ -176,11 +176,11 @@ _puppet() ;; *) action=$prev - COMPREPLY=( $( compgen -W '--digest --debug --help --verbose --version' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--digest --debug --help --verbose --version' \ + -- "$cur") ) case $action in fingerprint|list|verify|--fingerprint|--list|--verify) - COMPREPLY+=( $( compgen -W '--all' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '--all' -- "$cur") ) _puppet_certs --all return ;; @@ -193,13 +193,13 @@ _puppet() return ;; sign|--sign) - COMPREPLY+=( $( compgen -W '--all' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '--all' -- "$cur") ) _puppet_certs return ;; *) - COMPREPLY+=( $( compgen -W 'clean fingerprint generate - list print revoke sign verify reinventory' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W 'clean fingerprint generate + list print revoke sign verify reinventory' -- "$cur") ) return esac esac @@ -218,7 +218,7 @@ _puppet() return ;; -m|--mode) - COMPREPLY=( $( compgen -W 'text trac pdf rdoc' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'text trac pdf rdoc' -- "$cur") ) return ;; -r|--reference) @@ -248,8 +248,8 @@ _puppet() if [[ "$cur" == -* ]]; then _puppet_subcmd_opts "$1" $subcommand else - COMPREPLY=( $( compgen -W 'backup get restore' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'backup get restore' \ + -- "$cur") ) _filedir fi return @@ -285,7 +285,7 @@ _puppet() *) _puppet_subcmd_opts "$1" $subcommand # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize] - COMPREPLY+=( $( compgen -W '--no-daemonize' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '--no-daemonize' -- "$cur") ) return esac ;; @@ -297,7 +297,7 @@ _puppet() return ;; *) - COMPREPLY=( $( compgen -W 'validate' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'validate' -- "$cur") ) return esac ;; diff --git a/completions/pv b/completions/pv index 28514e7c..007bb36b 100644 --- a/completions/pv +++ b/completions/pv @@ -6,25 +6,26 @@ _pv() _init_completion || return case $prev in - -h|--help|-V|--version|-A|--last-written|-F|--format|-D|--delay-start|\ - -i|--interval|-w|--width|-H|--height|-N|--name|-L|--rate-limit|\ - -B|--buffer-size) + --help|--version|--last-written|--format|--delay-start|--interval|\ + --width|--height|--name|--rate-limit|--buffer-size|-!(-*)[hVAFDiwHNLB]) return ;; - -R|--remote) + --remote|-!(-*)R) _pids return ;; - -P|--pidfile|-d|--watchfd) + --pidfile|--watchfd|-!(-*)[Pd]) _filedir pid return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else _filedir fi } && complete -F _pv pv + +# ex: filetype=sh diff --git a/completions/pwck b/completions/pwck index 468aa7c6..7723f66d 100644 --- a/completions/pwck +++ b/completions/pwck @@ -6,7 +6,7 @@ _pwck() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi diff --git a/completions/pwd b/completions/pwd index f4a558a2..56100173 100644 --- a/completions/pwd +++ b/completions/pwd @@ -11,9 +11,9 @@ _pwd() ;; esac - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY ]] || \ - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) } && complete -F _pwd pwd diff --git a/completions/pwdx b/completions/pwdx index ed8d3ec2..675c41ff 100644 --- a/completions/pwdx +++ b/completions/pwdx @@ -12,9 +12,9 @@ _pwdx() esac if [[ $cur == -* ]]; then - local help='$( _parse_help "$1" )' + local help='$(_parse_help "$1")' [[ $help ]] || help=-V - COMPREPLY=( $( compgen -W "$help" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$help" -- "$cur") ) else _pids fi diff --git a/completions/pwgen b/completions/pwgen index d30526e9..8781cb9a 100644 --- a/completions/pwgen +++ b/completions/pwgen @@ -6,10 +6,10 @@ _pwgen() _init_completion -s || return case $prev in - -N|--num-passwords|-h|--help) + --num-passwords|--help|-!(-*)[Nh]) return ;; - -H|--sha1) + --sha1|-!(-*)H) _filedir return ;; @@ -18,7 +18,7 @@ _pwgen() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/py.test b/completions/py.test deleted file mode 100644 index 6362bf0a..00000000 --- a/completions/py.test +++ /dev/null @@ -1,71 +0,0 @@ -# bash completion for py.test(1) -*- shell-script -*- - -_py_test() -{ - local cur prev words cword split - _init_completion -s || return - - case $prev in - -h|--help|-k|-m|--maxfail|-r|--report|--junit-prefix|--doctest-glob|-p) - return - ;; - --import-mode) - COMPREPLY=( $( compgen -W "prepend append" -- "$cur" ) ) - return - ;; - --capture) - COMPREPLY=( $( compgen -W "fd sys no" -- "$cur" ) ) - return - ;; - --tb) - COMPREPLY=( $( compgen -W "auto long short line native no" \ - -- "$cur" ) ) - return - ;; - --color) - COMPREPLY=( $( compgen -W "yes no auto" -- "$cur" ) ) - return - ;; - --pastebin) - COMPREPLY=( $( compgen -W "failed all" -- "$cur" ) ) - return - ;; - --junit-xml) - _filedir xml - return - ;; - --result-log) - _filedir log - return - ;; - --ignore) - _filedir - return - ;; - --confcutdir|--basetemp) - _filedir -d - return - ;; - --assert) - COMPREPLY=( $( compgen -W "plain reinterp rewrite" -- "$cur" ) ) - return - ;; - --genscript) - _filedir py - return - ;; - esac - - $split && return - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - return - fi - - _filedir py -} && -complete -F _py_test py.test py.test-2 py.test-3 - -# ex: filetype=sh diff --git a/completions/pycodestyle b/completions/pycodestyle index 7a62ac07..2eac748c 100644 --- a/completions/pycodestyle +++ b/completions/pycodestyle @@ -10,7 +10,7 @@ _pycodestyle() return ;; --format) - COMPREPLY=( $( compgen -W 'default pylint' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'default pylint' -- "$cur") ) return ;; --config) @@ -22,7 +22,7 @@ _pycodestyle() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/pydoc b/completions/pydoc index 0e750cbb..1e904885 100644 --- a/completions/pydoc +++ b/completions/pydoc @@ -16,21 +16,23 @@ _pydoc() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W \ - '$( "$1" | command sed -e "s/^pydoc3\{0,1\} //" | _parse_help - )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$("$1" | command sed -e "s/^pydoc3\{0,1\} //" | _parse_help -)' \ + -- "$cur") ) return fi - COMPREPLY=( $( compgen -W 'keywords topics modules' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'keywords topics modules' -- "$cur") ) - local python=python; [[ $1 == *3* ]] && python=python3 - _xfunc python _python_modules $python + if [[ $cur != @(.|*/)* ]]; then + local python=python; [[ ${1##*/} == *3* ]] && python=python3 + _xfunc python _python_modules $python + fi # Note that we don't do "pydoc modules" as it is known to hang on # some systems; _python_modules tends to work better and faster. - COMPREPLY+=( $( compgen -W \ - '$( $1 keywords topics | command sed -e /^Here/d )' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + '$($1 keywords topics | command sed -e /^Here/d)' -- "$cur") ) _filedir py } && diff --git a/completions/pydocstyle b/completions/pydocstyle new file mode 100644 index 00000000..eb858901 --- /dev/null +++ b/completions/pydocstyle @@ -0,0 +1,35 @@ +# bash completion for pydocstyle -*- shell-script -*- + +_pydocstyle() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--version|--match|--ignore-decorators|--select|--ignore|\ + --add-select|--add-ignore|-!(-*)h) + return + ;; + --config) + _filedir xml + return + ;; + --convention) + COMPREPLY=( $(compgen -W "pep257 numpy" -- "$cur") ) + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir py +} && +complete -F _pydocstyle pydocstyle + +# ex: filetype=sh diff --git a/completions/pyflakes b/completions/pyflakes index 05025263..4a982784 100644 --- a/completions/pyflakes +++ b/completions/pyflakes @@ -12,7 +12,7 @@ _pyflakes() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/pylint b/completions/pylint index b1d80918..35655964 100644 --- a/completions/pylint +++ b/completions/pylint @@ -5,12 +5,12 @@ _pylint() local cur prev words cword split _init_completion -s || return - local python=python; [[ $1 == *3* ]] && python=python3 + local python=python; [[ ${1##*/} == *3* ]] && python=python3 case $prev in - --version|-h|--help|--long-help|--help-msg|--init-hook|--ignore|-e|\ - --enable|-d|--disable|--evaluation|--max-line-length|\ - --max-module-lines|--indent-string|--min-similarity-lines|--max-args|\ + --version|--help|--long-help|--help-msg|--init-hook|--ignore|--enable|\ + --evaluation|--max-line-length|--max-module-lines|\ + --indent-string|--min-similarity-lines|--max-args|\ --ignored-argument-names|--max-locals|--max-returns|--max-branchs|\ --max-statements|--max-parents|--max-attributes|--min-public-methods|\ --max-public-methods|--required-attributes|--bad-functions|\ @@ -20,17 +20,22 @@ _pylint() --additional-builtins|--notes|--ignored-classes|--generated-members|\ --overgeneral-exceptions|--ignore-iface-methods|\ --defining-attr-methods|--valid-classmethod-first-arg|\ - --valid-metaclass-classmethod-first-arg) + --valid-metaclass-classmethod-first-arg|-!(-*)[he]) + return + ;; + --disable|-!(-*)d) + COMPREPLY=( $(compgen -W 'all' -- "$cur") ) return ;; --rcfile) _filedir return ;; - --persistent|-i|--include-ids|-s|--symbols|--files-output|-r|\ - --reports|--comment|--ignore-comments|--ignore-docstrings|\ - --ignore-imports|--init-import|--ignore-mixin-members|--zope) - COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) ) + --persistent|--include-ids|--symbols|--files-output|--reports|\ + --comment|--ignore-comments|--ignore-docstrings|--ignore-imports|\ + --init-import|--ignore-mixin-members|--zope|--suggestion-mode|\ + -!(-*)[isr]) + COMPREPLY=( $(compgen -W 'yes no' -- "$cur") ) return ;; --load-plugins|--deprecated-modules) @@ -40,9 +45,20 @@ _pylint() [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; - -f|--format) - COMPREPLY=( $( compgen -W 'text parseable colorized msvs html' \ - -- "$cur" ) ) + --jobs|-!(-*)j) + COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + return + ;; + --confidence) + local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=( $(compgen -W "HIGH INFERENCE INFERENCE_FAILURE + UNDEFINED" -- "${cur##*,}") ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + return + ;; + --format|-!(-*)f) + COMPREPLY=( $(compgen -W 'text parseable colorized json msvs' \ + -- "$cur") ) return ;; --import-graph|--ext-import-graph|--int-import-graph) @@ -54,13 +70,13 @@ _pylint() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W \ - '$( _parse_help "$1" --long-help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(_parse_help "$1" --long-help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi - _xfunc python _python_modules $python + [[ $cur == @(.|*/)* ]] || _xfunc python _python_modules $python _filedir py } && complete -F _pylint pylint pylint-2 pylint-3 diff --git a/completions/pytest b/completions/pytest new file mode 100644 index 00000000..9239766c --- /dev/null +++ b/completions/pytest @@ -0,0 +1,86 @@ +# bash completion for pytest(1) -*- shell-script -*- + +_pytest() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--maxfail|--report|--junit-prefix|--doctest-glob|-!(-*)[hkmrp]) + return + ;; + --import-mode) + COMPREPLY=( $(compgen -W "prepend append" -- "$cur") ) + return + ;; + --capture) + COMPREPLY=( $(compgen -W "fd sys no" -- "$cur") ) + return + ;; + --tb) + COMPREPLY=( $(compgen -W "auto long short line native no" \ + -- "$cur") ) + return + ;; + --color) + COMPREPLY=( $(compgen -W "yes no auto" -- "$cur") ) + return + ;; + --pastebin) + COMPREPLY=( $(compgen -W "failed all" -- "$cur") ) + return + ;; + --junit-xml) + _filedir xml + return + ;; + --result-log) + _filedir log + return + ;; + --ignore) + _filedir + return + ;; + --confcutdir|--basetemp|--rsyncdir) + _filedir -d + return + ;; + --assert) + COMPREPLY=( $(compgen -W "plain reinterp rewrite" -- "$cur") ) + return + ;; + --genscript) + _filedir py + return + ;; + --pythonwarnings|-!(-*)W) + _xfunc python _python_warning_actions + return + ;; + --numprocesses|-!(-*)n) + COMPREPLY=( $(compgen -W "{1..$(_ncpus)} auto" -- "$cur") ) + return + ;; + --dist) + local modes=$("$1" --dist=nonexistent-distmode 2>&1 | \ + command sed -e 's/[^[:space:][:alnum:]-]\{1,\}//g' \ + -ne 's/.*choose from //p') + COMPREPLY=( $(compgen -W '$modes' -- "$cur") ) + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir py +} && +complete -F _pytest pytest pytest-2 pytest-3 py.test py.test-2 py.test-3 + +# ex: filetype=sh diff --git a/completions/python b/completions/python index f8ef6d0c..5e69ff12 100644 --- a/completions/python +++ b/completions/python @@ -2,9 +2,15 @@ _python_modules() { - COMPREPLY+=( $( compgen -W \ - "$( ${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python $cur \ - 2>/dev/null )" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + "$(${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python $cur \ + 2>/dev/null)" -- "$cur") ) +} + +_python_warning_actions() +{ + COMPREPLY+=( $(compgen -W "ignore default all module once error" \ + ${prefix:+-P "$prefix"} -- "$cur") ) } _python() @@ -21,26 +27,25 @@ _python() esac case $prev in - -'?'|-h|--help|-V|--version|-c|-X) + --help|--version|-!(-*)[?hVcX]) return ;; - -m) + -!(-*)m) _python_modules "$1" return ;; - -Q) - COMPREPLY=( $( compgen -W "old new warn warnall" -P "$prefix" \ - -- "$cur" ) ) + -!(-*)Q) + COMPREPLY=( $(compgen -W "old new warn warnall" -P "$prefix" \ + -- "$cur") ) return ;; - -W) - COMPREPLY=( $( compgen -W "ignore default all module once error" \ - -P "$prefix" -- "$cur" ) ) + -!(-*)W) + _python_warning_actions return ;; --jit) # TODO: quite a few others, parse from "--jit help" output? - COMPREPLY=( $( compgen -W "help off" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "help off" -- "$cur") ) return ;; !(?(*/)python*([0-9.])|?(*/)pypy*([0-9.])|-?)) @@ -50,12 +55,12 @@ _python() # if -c or -m is already given, complete all kind of files. - if [[ "${words[@]::$cword}" == *\ -[cm]\ * ]]; then + if [[ "${words[*]::$cword}" == *\ -[cm]\ * ]]; then _filedir elif [[ "$cur" != -* ]]; then _filedir 'py?([cowz])' else - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) fi } && complete -F _python python python2 python3 pypy pypy3 micropython diff --git a/completions/pyvenv b/completions/pyvenv index 8e366a01..d5135e87 100644 --- a/completions/pyvenv +++ b/completions/pyvenv @@ -20,6 +20,6 @@ _pyvenv() _filedir -d } && -complete -F _pyvenv pyvenv pyvenv-3.{4..5} +complete -F _pyvenv pyvenv pyvenv-3.{4..8} # ex: filetype=sh diff --git a/completions/qdbus b/completions/qdbus index dee0760a..9a22e800 100644 --- a/completions/qdbus +++ b/completions/qdbus @@ -6,8 +6,8 @@ _qdbus() _init_completion || return [[ -n $cur ]] && unset "words[$((${#words[@]}-1))]" - COMPREPLY=( $( compgen -W '$( command ${words[@]} 2>/dev/null | \ - command sed "s/(.*)//" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(command ${words[@]} 2>/dev/null | \ + command sed "s/(.*)//")' -- "$cur") ) } && complete -F _qdbus qdbus dcop diff --git a/completions/qemu b/completions/qemu index 724e7a5f..8602cebd 100644 --- a/completions/qemu +++ b/completions/qemu @@ -16,79 +16,78 @@ _qemu() return ;; -boot) - COMPREPLY=( $( compgen -W 'a c d n' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'a c d n' -- "$cur") ) return ;; -k) - COMPREPLY=( $( compgen -W 'ar de-ch es fo fr-ca hu ja mk no pt-br + COMPREPLY=( $(compgen -W 'ar de-ch es fo fr-ca hu ja mk no pt-br sv da en-gb et fr fr-ch is lt nl pl ru th de en-us fi fr-be hr - it lv nl-be pt sl tr' -- "$cur" ) ) + it lv nl-be pt sl tr' -- "$cur") ) return ;; -soundhw) - COMPREPLY=( $( compgen -W "$( $1 -soundhw ? | awk \ - '/^[[:lower:]]/ {print $1}' ) all" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 -soundhw ? | awk \ + '/^[[:lower:]]/ {print $1}') all" -- "$cur") ) return ;; -M) - COMPREPLY=( $( compgen -W "$( $1 -M ? | awk \ - '/^[[:lower:]]/ {print $1}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 -M ? | awk \ + '/^[[:lower:]]/ {print $1}')" -- "$cur") ) return ;; -cpu) - COMPREPLY=( $( compgen -W "$( $1 -cpu ? | awk \ - '{print $2}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 -cpu ? | awk '{print $2}')" \ + -- "$cur") ) return ;; -usbdevice) - COMPREPLY=( $( compgen -W 'mouse tablet disk: host: serial: braille - net' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'mouse tablet disk: host: serial: braille + net' -- "$cur") ) return ;; -net) - COMPREPLY=( $( compgen -W 'nic user tap socket vde none dump' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'nic user tap socket vde none dump' \ + -- "$cur") ) return ;; -serial|-parallel|-monitor) - COMPREPLY=( $( compgen -W 'vc pty none null /dev/ file: stdio pipe: - COM udp: tcp: telnet: unix: mon: braille' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'vc pty none null /dev/ file: stdio pipe: + COM udp: tcp: telnet: unix: mon: braille' -- "$cur") ) return ;; -redir) - COMPREPLY=( $( compgen -S":" -W 'tcp udp' -- "$cur" ) ) + COMPREPLY=( $(compgen -S":" -W 'tcp udp' -- "$cur") ) return ;; -bt) - COMPREPLY=( $( compgen -W 'hci vhci device' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'hci vhci device' -- "$cur") ) return ;; -vga) - COMPREPLY=( $( compgen -W 'cirrus std vmware xenfb none' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'cirrus std vmware xenfb none' -- "$cur") ) return ;; -drive) - COMPREPLY=( $( compgen -S"=" -W 'file if bus unit index media cyls - snapshot cache format serial addr' -- "$cur" ) ) + COMPREPLY=( $(compgen -S"=" -W 'file if bus unit index media cyls + snapshot cache format serial addr' -- "$cur") ) return ;; -balloon) - COMPREPLY=( $( compgen -W 'none virtio' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'none virtio' -- "$cur") ) return ;; -smbios) - COMPREPLY=( $( compgen -W 'file type' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'file type' -- "$cur") ) return ;; -watchdog) - COMPREPLY=( $( compgen -W "$( $1 -watchdog ? 2>&1 | \ - awk '{print $1}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 -watchdog ? 2>&1 | \ + awk '{print $1}')" -- "$cur") ) return ;; -watchdog-action) - COMPREPLY=( $( compgen -W 'reset shutdown poweroff pause debug - none' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'reset shutdown poweroff pause debug + none' -- "$cur") ) return ;; -runas) @@ -99,8 +98,8 @@ _qemu() if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help ) -fd{a,b} - -hd{a..d}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help) -fd{a,b} + -hd{a..d}' -- "$cur") ) else _filedir fi diff --git a/completions/qrunner b/completions/qrunner index 4e02a175..b0421a09 100644 --- a/completions/qrunner +++ b/completions/qrunner @@ -8,8 +8,8 @@ _qrunner() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--runner --once --list --verbose --subproc - --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--runner --once --list --verbose --subproc + --help' -- "$cur") ) fi } && diff --git a/completions/querybts b/completions/querybts index e08c905c..69c5aa08 100644 --- a/completions/querybts +++ b/completions/querybts @@ -6,27 +6,34 @@ _querybts() _init_completion -s || return case $prev in - -B|--bts) - COMPREPLY=( $( compgen -W "debian guug kde mandrake help" \ - -- "$cur" ) ) + --bts|-!(-*)B) + COMPREPLY=( $(compgen -W "debian guug kde mandrake help" \ + -- "$cur") ) return ;; - -u|--ui|--interface) - COMPREPLY=( $( compgen -W "newt text gnome" -- "$cur" ) ) + --ui|--interface|-!(-*)u) + COMPREPLY=( $(compgen -W "newt text gnome" -- "$cur") ) + return + ;; + --mbox-reader-cmd) + compopt -o filenames + COMPREPLY=( $(compgen -c -- "$cur") ) return ;; esac $split && return - COMPREPLY=( $( compgen -W '-h --help -v --version -A --archive -B --bts -l - --ldap --no-ldap --proxy --http_proxy -s --source -w --web -u --ui - --interface \ - wnpp boot-floppies kernel bugs.debian.org cdimage.debian.org general - installation-reports listarchives lists.debian.org mirrors - nm.debian.org press project qa.debian.org release-notes - security.debian.org tech-ctte upgrade-reports www.debian.org' \ - -- "$cur" ) $( apt-cache pkgnames -- "$cur" 2> /dev/null ) ) + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + else + COMPREPLY=( $(compgen -W 'wnpp boot-floppies kernel bugs.debian.org + cdimage.debian.org general installation-reports listarchives + lists.debian.org mirrors nm.debian.org press project qa.debian.org + release-notes security.debian.org tech-ctte upgrade-reports + www.debian.org $(apt-cache pkgnames 2>/dev/null)' -- "$cur") ) + fi } && complete -F _querybts querybts diff --git a/completions/quota b/completions/quota index c1604f8e..bf7319bc 100644 --- a/completions/quota +++ b/completions/quota @@ -7,34 +7,33 @@ _user_or_group() # complete on groups if -g was given for (( i=1; i < cword; i++ )); do if [[ "${words[i]}" == -@(g|-group) ]]; then - COMPREPLY=( $( compgen -g -- "$cur" ) ) + COMPREPLY=( $(compgen -g -- "$cur") ) return fi done # otherwise complete on users - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) } _quota_parse_help() { - local opts=$( _parse_help "$1" ) - [[ $opts ]] || opts=$( _parse_usage "$1" ) # non-GNU? - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace } _quota_formats() { - COMPREPLY=( $( compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur") ) } _filesystems() { # Only list filesystems starting with "/", otherwise we also get #+ "binfmt_misc", "proc", "tmpfs", ... - COMPREPLY=( $( compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \ + -- "$cur") ) } _quota() @@ -171,7 +170,7 @@ _quotaon() return ;; -x|--xfs-command) - COMPREPLY=( $( compgen -W 'delete enforce' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'delete enforce' -- "$cur") ) return ;; -h|--help|-V|--version) diff --git a/completions/radvdump b/completions/radvdump index 7280a7a1..469c8f12 100644 --- a/completions/radvdump +++ b/completions/radvdump @@ -10,12 +10,12 @@ _radvdump() return ;; -d|--debug) - COMPREPLY=( $( compgen -W '{1..4}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..4}' -- "$cur") ) return ;; esac - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) } && complete -F _radvdump radvdump diff --git a/completions/rcs b/completions/rcs index d63fe170..cfad0211 100644 --- a/completions/rcs +++ b/completions/rcs @@ -13,7 +13,7 @@ _rcs() # deal with relative directory [[ $file == $dir ]] && dir=. - COMPREPLY=( $( compgen -f -- "$dir/RCS/$file" ) ) + COMPREPLY=( $(compgen -f -- "$dir/RCS/$file") ) for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do file=${COMPREPLY[$i]##*/} @@ -21,7 +21,7 @@ _rcs() COMPREPLY[$i]=$dir$file done - COMPREPLY+=( $( compgen -G "$dir/$file*,v" ) ) + COMPREPLY+=( $(compgen -G "$dir/$file*,v") ) for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do COMPREPLY[$i]=${COMPREPLY[$i]%,v} @@ -29,7 +29,7 @@ _rcs() # default to files if nothing returned and we're checking in. # otherwise, default to directories - [[ ${#COMPREPLY[@]} -eq 0 && $1 == ci ]] && _filedir || _filedir -d + [[ ${#COMPREPLY[@]} -eq 0 && $1 == *ci ]] && _filedir || _filedir -d } && complete -F _rcs ci co rlog rcs rcsdiff diff --git a/completions/rdesktop b/completions/rdesktop index 1ad6978d..5226a123 100644 --- a/completions/rdesktop +++ b/completions/rdesktop @@ -6,47 +6,47 @@ _rdesktop() _init_completion -n : || return case $prev in - -k) - COMPREPLY=( $( command ls \ + -*k) + COMPREPLY=( $(command ls \ /usr/share/rdesktop/keymaps 2>/dev/null | \ - command grep -E -v '(common|modifiers)' ) ) - COMPREPLY+=( $( command ls $HOME/.rdesktop/keymaps 2>/dev/null ) ) - COMPREPLY+=( $( command ls ./keymaps 2>/dev/null ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) + command grep -E -v '(common|modifiers)') ) + COMPREPLY+=( $(command ls $HOME/.rdesktop/keymaps 2>/dev/null) ) + COMPREPLY+=( $(command ls ./keymaps 2>/dev/null) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) return ;; - -a) - COMPREPLY=( $( compgen -W '8 15 16 24' -- "$cur" ) ) + -*a) + COMPREPLY=( $(compgen -W '8 15 16 24' -- "$cur") ) return ;; - -x) - COMPREPLY=( $( compgen -W 'broadband modem lan' -- "$cur" ) ) + -*x) + COMPREPLY=( $(compgen -W 'broadband modem lan' -- "$cur") ) return ;; - -r) + -*r) case $cur in sound:*) - COMPREPLY=( $( compgen -W 'local off remote' \ - -- "${cur#sound:}" ) ) + COMPREPLY=( $(compgen -W 'local off remote' \ + -- "${cur#sound:}") ) ;; *:*) ;; *) - COMPREPLY=( $( compgen -W 'comport: disk: lptport: - printer: sound: lspci scard' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'comport: disk: lptport: + printer: sound: lspci scard' -- "$cur") ) [[ $COMPREPLY == *: ]] && compopt -o nospace ;; esac return ;; - -u|-d|-s|-c|-p|-n|-g|-S|-T|-X) + -*[udscpngSTX]) return ;; esac if [[ "$cur" == -* ]]; then - local opts=( $( _parse_help "$1" ) ) - COMPREPLY=( $( compgen -W '${opts[@]%:}' -- "$cur" ) ) + local opts=( $(_parse_help "$1") ) + COMPREPLY=( $(compgen -W '${opts[@]%:}' -- "$cur") ) else _known_hosts_real -- "$cur" fi diff --git a/completions/remove_members b/completions/remove_members index 66dbfda6..c22286f1 100644 --- a/completions/remove_members +++ b/completions/remove_members @@ -15,8 +15,8 @@ _remove_members() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--file --all --fromall --nouserack - --noadminack --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--file --all --fromall --nouserack + --noadminack --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/removepkg b/completions/removepkg index eaeb70a7..77f414f6 100644 --- a/completions/removepkg +++ b/completions/removepkg @@ -5,7 +5,7 @@ _removepkg() local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-copy -keep -preserve -warn' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-copy -keep -preserve -warn' -- "$cur") ) return fi @@ -15,8 +15,8 @@ _removepkg() fi local root=${ROOT:-/} - COMPREPLY=( $( cd "$root/var/log/packages" 2> /dev/null || return 1; \ - compgen -f -- "$cur" ) ) + COMPREPLY=( $(cd "$root/var/log/packages" 2>/dev/null || return 1; \ + compgen -f -- "$cur") ) } && complete -F _removepkg removepkg diff --git a/completions/reportbug b/completions/reportbug index c13cc627..f5eaadf3 100644 --- a/completions/reportbug +++ b/completions/reportbug @@ -6,70 +6,91 @@ _reportbug() _init_completion -s || return case $prev in - -f|--filename|-i|--include|--mta|-o|--output|-A|--attach) + --class|--header|--pseudo-header|--mirror|--list-cc|--subject|\ + --http_proxy|--proxy|--email|--realname|--smtpuser|--smtppasswd|\ + --replyto|--reply-to|--justification|--package-version|--body|\ + --body-file|--timeout|--max-attachment-size|--envelope-from|\ + -!(-*)[CHPsjV]) + return + ;; + --filename|--include|--mta|--output|--attach|-[fioA]) _filedir return ;; - -B|--bts) - COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \ - "$cur" ) ) + --keyid|-!(-*)K) + COMPREPLY=( $(compgen -W '$(IFS=: ; \ + gpg --list-keys --with-colons 2>/dev/null \ + | while read -ra row ; do + [[ "${row[0]}" == [ps]ub && ${row[11]} == *s* ]] && \ + printf "%s\n" "${row[4]}" + done)' -- "$cur") ) + return + ;; + --bts|-!(-*)B) + COMPREPLY=( $(compgen -W "debian guug kde mandrake help" -- \ + "$cur") ) return ;; - -e|--editor|--mua) + --editor|--mua|--mbox-reader-cmd|-!(-*)e) words=( words[0] "$cur" ) cword=1 _command return ;; --mode) - COMPREPLY=( $( compgen -W "novice standard expert" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "novice standard expert" -- "$cur") ) return ;; - -S|--severity) - COMPREPLY=( $( compgen -W "grave serious important normal minor - wishlist" -- "$cur" ) ) + --severity|-!(-*)S) + COMPREPLY=( $(compgen -W "grave serious important normal minor + wishlist" -- "$cur") ) return ;; - -u|--ui|--interface) - COMPREPLY=( $( compgen -W "newt text gnome" -- "$cur" ) ) + --ui|--interface|-!(-*)u) + COMPREPLY=( $(compgen -W "newt text gnome" -- "$cur") ) return ;; - -t|--type) - COMPREPLY=( $( compgen -W "gnats debbugs" -- "$cur" ) ) + --type|-!(-*)t) + COMPREPLY=( $(compgen -W "gnats debbugs" -- "$cur") ) return ;; - -T|--tag) - COMPREPLY=( $( compgen -W "none woody potato sarge sarge-ignore + --tag|-!(-*)T) + COMPREPLY=( $(compgen -W "none woody potato sarge sarge-ignore etch etch-ignore lenny lenny-ignore sid experimental confirmed d-i fixed fixed-in-experimental fixed-upstream help l10n moreinfo patch pending security unreproducible upstream wontfix - ipv6 lfs" -- "$cur" ) ) + ipv6 lfs" -- "$cur") ) return ;; --from-buildd) - COMPREPLY=( $( compgen -S "_" -W '$( apt-cache dumpavail | \ - command grep "^Source: $cur" | sort -u | cut -f2 -d" " )' )) + COMPREPLY=( $(compgen -S "_" -W '$(apt-cache dumpavail | \ + command grep "^Source: $cur" | sort -u | cut -f2 -d" ")') ) return ;; - *) + --smtphost) + _known_hosts_real -- "$cur" + return + ;; + --draftpath) + _filedir -d + return ;; esac $split && return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) - wnpp boot-floppies kernel bugs.debian.org - cdimage.debian.org general installation-reports - listarchives lists.debian.org mirrors nm.debian.org - press project qa.debian.org release-notes - security.debian.org tech-ctte upgrade-reports - www.debian.org' -- "$cur" ) - $( apt-cache pkgnames -- "$cur" 2>/dev/null ) ) - if [[ $COMPREPLY == -*= ]]; then - compopt -o nospace - else - _filedir + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == -*= ]] && compopt -o nospace + return fi + + COMPREPLY=( $(compgen -W 'wnpp boot-floppies kernel bugs.debian.org + cdimage.debian.org general installation-reports listarchives + lists.debian.org mirrors nm.debian.org press project qa.debian.org + release-notes security.debian.org tech-ctte upgrade-reports + www.debian.org $(apt-cache pkgnames 2>/dev/null)' -- "$cur") ) + _filedir } && complete -F _reportbug reportbug diff --git a/completions/resolvconf b/completions/resolvconf index 1902e7d1..b4659612 100644 --- a/completions/resolvconf +++ b/completions/resolvconf @@ -13,7 +13,7 @@ _resolvconf() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-a -d -u' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-a -d -u' -- "$cur") ) fi } && complete -F _resolvconf resolvconf diff --git a/completions/ri b/completions/ri index ba4dbe51..8f331419 100644 --- a/completions/ri +++ b/completions/ri @@ -15,20 +15,20 @@ _ri_get_methods() fi COMPREPLY+=( \ - "$( ri ${classes[@]} 2>/dev/null | ruby -ane \ + "$(ri "${classes[@]}" 2>/dev/null | ruby -ane \ 'if /^'"$regex"' methods:/.../^------------------|^$/ and \ /^ / then print $_.split(/, |,$/).grep(/^[^\[]*$/).join("\n"); \ - end' 2>/dev/null | sort -u )" ) + end' 2>/dev/null | sort -u)" ) else # older versions of ri didn't distinguish between class/module and # instance methods COMPREPLY+=( \ - "$( ruby -W0 $ri_path ${classes[@]} | ruby -ane \ + "$(ruby -W0 $ri_path "${classes[@]}" | ruby -ane \ 'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \ print $_.split(/, |,$| +/).grep(/^[^\[]*$/).join("\n"); \ - end' | sort -u )" ) + end' | sort -u)" ) fi - COMPREPLY=( $( compgen $prefix -W '${COMPREPLY[@]}' -- $method ) ) + COMPREPLY=( $(compgen $prefix -W '${COMPREPLY[@]}' -- $method) ) } # needs at least Ruby 1.8.0 in order to use -W0 @@ -38,14 +38,14 @@ _ri() _init_completion -s -n : || return case $prev in - -h|--help|-w|--width) + --help|--width|-!(-*)[hw]) return ;; - -f|--format) - COMPREPLY=( $( compgen -W 'ansi bs html rdoc' -- "$cur" ) ) + --format|-!(-*)f) + COMPREPLY=( $(compgen -W 'ansi bs html rdoc' -- "$cur") ) return ;; - -d|--doc-dir) + --doc-dir|-!(-*)d) _filedir -d return ;; @@ -58,7 +58,7 @@ _ri() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -89,21 +89,21 @@ _ri() if [[ $ri_version == integrated ]]; then # integrated ri from Ruby 1.9 - classes=( $( ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \ - if /^ +[A-Z]/ then print; end; end' 2>/dev/null ) ) + classes=( $(ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \ + if /^ +[A-Z]/ then print; end; end' 2>/dev/null) ) elif [[ $ri_major && $ri_major -ge 3 ]]; then - classes=( $( ri -l 2>/dev/null ) ) + classes=( $(ri -l 2>/dev/null) ) elif [[ $ri_version == "ri 1.8a" ]]; then - classes=( $( ruby -W0 $ri_path | \ + classes=( $(ruby -W0 $ri_path | \ ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \ - if /^ .*[A-Z]/ then print; end; end' )) + if /^ .*[A-Z]/ then print; end; end') ) else - classes=( $( ruby -W0 $ri_path | \ + classes=( $(ruby -W0 $ri_path | \ ruby -ne 'if /^I have/..$stdin.eof then \ - if /^ .*[A-Z]/ then print; end; end' )) + if /^ .*[A-Z]/ then print; end; end') ) fi - COMPREPLY=( $( compgen -W '${classes[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${classes[@]}' -- "$cur") ) __ltrim_colon_completions "$cur" if [[ "$cur" == [A-Z]* ]]; then diff --git a/completions/rmlist b/completions/rmlist index ff827473..d096352c 100644 --- a/completions/rmlist +++ b/completions/rmlist @@ -6,7 +6,7 @@ _rmlist() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--archives --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--archives --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/rmmod b/completions/rmmod index 9868c79a..12f2334e 100644 --- a/completions/rmmod +++ b/completions/rmmod @@ -13,7 +13,7 @@ _rmmod() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/route b/completions/route index 128ebc16..a7c06d6d 100644 --- a/completions/route +++ b/completions/route @@ -23,7 +23,7 @@ _route() $found || COMPREPLY[${#COMPREPLY[@]}]="$opt" done - COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") ) } && complete -F _route route diff --git a/completions/rpcdebug b/completions/rpcdebug index 4eb332fd..ce4f9372 100644 --- a/completions/rpcdebug +++ b/completions/rpcdebug @@ -12,8 +12,8 @@ _rpcdebug_flags() done if [[ -n $module ]]; then - COMPREPLY=( $( compgen -W "$( rpcdebug -vh 2>&1 | \ - command sed -ne 's/^'$module'[[:space:]]\{1,\}//p' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(rpcdebug -vh 2>&1 | \ + command sed -ne 's/^'$module'[[:space:]]\{1,\}//p')" -- "$cur") ) fi } @@ -23,23 +23,22 @@ _rpcdebug() _init_completion || return case $prev in - -s) + -*s) _rpcdebug_flags return ;; - -c) + -*c) _rpcdebug_flags return ;; - -m) - COMPREPLY=( $( compgen -W 'rpc nfs nfsd nlm' -- "$cur" ) ) + -*m) + COMPREPLY=( $(compgen -W 'rpc nfs nfsd nlm' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" -h ) -s -c' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h) -s -c' -- "$cur") ) fi } && complete -F _rpcdebug rpcdebug diff --git a/completions/rpm b/completions/rpm index 6b4e66fa..b797e9fb 100644 --- a/completions/rpm +++ b/completions/rpm @@ -7,38 +7,38 @@ _rpm_installed_packages() if [[ -r /var/log/rpmpkgs && \ /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then # using RHL 7.2 or later - this is quicker than querying the DB - COMPREPLY=( $( compgen -W "$( command sed -ne \ + COMPREPLY=( $(compgen -W "$(command sed -ne \ 's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \ - /var/log/rpmpkgs )" -- "$cur" ) ) + /var/log/rpmpkgs)" -- "$cur") ) elif type rpmqpack &>/dev/null ; then # SUSE's rpmqpack is faster than rpm -qa - COMPREPLY=( $( compgen -W '$( rpmqpack )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(rpmqpack)' -- "$cur") ) else - COMPREPLY=( $( ${1:-rpm} -qa --nodigest --nosignature \ - --queryformat='%{NAME} ' "$cur*" 2>/dev/null ) ) + COMPREPLY=( $(${1:-rpm} -qa --nodigest --nosignature \ + --queryformat='%{NAME} ' "$cur*" 2>/dev/null) ) fi } _rpm_groups() { local IFS=$'\n' - COMPREPLY=( $( compgen -W "$( ${1:-rpm} -qa --nodigest --nosignature \ - --queryformat='%{GROUP}\n' 2>/dev/null )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(${1:-rpm} -qa --nodigest --nosignature \ + --queryformat='%{GROUP}\n' 2>/dev/null)" -- "$cur") ) } _rpm_macros() { # get a list of macros - COMPREPLY=( $( compgen -W "$( ${1:-rpm} --showrc | command sed -ne \ - 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p' )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(${1:-rpm} --showrc | command sed -ne \ + 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p')" \ + -- "$cur") ) } _rpm_buildarchs() { - COMPREPLY=( $( compgen -W "$( ${1:-rpm} --showrc | command sed -ne \ - 's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p' )" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(${1:-rpm} --showrc | command sed -ne \ + 's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p')" \ + -- "$cur") ) } # rpm(8) completion @@ -52,32 +52,31 @@ _rpm() # first parameter on line case $cur in --*) - COMPREPLY=( $( compgen -W '--help --version --initdb + COMPREPLY=( $(compgen -W '--help --version --initdb --checksig --addsign --delsign --rebuilddb --showrc --setperms --setugids --eval --install --upgrade --query --freshen --erase --verify --querytags --import' \ - -- "$cur" ) ) + -- "$cur") ) ;; *) - COMPREPLY=( $( compgen -W '-e -E -F -i -q -t -U -V' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-e -E -F -i -q -t -U -V' -- "$cur") ) ;; esac return fi case $prev in - --dbpath|--excludepath|--prefix|--relocate|--root|-r) + --dbpath|--excludepath|--prefix|--relocate|--root|-!(-*)r) _filedir -d return ;; - --eval|-E) + --eval|-!(-*)E) _rpm_macros $1 return ;; --pipe) compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) return ;; --rcfile) @@ -104,13 +103,13 @@ _rpm() *suggests) fmt=SUGGESTNAME ;; *supplements) fmt=SUPPLEMENTNAME ;; esac - COMPREPLY=( $( compgen -W "$( $1 -qa --nodigest --nosignature \ + COMPREPLY=( $(compgen -W "$($1 -qa --nodigest --nosignature \ --queryformat=\"%{$fmt}\\n\" 2>/dev/null | - command grep -vF '(none)' )" -- "$cur" ) ) + command grep -vF '(none)')" -- "$cur") ) fi return ;; - --define|-D|--fileid|--hdrid|--pkgid) + --define|--fileid|--hdrid|--pkgid|-!(-*)D) # argument required but no completions available return ;; @@ -125,21 +124,21 @@ _rpm() case ${words[1]} in -[iFU]*|--install|--freshen|--upgrade) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$opts --percent --force --test + COMPREPLY=( $(compgen -W "$opts --percent --force --test --replacepkgs --replacefiles --root --excludedocs --includedocs --noscripts --ignorearch --dbpath --prefix= --ignoreos --nodeps --allfiles --ftpproxy --ftpport --justdb --httpproxy --httpport --noorder --relocate= --badreloc --notriggers --excludepath= --ignoresize --oldpackage --queryformat --repackage - --nosuggests" -- "$cur" ) ) + --nosuggests" -- "$cur") ) else _filedir '[rs]pm' fi ;; -e|--erase) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$opts --allmatches --noscripts - --notriggers --nodeps --test --repackage" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts --allmatches --noscripts + --notriggers --nodeps --test --repackage" -- "$cur") ) else _rpm_installed_packages $1 fi @@ -151,64 +150,64 @@ _rpm() --fileprovide --filerequire --filesbypkg --info --list --obsoletes --pipe --provides --queryformat= --requires --scripts --suggests --triggers --xml --recommends - --supplements --filetriggers" + --supplements --filetriggers --licensefiles" - if [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then + if [[ "${words[*]}" == *\ -@(*([^ -])f|-file )* ]]; then # -qf completion if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$opts --dbpath --fscontext - --last --root --state" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts --dbpath --fscontext + --last --root --state" -- "$cur") ) else _filedir fi - elif [[ ${words[@]} == *\ -@(*([^ -])g|-group )* ]]; then + elif [[ "${words[*]}" == *\ -@(*([^ -])g|-group )* ]]; then # -qg completion _rpm_groups $1 - elif [[ ${words[@]} == *\ -@(*([^ -])p|-package )* ]]; then + elif [[ "${words[*]}" == *\ -@(*([^ -])p|-package )* ]]; then # -qp; uninstalled package completion if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$opts --ftpport --ftpproxy - --httpport --httpproxy --nomanifest" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts --ftpport --ftpproxy + --httpport --httpproxy --nomanifest" -- "$cur") ) else _filedir '[rs]pm' fi else # -q; installed package completion if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$opts --all --file --fileid + COMPREPLY=( $(compgen -W "$opts --all --file --fileid --dbpath --fscontext --ftswalk --group --hdrid --last --package --pkgid --root= --specfile --state --triggeredby --whatenhances --whatprovides --whatrecommends --whatrequires --whatsuggests --whatsupplements" \ - -- "$cur" ) ) - elif [[ ${words[@]} != *\ -@(*([^ -])a|-all )* ]]; then + -- "$cur") ) + elif [[ "${words[*]}" != *\ -@(*([^ -])a|-all )* ]]; then _rpm_installed_packages $1 fi fi ;; -K*|--checksig) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$opts --nopgp --nogpg --nomd5" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts --nopgp --nogpg --nomd5" \ + -- "$cur") ) else _filedir '[rs]pm' fi ;; -[Vy]*|--verify) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$opts --root= --dbpath --nodeps + COMPREPLY=( $(compgen -W "$opts --root= --dbpath --nodeps --nogroup --nolinkto --nomode --nomtime --nordev --nouser --nofiles --noscripts --nomd5 --querytags --specfile --whatenhances --whatprovides --whatrecommends --whatrequires --whatsuggests --whatsupplements" \ - -- "$cur" ) ) + -- "$cur") ) # check whether we're doing file completion - elif [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then + elif [[ "${words[*]}" == *\ -@(*([^ -])f|-file )* ]]; then _filedir - elif [[ ${words[@]} == *\ -@(*([^ -])g|-group )* ]]; then + elif [[ "${words[*]}" == *\ -@(*([^ -])g|-group )* ]]; then _rpm_groups $1 - elif [[ ${words[@]} == *\ -@(*([^ -])p|-package )* ]]; then + elif [[ "${words[*]}" == *\ -@(*([^ -])p|-package )* ]]; then _filedir '[rs]pm' else _rpm_installed_packages $1 @@ -222,8 +221,8 @@ _rpm() ;; --import|--dbpath|--root) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--import --dbpath --root=' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--import --dbpath --root=' \ + -- "$cur") ) else _filedir fi @@ -242,7 +241,7 @@ _rpmbuild() [[ $rpm == $1 ]] || ! type $rpm &>/dev/null && rpm= case $prev in - --buildroot|--root|-r|--dbpath) + --buildroot|--root|--dbpath|-!(-*)r) _filedir -d return ;; @@ -250,7 +249,7 @@ _rpmbuild() _rpm_buildarchs return ;; - --eval|-E) + --eval|-!(-*)E) _rpm_macros $rpm return ;; @@ -259,13 +258,13 @@ _rpmbuild() return ;; --buildpolicy) - local cfgdir=$( $rpm --eval '%{_rpmconfigdir}' 2>/dev/null ) + local cfgdir=$($rpm --eval '%{_rpmconfigdir}' 2>/dev/null) if [[ $cfgdir ]]; then - COMPREPLY=( $( compgen -W "$( command ls $cfgdir 2>/dev/null \ - | command sed -ne 's/^brp-//p' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(command ls $cfgdir 2>/dev/null \ + | command sed -ne 's/^brp-//p')" -- "$cur") ) fi ;; - --define|-D|--with|--without) + --define|--with|--without|-!(-*)D) return ;; esac @@ -273,14 +272,14 @@ _rpmbuild() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi # Figure out file extensions to complete local word ext - for word in ${words[@]}; do + for word in "${words[@]}"; do case $word in -b?|--clean|--nobuild) ext=spec diff --git a/completions/rpm2tgz b/completions/rpm2tgz index abdf321b..da4b7e5e 100644 --- a/completions/rpm2tgz +++ b/completions/rpm2tgz @@ -6,7 +6,7 @@ _rpm2tgz() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-s -S -n -r -d -c' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-s -S -n -r -d -c' -- "$cur") ) return fi diff --git a/completions/rpmcheck b/completions/rpmcheck index 565f1313..f8577c4e 100644 --- a/completions/rpmcheck +++ b/completions/rpmcheck @@ -13,8 +13,8 @@ _rpmcheck() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-explain -failures -successes -dump - -dump-all -base -help -compressed-input' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-explain -failures -successes -dump + -dump-all -base -help -compressed-input' -- "$cur") ) else _filedir fi diff --git a/completions/rrdtool b/completions/rrdtool index 705be0d0..c8214a49 100644 --- a/completions/rrdtool +++ b/completions/rrdtool @@ -6,8 +6,8 @@ _rrdtool () _init_completion || return if [[ ${#words[@]} -eq 2 ]]; then - COMPREPLY=( $( compgen -W 'create update updatev graph dump restore - last lastupdate first info fetch tune resize xport' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'create update updatev graph dump restore + last lastupdate first info fetch tune resize xport' -- "$cur") ) else _filedir rrd fi diff --git a/completions/rsync b/completions/rsync index 22593577..03495244 100644 --- a/completions/rsync +++ b/completions/rsync @@ -12,20 +12,20 @@ _rsync() _filedir return ;; - -T|--temp-dir|--compare-dest|--backup-dir|--partial-dir|--copy-dest|\ - --link-dest) + --temp-dir|--compare-dest|--backup-dir|--partial-dir|--copy-dest|\ + --link-dest|-!(-*)T) compopt +o nospace _filedir -d return ;; - -e|--rsh) + --rsh|-!(-*)e) compopt +o nospace - COMPREPLY=( $( compgen -W 'rsh ssh' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'rsh ssh' -- "$cur") ) return ;; --compress-level) compopt +o nospace - COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) return ;; esac @@ -36,7 +36,7 @@ _rsync() case $cur in -*) - COMPREPLY=( $( compgen -W '--verbose --quiet --no-motd --checksum + COMPREPLY=( $(compgen -W '--verbose --quiet --no-motd --checksum --archive --recursive --relative --no-implied-dirs --backup --backup-dir= --suffix= --update --inplace --append --append-verify --dirs --old-dirs --links --copy-links @@ -61,7 +61,7 @@ _rsync() --out-format= --log-file= --log-file-format= --password-file= --list-only --bwlimit= --write-batch= --only-write-batch= --read-batch= --protocol= --iconv= --ipv4 --ipv6 --version - --help --daemon --config= --no-detach' -- "$cur" ) ) + --help --daemon --config= --no-detach' -- "$cur") ) [[ $COMPREPLY == *= ]] || compopt +o nospace ;; *:*) diff --git a/completions/sbcl b/completions/sbcl index 3db4a39a..a8dd5345 100644 --- a/completions/sbcl +++ b/completions/sbcl @@ -9,9 +9,9 @@ _sbcl() # completing an option (may or may not be separated by a space) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--core --noinform --help --version + COMPREPLY=( $(compgen -W '--core --noinform --help --version --sysinit --userinit --eval --noprint --disable-debugger - --end-runtime-options --end-toplevel-options ' -- "$cur" ) ) + --end-runtime-options --end-toplevel-options ' -- "$cur") ) else _filedir fi diff --git a/completions/sbopkg b/completions/sbopkg index e5742af6..1504a54e 100644 --- a/completions/sbopkg +++ b/completions/sbopkg @@ -6,13 +6,13 @@ _sbopkg() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) [[ $COMPREPLY ]] && return fi case "$prev" in -e) - COMPREPLY=( $( compgen -W 'ask continue stop' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'ask continue stop' -- "$cur") ) return ;; -f) @@ -24,8 +24,8 @@ _sbopkg() return ;; -V) - COMPREPLY=( $( compgen -W "? - $( sbopkg -V ? 2>&1 | cut -s -f1 )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "? + $(sbopkg -V ? 2>&1 | cut -s -f1)" -- "$cur") ) return ;; -i|-b) @@ -61,9 +61,9 @@ _sbopkg() done [[ -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]] || return - COMPREPLY=( $( command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\ - $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ) - $( cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur" ) ) + COMPREPLY=( $(command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\ + $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT) + $(cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur") ) } && complete -F _sbopkg sbopkg diff --git a/completions/screen b/completions/screen index 6b5c319f..3b9fb272 100644 --- a/completions/screen +++ b/completions/screen @@ -2,22 +2,22 @@ _screen_sessions() { - local sessions=( $( command screen -ls | command sed -ne \ - 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p' ) ) + local sessions=( $(command screen -ls | command sed -ne \ + 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p') ) if [[ $cur == +([0-9])?(.*) ]]; then # Complete sessions including pid prefixes - COMPREPLY=( $( compgen -W '${sessions[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${sessions[@]}' -- "$cur") ) else # Create unique completions, dropping pids where possible local -A res local i tmp - for i in ${sessions[@]}; do + for i in "${sessions[@]}"; do res[${i/#+([0-9])./}]+=" $i" done - for i in ${!res[@]}; do + for i in "${!res[@]}"; do [[ ${res[$i]} == \ *\ * ]] && tmp+=" ${res[$i]}" || tmp+=" $i" done - COMPREPLY=( $( compgen -W '$tmp' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$tmp' -- "$cur") ) fi } && _screen() @@ -27,7 +27,7 @@ _screen() if ((cword > 2)); then case ${words[cword-2]} in - -[dD]) + -*[dD]) _screen_sessions return ;; @@ -37,7 +37,7 @@ _screen() local i for (( i=1; i <= cword; i++ )); do case ${words[i]} in - -r|-R|-d|-D|-x|-s|-c|-T|-e|-h|-p|-S|-t) + -*[rRdDxscTehpSt]) (( i++ )) continue ;; @@ -51,26 +51,26 @@ _screen() done case $prev in - -[rR]) + -*[rR]) # list detached _screen_sessions 'Detached' return ;; - -[dD]) + -*[dD]) # list attached _screen_sessions 'Attached' return ;; - -x) + -*x) # list both _screen_sessions return ;; - -s) + -*s) _shells return ;; - -c) + -*c) _filedir return ;; @@ -78,15 +78,15 @@ _screen() _terms return ;; - -e|-h|-p|-S|-t) + -*[ehpSt]) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-a -A -c -d -D -e -f -fn -fa -h -i -ln -list + COMPREPLY=( $(compgen -W '-a -A -c -d -D -e -f -fn -fa -h -i -ln -list -L -m -O -p -q -r -R -s -S -t -T -U -v -wipe -x -X --help - --version' -- "$cur" ) ) + --version' -- "$cur") ) fi } && complete -F _screen screen diff --git a/completions/scrub b/completions/scrub new file mode 100644 index 00000000..7fca6077 --- /dev/null +++ b/completions/scrub @@ -0,0 +1,36 @@ +# scrub(1) completion -*- shell-script -*- + +_scrub() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --version|--help|--blocksize|--device-size|--dirent|-!(-*)[vhbsD]) + return + ;; + --pattern|-!(-*)p) + COMPREPLY=( $(compgen -W '$("$1" --help 2>&1 | + awk "/^Available/{flag=1;next}/^ /&&flag{print \$1}")' \ + -- "$cur") ) + return + ;; + --freespace|-!(-*)X) + _filedir -d + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir +} && +complete -F _scrub scrub + +# ex: filetype=sh diff --git a/completions/sh b/completions/sh index fd785a6d..93f00952 100644 --- a/completions/sh +++ b/completions/sh @@ -10,24 +10,24 @@ _sh() return ;; -o|+o) - COMPREPLY=( $( compgen -W 'allexport errexit ignoreeof monitor + COMPREPLY=( $(compgen -W 'allexport errexit ignoreeof monitor noclobber noglob noexec nolog notify nounset verbose vi - xtrace' -- "$cur" ) ) + xtrace' -- "$cur") ) return ;; esac local opts="-a -b -C -e -f -h -i -m -n -o -u -v -x" if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "$opts -c -s" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts -c -s" -- "$cur") ) return elif [[ "$cur" == +* ]]; then - COMPREPLY=( $( compgen -W "${opts//-/+}" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "${opts//-/+}" -- "$cur") ) return fi local args ext= - _count_args + _count_args "" "@(-c|[-+]o)" [[ $args -eq 1 ]] && ext=sh _filedir $ext } && diff --git a/completions/shellcheck b/completions/shellcheck new file mode 100644 index 00000000..197c1811 --- /dev/null +++ b/completions/shellcheck @@ -0,0 +1,51 @@ +# bash completion for shellcheck(1) -*- shell-script -*- + +_shellcheck_optarg() +{ + local args=$("$1" --help 2>&1 | \ + command sed -e 's/,/ /g' -ne 's/^.*'$2'\>.*(\([^)]*\)).*/\1/p') + COMPREPLY+=( $(compgen -W '$args' -- "$cur") ) +} + +_shellcheck() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --version|-!(-*)V*) + return + ;; + --exclude|-!(-*)e) + return + ;; + --format|-!(-*)f) + local args=$("$1" --format=nonexistent-format /dev/null 2>&1 | \ + command sed -ne '/^Supported formats/,//p' | \ + command sed -ne '/^[[:space:]]/p') + COMPREPLY=( $(compgen -W '$args' -- "$cur") ) + return + ;; + --color|-!(-*)C) + _shellcheck_optarg "$1" --color + return + ;; + --shell|-!(-*)s) + _shellcheck_optarg "$1" --shell + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir +} && +complete -F _shellcheck shellcheck + +# ex: filetype=sh diff --git a/completions/sitecopy b/completions/sitecopy index ef1310df..dae0548d 100644 --- a/completions/sitecopy +++ b/completions/sitecopy @@ -9,17 +9,17 @@ _sitecopy() _init_completion -s || return case $prev in - --debug|-d) - COMPREPLY=( $( compgen -W "socket files rcfile ftp http httpbody - rsh sftp xml xmlparse cleartext" -- "$cur" ) ) + --debug|-!(-*)d) + COMPREPLY=( $(compgen -W "socket files rcfile ftp http httpbody + rsh sftp xml xmlparse cleartext" -- "$cur") ) compopt -o nospace return ;; - --logfile|-g|--rcfile|-r) + --logfile|--rcfile|-!(-*)[gr]) _filedir return ;; - --storepath|-p) + --storepath|-!(-*)p) _filedir -d return ;; @@ -27,7 +27,7 @@ _sitecopy() case $cur in --*) - COMPREPLY=( $( compgen -W "$(_parse_help $1)" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(_parse_help $1)" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return ;; @@ -41,8 +41,8 @@ _sitecopy() esac if [[ -r ~/.sitecopyrc ]]; then - COMPREPLY=( $( compgen -W "$($1 -v | \ - command sed -n '/^Site:/s/Site: //p')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 -v | \ + command sed -n '/^Site:/s/Site: //p')" -- "$cur") ) fi } && complete -F _sitecopy -o default sitecopy diff --git a/completions/slackpkg b/completions/slackpkg index 83396a4e..a1d500dc 100644 --- a/completions/slackpkg +++ b/completions/slackpkg @@ -16,11 +16,11 @@ _slackpkg() case "$prev" in -delall|-checkmd5|-checkgpg|-checksize|-postinst|-onoff|-download_all|\ -dialog|-batch|-only_new_dotnew|-use_includes|-spinning) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; -default_answer) - COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'yes no' -- "$cur") ) return ;; -dialog_maxargs|-mirror) @@ -33,10 +33,10 @@ _slackpkg() if [[ "$cur" == -* ]]; then compopt -o nospace - COMPREPLY=( $( compgen -W '-delall= -checkmd5= -checkgpg= + COMPREPLY=( $(compgen -W '-delall= -checkmd5= -checkgpg= -checksize= -postinst= -onoff= -download_all= -dialog= -dialog_maxargs= -batch= -only_new_dotnew= -use_includes= - -spinning= -default_answer= -mirror=' -- "$cur" ) ) + -spinning= -default_answer= -mirror=' -- "$cur") ) return fi @@ -61,42 +61,42 @@ _slackpkg() ;; install-template|remove-template) if [[ -e $confdir/templates ]]; then - COMPREPLY=( $( cd "$confdir/templates"; \ - compgen -f -X "!*.template" -- "$cur" ) ) + COMPREPLY=( $(cd "$confdir/templates"; \ + compgen -f -X "!*.template" -- "$cur") ) COMPREPLY=( ${COMPREPLY[@]%.template} ) fi return ;; remove) _filedir - COMPREPLY+=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x - xap xfce y' -- "$cur" ) ) - COMPREPLY+=( $( cd /var/log/packages; compgen -f -- "$cur" ) ) + COMPREPLY+=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x + xap xfce y' -- "$cur") ) + COMPREPLY+=( $(cd /var/log/packages; compgen -f -- "$cur") ) return ;; install|reinstall|upgrade|blacklist|download) _filedir - COMPREPLY+=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x - xap xfce y' -- "$cur" ) ) - COMPREPLY+=( $( cut -f 6 -d\ "${WORKDIR}/pkglist" 2> /dev/null | \ - command grep "^$cur" ) ) + COMPREPLY+=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x + xap xfce y' -- "$cur") ) + COMPREPLY+=( $(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null | \ + command grep "^$cur") ) return ;; info) - COMPREPLY=( $( cut -f 6 -d\ "${WORKDIR}/pkglist" 2> /dev/null | \ - command grep "^$cur" ) ) + COMPREPLY=( $(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null | \ + command grep "^$cur") ) return ;; update) # we should complete the same as the next `list` + "gpg" - COMPREPLY=( $( compgen -W 'gpg' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'gpg' -- "$cur") ) ;& *) - COMPREPLY+=( $( compgen -W 'install reinstall upgrade remove + COMPREPLY+=( $(compgen -W 'install reinstall upgrade remove blacklist download update install-new upgrade-all clean-system new-config check-updates help generate-template install-template remove-template search file-search info' -- \ - "$cur" ) ) + "$cur") ) return ;; esac diff --git a/completions/slapt-get b/completions/slapt-get index 512981b6..9b249f19 100644 --- a/completions/slapt-get +++ b/completions/slapt-get @@ -17,7 +17,7 @@ _slapt_get() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY ]] && return fi @@ -56,22 +56,22 @@ _slapt_get() # slapt-get will fail to search for "^name-version" # it can search for names only local name=${cur%%-*} - COMPREPLY=( $( LC_ALL=C "$1" -c "$config" --search "^$name" 2> \ - /dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}" ) ) + COMPREPLY=( $(LC_ALL=C "$1" -c "$config" --search "^$name" \ + 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") ) return ;; avl) # --install|-i| - COMPREPLY=( $( LC_ALL=C "$1" -c "$config" --available 2> \ - /dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}" ) ) + COMPREPLY=( $(LC_ALL=C "$1" -c "$config" --available \ + 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") ) return ;; ins) # --remove|--filelist - COMPREPLY=( $( cd /var/log/packages; compgen -f -- "$cur" ) ) + COMPREPLY=( $(cd /var/log/packages; compgen -f -- "$cur") ) return ;; set) # --install-set - COMPREPLY=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x - xap xfce y' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x + xap xfce y' -- "$cur") ) return ;; esac diff --git a/completions/slapt-src b/completions/slapt-src index 2f65415f..64458bab 100644 --- a/completions/slapt-src +++ b/completions/slapt-src @@ -19,7 +19,7 @@ _slapt_src() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY ]] && return fi @@ -54,12 +54,12 @@ _slapt_src() if [[ "$cur" == *:* ]]; then local name=${cur%:*} local version=${cur##*:} - COMPREPLY=( $( LC_ALL=C "$1" --config "$config" --search "^$name" 2> \ - /dev/null | LC_ALL=C command sed -ne \ - "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}" ) ) + COMPREPLY=( $(LC_ALL=C "$1" --config "$config" --search "^$name" \ + 2>/dev/null | LC_ALL=C command sed -ne \ + "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}") ) else - COMPREPLY=( $( LC_ALL=C "$1" --config "$config" --search "^$cur" 2> \ - /dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}" ) ) + COMPREPLY=( $(LC_ALL=C "$1" --config "$config" --search "^$cur" \ + 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") ) fi } && complete -F _slapt_src slapt-src diff --git a/completions/smartctl b/completions/smartctl index 3e952aa2..c34ca598 100644 --- a/completions/smartctl +++ b/completions/smartctl @@ -2,23 +2,23 @@ _smartctl_quietmode() { - COMPREPLY=( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'errorsonly silent noserial' -- "$cur") ) } _smartctl_device() { case $cur in areca*|3ware*|megaraid*|cciss*) COMPREPLY+=( ${cur%%,*},{0..31} ) - COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") ) ;; hpt*) COMPREPLY+=( hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5} ) - COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") ) ;; *) - COMPREPLY=( $( compgen -W "ata scsi sat usbcypress usbjmicron + COMPREPLY=( $(compgen -W "ata scsi sat usbcypress usbjmicron usbsunplus marvell areca 3ware hpt megaraid cciss auto test" \ - -- "$cur" ) ) + -- "$cur") ) case "${COMPREPLY[@]}" in areca|3ware|hpt|megaraid|cciss) compopt -o nospace @@ -29,59 +29,59 @@ _smartctl_device() } _smartctl_tolerance() { - COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'normal conservative permissive verypermissive' \ + -- "$cur") ) } _smartctl_badsum() { - COMPREPLY=( $( compgen -W 'warn exit ignore' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'warn exit ignore' -- "$cur") ) } _smartctl_report() { - COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'ioctl ataioctl scsiioctl' -- "$cur") ) } _smartctl_powermode() { - COMPREPLY=( $( compgen -W 'never sleep standby idle' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'never sleep standby idle' -- "$cur") ) } _smartctl_feature() { - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) } _smartctl_log() { - COMPREPLY=( $( compgen -W 'error selftest selective directory background + COMPREPLY=( $(compgen -W 'error selftest selective directory background sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts - scttemphist scterc gplog smartlog xerror xselftest' -- "$cur" ) ) + scttemphist scterc gplog smartlog xerror xselftest' -- "$cur") ) } _smartctl_vendorattribute() { - COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp + COMPREPLY=( $(compgen -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp 192,emergencyretractcyclect 193,loadunload 194,10xCelsius 194,unknown 198,offlinescanuncsectorct 200,writeerrorcount 201,detectedtacount - 220,temp' -- "$cur" ) ) + 220,temp' -- "$cur") ) } _smartctl_firmwarebug() { - COMPREPLY=( $( compgen -W 'none samsung samsung2 samsung3 swapid' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'none samsung samsung2 samsung3 swapid' \ + -- "$cur") ) } _smartctl_presets() { - COMPREPLY=( $( compgen -W 'use ignore show showall' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'use ignore show showall' -- "$cur") ) } _smartctl_test() { [[ $cur == @(pending|scttempint|vendor), ]] && return - COMPREPLY=( $( compgen -W 'offline short long conveyance select, + COMPREPLY=( $(compgen -W 'offline short long conveyance select, select,redo select,next afterselect,on afterselect,off pending, - scttempint, vendor,' -- "$cur" ) ) + scttempint, vendor,' -- "$cur") ) [[ $COMPREPLY == *, ]] && compopt -o nospace } _smartctl_drivedb() { local prefix= - if [[ $cur == +* ]] ; then + if [[ $cur == +* ]]; then prefix=+ cur="${cur#+}" fi @@ -95,54 +95,54 @@ _smartctl() _init_completion -s || return case $prev in - -q|--quietmode) + --quietmode|-!(-*)q) _smartctl_quietmode ;; - -d|--device) + --device|-!(-*)d) _smartctl_device return ;; - -T|--tolerance) + --tolerance|-!(-*)T) _smartctl_tolerance return ;; - -b|--badsum) + --badsum|-!(-*)b) _smartctl_badsum return ;; - -r|--report) + --report|-!(-*)r) _smartctl_report return ;; - -n|--nocheck) + --nocheck|-!(-*)n) _smartctl_powermode return ;; - -s|--smart|-o|--offlineauto|-S|--saveauto) + --smart|--offlineauto|--saveauto|-!(-*)[soS]) _smartctl_feature return ;; - -l|--log) + --log|-!(-*)l) _smartctl_log return ;; - -v|--vendorattribute) + --vendorattribute|-!(-*)v) _smartctl_vendorattribute return ;; - -F|--firmwarebug) + --firmwarebug|-!(-*)F) _smartctl_firmwarebug return ;; - -P|--presets) + --presets|-!(-*)P) _smartctl_presets return ;; - -B|--drivedb) + --drivedb|-!(-*)B) _smartctl_drivedb return ;; - -t|--test) + --test|-!(-*)t) _smartctl_test return ;; @@ -151,12 +151,12 @@ _smartctl() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version --info --all --xall + COMPREPLY=( $(compgen -W '--help --version --info --all --xall --scan --scan-open --quietmode= --device= --tolerance= --badsum= --report= --nocheck= --smart= --offlineauto= --saveauto= --health --capabilities --attributes --log= --vendorattribute= --firmwarebug= --presets= --drivedb= --test= --captive --abort' \ - -- "$cur" ) ) + -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else cur=${cur:=/dev/} diff --git a/completions/smbclient b/completions/smbclient index 3a5616cd..c896ce42 100644 --- a/completions/smbclient +++ b/completions/smbclient @@ -2,40 +2,40 @@ _samba_resolve_order() { - COMPREPLY=( $( compgen -W 'lmhosts host wins bcast' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'lmhosts host wins bcast' -- "$cur") ) } _samba_domains() { if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then - COMPREPLY=( $( compgen -W '$( smbtree -N -D )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(smbtree -N -D)' -- "$cur") ) fi } _samba_hosts() { if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then - COMPREPLY=( $( compgen -W "$( smbtree -N -S | \ + COMPREPLY=( $(compgen -W "$(smbtree -N -S | \ command sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \ - )" -- "$cur" ) ) + )" -- "$cur") ) fi } _samba_debuglevel() { - COMPREPLY=( $( compgen -W '{0..10}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") ) } _samba_sockopts() { - COMPREPLY=( $( compgen -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST + COMPREPLY=( $(compgen -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST TCP_NODELAY IPTOS_LOWDELAY IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF - SO_SNDLOWAT SO_RCVLOWAT' -- "$cur" ) ) + SO_SNDLOWAT SO_RCVLOWAT' -- "$cur") ) } _samba_signing() { - COMPREPLY=( $( compgen -W 'on off required' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off required' -- "$cur") ) } _smbclient() @@ -44,54 +44,52 @@ _smbclient() _init_completion -s || return case $prev in - -R|--name-resolve) + --name-resolve|-!(-*)R) _samba_resolve_order return ;; - -t) - COMPREPLY=( $( compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \ - -- "$cur" ) ) + -!(-*)t) + COMPREPLY=( $(compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \ + -- "$cur") ) return ;; - -s|--configfile|-A|--authentication-file) + --configfile|--authentication-file|-!(-*)[sA]) _filedir return ;; - -l|--log-basename|-D|--directory) + --log-basename|--directory|-!(-*)[lD]) _filedir -d return ;; - -O|--socket-options) + --socket-options|-!(-*)O) _samba_sockopts return ;; - -T) - COMPREPLY=( $( compgen -W 'c x I X F b g q r N a' -- "$cur" ) ) + -!(-*)T) + COMPREPLY=( $(compgen -W 'c x I X F b g q r N a' -- "$cur") ) return ;; - -W|--workgroup) + --workgroup|-!(-*)W) _samba_domains return ;; - -d|--debuglevel) + --debuglevel|-!(-*)d) _samba_debuglevel return ;; - -L|--list) + --list|-!(-*)L) _samba_hosts return ;; - -S|--signing) + --signing|-!(-*)S) _samba_signing return ;; - -p|--port|-M|--message|-I|--ip-address|-b|--send-buffer|-U|--user|-n|\ - --netbiosname|-i|--scope|-T|--tar|-c|--command|-m|--max-protocol) - # argument required but no completions available + --port|--message|--ip-address|--send-buffer|--user|--netbiosname|\ + --scope|--tar|--command|--max-protocol|-!(-*)[pMIbUniTcm]) return ;; - -\?|--help|-V|--version) - # all other arguments are noop with these + --help|--version|-!(-*)[?V]) return ;; esac @@ -99,7 +97,7 @@ _smbclient() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && @@ -111,19 +109,19 @@ _smbget() _init_completion -s || return case $prev in - -o|--outputfile|-f|--rcfile) + --outputfile|--rcfile|-!(-*)[of]) _filedir return ;; - -d|--debuglevel) + --debuglevel|-!(-*)d) _samba_debuglevel return ;; - -w|--workgroup) + --workgroup|-!(-*)w) _samba_domains return ;; - -u|--username|-p|--password|-b|--blocksize) + --username|--password|--blocksize|-!(-*)[upb]) return ;; esac @@ -131,7 +129,7 @@ _smbget() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && @@ -143,15 +141,15 @@ _smbcacls() _init_completion -s || return case $prev in - -s|--configfile|-A|--authentication-file) + --configfile|--authentication-file|-!(-*)[As]) _filedir return ;; - -l|--log-basename) + --log-basename|-!(-*)l) _filedir -d return ;; - -d|--debuglevel) + --debuglevel|-!(-*)d) _samba_debuglevel return ;; @@ -159,16 +157,16 @@ _smbcacls() _samba_signing return ;; - -O|--socket-options) + --socket-options|-!(-*)O) _samba_sockopts return ;; - -W|--workgroup) + --workgroup|-!(-*)W) _samba_domains return ;; - -\?|--help|--usage|-D|--delete|-M|--modify|-a|--add|-S|--set|-C|\ - --chown|-G|--chgrp|-n|--netbiosname|-i|--scope|-U|--user) + --help|--usage|--delete|--modify|--add|--set|--chown|--chgrp|\ + --netbiosname|--scope|--user|-!(-*)[?DMaSCGniU]) return ;; esac @@ -176,7 +174,7 @@ _smbcacls() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && @@ -188,15 +186,15 @@ _smbcquotas() _init_completion -s || return case $prev in - -s|--configfile|-A|--authentication-file) + --configfile|--authentication-file|-!(-*)[sA]) _filedir return ;; - -l|--log-basename) + --log-basename|-!(-*)l) _filedir -d return ;; - -d|--debuglevel) + --debuglevel|-!(-*)d) _samba_debuglevel return ;; @@ -204,7 +202,7 @@ _smbcquotas() _samba_signing return ;; - -\?|--help|--usage|-U|-u|--user|-S|--set) + --help|--usage|--user|--set|-!(-*)[?UuS]) return ;; esac @@ -212,7 +210,7 @@ _smbcquotas() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && @@ -224,29 +222,29 @@ _smbpasswd() _init_completion || return case $prev in - -r) + -*r) _samba_hosts return ;; - -R) + -*R) _samba_resolve_order return ;; - -c) + -*c) _filedir return ;; - -D) + -*D) _samba_debuglevel return ;; - -U|-h|-w) + -*[Uhw]) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) fi } && complete -F _smbpasswd smbpasswd @@ -257,29 +255,29 @@ _smbtar() _init_completion || return case $prev in - -r|-t) + -*[rt]) _filedir tar return ;; - -s) + -*s) _samba_hosts return ;; - -l) + -*l) _samba_debuglevel return ;; - -N) + -*N) _filedir return ;; - -p|-x|-b|-d|-u) + -*[pxbdu]) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _smbtar smbtar @@ -290,23 +288,23 @@ _smbtree() _init_completion -s || return case $prev in - -s|--configfile|-A|--authentication-file) + --configfile|--authentication-file|-!(-*)[sA]) _filedir return ;; - -l|--log-basename) + --log-basename|-!(-*)l) _filedir -d return ;; - -d|--debuglevel) + --debuglevel|-!(-*)d) _samba_debuglevel return ;; - -S|--signing) + --signing|-!(-*)S) _samba_signing return ;; - -\?|--help|--usage|-U|--user) + --help|--usage|--user|-!(-*)[?U]) return ;; esac @@ -314,7 +312,7 @@ _smbtree() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/snownews b/completions/snownews index b5b070da..3938454f 100644 --- a/completions/snownews +++ b/completions/snownews @@ -7,7 +7,7 @@ _snownews() if [[ "$cur" == -* ]]; then # return list of available options - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) fi } && complete -F _snownews snownews diff --git a/completions/sqlite3 b/completions/sqlite3 index 37d78a01..a7005489 100644 --- a/completions/sqlite3 +++ b/completions/sqlite3 @@ -8,17 +8,26 @@ _sqlite3() local dbexts='@(sqlite?(3)|?(s?(3))db)' case $prev in - -help|-version|-separator|-nullvalue|*.$dbexts) + -help|-version|-lookaside|-mmap|-newline|-nullvalue|-pagecache|\ + -scratch|-separator|*.$dbexts) return ;; -init) _filedir return ;; + -cmd) + compopt -o filenames + COMPREPLY=( $(compgen -c -- "$cur") ) + return + ;; esac + [[ $cword -gt 2 && ${words[cword-2]} == -@(lookaside|pagecache|scratch) ]] \ + && return + if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) return fi diff --git a/completions/ss b/completions/ss index b240c5e0..05e4e4b2 100644 --- a/completions/ss +++ b/completions/ss @@ -6,23 +6,23 @@ _ss() _init_completion -s || return case $prev in - -h|--help|-V|--version) + --help|--version|-!(-*)[hV]) return ;; - -f|--family) - COMPREPLY=( $( compgen -W 'unix inet inet6 link netlink' \ - -- "$cur" ) ) + --family|-!(-*)f) + COMPREPLY=( $(compgen -W 'unix inet inet6 link netlink' \ + -- "$cur") ) return ;; - -A|--query) + --query|-!(-*)A) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -W '$( "$1" --help | \ - command sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p" )' \ - -- "${cur##*,}" ) ) + COMPREPLY=( $(compgen -W '$("$1" --help | \ + command sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p")' \ + -- "${cur##*,}") ) [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; - -D|--diag|-F|--filter) + --diag|--filter|-!(-*)[DF]) _filedir return ;; @@ -31,7 +31,7 @@ _ss() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/ssh b/completions/ssh index ba3d4b45..aaa10346 100644 --- a/completions/ssh +++ b/completions/ssh @@ -2,8 +2,9 @@ _ssh_queries() { - COMPREPLY+=( $( compgen -W \ - "cipher cipher-auth mac kex key protocol-version" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W \ + "cipher cipher-auth mac kex key key-cert key-plain protocol-version" \ + -- "$cur") ) } _ssh_query() @@ -13,44 +14,61 @@ _ssh_query() _ssh_ciphers() { - local ciphers='$( _ssh_query "$1" cipher )' + local ciphers='$(_ssh_query "$1" cipher)' [[ $ciphers ]] || ciphers="3des-cbc aes128-cbc aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour blowfish-cbc cast128-cbc" - COMPREPLY+=( $( compgen -W "$ciphers" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W "$ciphers" -- "$cur") ) } _ssh_macs() { - local macs='$( _ssh_query "$1" mac )' + local macs='$(_ssh_query "$1" mac)' [[ $macs ]] || macs="hmac-md5 hmac-sha1 umac-64@openssh.com hmac-ripemd160 hmac-sha1-96 hmac-md5-96" - COMPREPLY+=( $( compgen -W "$macs" -- "$cur" ) ) + COMPREPLY+=( $(compgen -W "$macs" -- "$cur") ) } _ssh_options() { - compopt -o nospace - COMPREPLY=( $( compgen -S = -W 'AddressFamily BatchMode BindAddress - ChallengeResponseAuthentication CheckHostIP Cipher Ciphers - ClearAllForwardings Compression CompressionLevel ConnectionAttempts - ConnectTimeout ControlMaster ControlPath ControlPersist DynamicForward - EnableSSHKeysign EscapeChar ExitOnForwardFailure ForwardAgent - ForwardX11 ForwardX11Timeout ForwardX11Trusted GatewayPorts - GlobalKnownHostsFile GSSAPIAuthentication GSSAPIClientIdentity - GSSAPIDelegateCredentials GSSAPIKeyExchange GSSAPIRenewalForcesRekey - GSSAPIServerIdentity GSSAPITrustDns HashKnownHosts Host - HostbasedAuthentication HostKeyAlgorithms HostKeyAlias HostName - IdentityFile IdentitiesOnly IPQoS KbdInteractiveDevices KexAlgorithms + local opts=( + AddKeysToAgent AddressFamily BatchMode BindAddress CanonicalDomains + CanonicalizeFallbackLocal CanonicalizeHostname CanonicalizeMaxDots + CanonicalizePermittedCNAMEs CertificateFile + ChallengeResponseAuthentication CheckHostIP Ciphers ClearAllForwardings + Compression ConnectionAttempts ConnectTimeout ControlMaster ControlPath + ControlPersist DynamicForward EnableSSHKeysign EscapeChar + ExitOnForwardFailure FingerprintHash ForwardAgent ForwardX11 + ForwardX11Timeout ForwardX11Trusted GatewayPorts GlobalKnownHostsFile + GSSAPIAuthentication GSSAPIClientIdentity GSSAPIDelegateCredentials + GSSAPIKeyExchange GSSAPIRenewalForcesRekey GSSAPIServerIdentity + GSSAPITrustDns HashKnownHosts Host HostbasedAuthentication + HostbasedKeyTypes HostKeyAlgorithms HostKeyAlias HostName + IdentitiesOnly IdentityAgent IdentityFile IgnoreUnknown Include IPQoS + KbdInteractiveAuthentication KbdInteractiveDevices KexAlgorithms LocalCommand LocalForward LogLevel MACs - NoHostAuthenticationForLocalhost NumberOfPasswordPrompts ProxyJump + NoHostAuthenticationForLocalhost NumberOfPasswordPrompts PasswordAuthentication PermitLocalCommand PKCS11Provider Port - PreferredAuthentications Protocol ProxyCommand PubkeyAuthentication - RekeyLimit RemoteForward RequestTTY RhostsRSAAuthentication - RSAAuthentication SendEnv ServerAliveCountMax ServerAliveInterval - SmartcardDevice StrictHostKeyChecking TCPKeepAlive Tunnel TunnelDevice - UsePrivilegedPort User UserKnownHostsFile VerifyHostKeyDNS - VisualHostKey XAuthLocation' -- "$cur" ) ) + PreferredAuthentications ProxyCommand ProxyJump ProxyUseFdpass + PubkeyAcceptedKeyTypes PubkeyAuthentication RekeyLimit RemoteCommand + RemoteForward RequestTTY RevokedHostKeys SendEnv ServerAliveCountMax + ServerAliveInterval SmartcardDevice StreamLocalBindMask + StreamLocalBindUnlink StrictHostKeyChecking SyslogFacility TCPKeepAlive + Tunnel TunnelDevice UpdateHostKeys UsePrivilegedPort User + UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation ) + local protocols=$(_ssh_query "$1" protocol-version) + if [[ -z $protocols || $protocols == *1* ]]; then + opts+=( Cipher CompressionLevel Protocol RhostsRSAAuthentication + RSAAuthentication ) + fi + + compopt -o nospace + local IFS=$' \t\n' reset=$(shopt -p nocasematch); shopt -s nocasematch + local option + COMPREPLY=( $(for option in "${opts[@]}"; do + [[ $option == "$cur"* ]] && printf '%s=\n' "$option" + done) ) + $reset } # Complete a ssh suboption (like ForwardAgent=y) @@ -63,61 +81,90 @@ _ssh_suboption() # Split into subopt and subval local prev=${1%%=*} cur=${1#*=} - case $prev in - BatchMode|ChallengeResponseAuthentication|CheckHostIP|\ - ClearAllForwardings|ControlPersist|Compression|EnableSSHKeysign|\ - ExitOnForwardFailure|ForwardAgent|ForwardX11|ForwardX11Trusted|\ - GatewayPorts|GSSAPIAuthentication|GSSAPIKeyExchange|\ - GSSAPIDelegateCredentials|GSSAPIRenewalForcesRekey|GSSAPITrustDns|\ - HashKnownHosts|HostbasedAuthentication|IdentitiesOnly|\ - KbdInteractiveAuthentication|KbdInteractiveDevices|\ - NoHostAuthenticationForLocalhost|PasswordAuthentication|\ - PubkeyAuthentication|RhostsRSAAuthentication|RSAAuthentication|\ - StrictHostKeyChecking|TCPKeepAlive|UsePrivilegedPort|\ - VerifyHostKeyDNS|VisualHostKey) - COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) ) - ;; - AddressFamily) - COMPREPLY=( $( compgen -W 'any inet inet6' -- "$cur" ) ) - ;; - BindAddress) + case ${prev,,} in + batchmode|canonicaldomains|canonicalizefallbacklocal|\ + challengeresponseauthentication|checkhostip|\ + clearallforwardings|controlpersist|compression|enablesshkeysign|\ + exitonforwardfailure|forwardagent|forwardx11|forwardx11trusted|\ + gatewayports|gssapiauthentication|gssapikeyexchange|\ + gssapidelegatecredentials|gssapirenewalforcesrekey|gssapitrustdns|\ + hashknownhosts|hostbasedauthentication|identitiesonly|\ + kbdinteractiveauthentication|kbdinteractivedevices|\ + nohostauthenticationforlocalhost|passwordauthentication|\ + proxyusefdpass|pubkeyauthentication|rhostsrsaauthentication|\ + rsaauthentication|stricthostkeychecking|streamlocalbindunlink|\ + tcpkeepalive|useprivilegedport|verifyhostkeydns|visualhostkey) + COMPREPLY=( $(compgen -W 'yes no' -- "$cur") ) + ;; + addkeystoagent) + COMPREPLY=( $(compgen -W 'yes ask confirm no' -- "$cur") ) + ;; + addressfamily) + COMPREPLY=( $(compgen -W 'any inet inet6' -- "$cur") ) + ;; + bindaddress) _ip_addresses ;; - Cipher) - COMPREPLY=( $( compgen -W 'blowfish des 3des' -- "$cur" ) ) + canonicalizehostname) + COMPREPLY=( $(compgen -W 'yes no always' -- "$cur") ) ;; - ProxyJump) - _known_hosts_real -a -F "$configfile" -- "$cur" + *file|identityagent|include) + _filedir ;; - IPQoS) - COMPREPLY=( $( compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3} - cs{0..7} ef lowdelay throughput reliability' -- "$cur" ) ) + cipher) + COMPREPLY=( $(compgen -W 'blowfish des 3des' -- "$cur") ) ;; - HostbasedKeyTypes|HostKeyAlgorithms) - COMPREPLY=( $( compgen -W '$( _ssh_query "$2" key )' -- "$cur" ) ) + ciphers) + _ssh_ciphers "$2" ;; - KexAlgorithms) - COMPREPLY=( $( compgen -W '$( _ssh_query "$2" kex )' -- "$cur" ) ) + compressionlevel) + COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) ;; - Protocol) - COMPREPLY=( $( compgen -W '1 2 1,2 2,1' -- "$cur" ) ) + fingerprinthash) + COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") ) ;; - RequestTTY) - COMPREPLY=( $( compgen -W 'no yes force auto' -- "$cur" ) ) + ipqos) + COMPREPLY=( $(compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3} + cs{0..7} ef lowdelay throughput reliability' -- "$cur") ) ;; - Tunnel) - COMPREPLY=( $( compgen -W 'yes no point-to-point ethernet' \ - -- "$cur" ) ) + hostbasedkeytypes|hostkeyalgorithms) + COMPREPLY=( $(compgen -W '$(_ssh_query "$2" key)' -- "$cur") ) ;; - PreferredAuthentications) - COMPREPLY=( $( compgen -W 'gssapi-with-mic host-based publickey - keyboard-interactive password' -- "$cur" ) ) + kexalgorithms) + COMPREPLY=( $(compgen -W '$(_ssh_query "$2" kex)' -- "$cur") ) ;; - MACs) + macs) _ssh_macs "$2" ;; - Ciphers) - _ssh_ciphers "$2" + preferredauthentications) + COMPREPLY=( $(compgen -W 'gssapi-with-mic host-based publickey + keyboard-interactive password' -- "$cur") ) + ;; + protocol) + local protocols=( $(_ssh_query "$2" protocol-version) ) + [[ $protocols ]] || protocols=(1 2) + if [[ ${#protocols[@]} -gt 1 ]]; then + COMPREPLY=( $(compgen -W '${protocols[@]}' -- "$cur") ) + fi + ;; + proxyjump) + _known_hosts_real -a -F "$configfile" -- "$cur" + ;; + pubkeyacceptedkeytypes) + COMPREPLY=( $(compgen -W '$(_ssh_query "$2" key)' -- "$cur") ) + ;; + requesttty) + COMPREPLY=( $(compgen -W 'no yes force auto' -- "$cur") ) + ;; + syslogfacility) + COMPREPLY=( $(compgen -W 'DAEMON USER AUTH LOCAL{0..7}' -- "$cur") ) + ;; + tunnel) + COMPREPLY=( $(compgen -W 'yes no point-to-point ethernet' \ + -- "$cur") ) + ;; + updatehostkeys) + COMPREPLY=( $(compgen -W 'yes no ask' -- "$cur") ) ;; esac return 0 @@ -130,7 +177,7 @@ _ssh_suboption_check() { # Get prev and cur words without splitting on = local cureq=`_get_cword :=` preveq=`_get_pword :=` - if [[ $cureq == *=* && $preveq == -o ]]; then + if [[ $cureq == *=* && $preveq == -*o ]]; then _ssh_suboption $cureq "$1" return $? fi @@ -170,55 +217,58 @@ _ssh() local ipvx case $prev in - -F|-i|-S) - _filedir - return + -*4*) + ipvx=-4 ;; - -I) - _filedir so + -*6*) + ipvx=-6 + ;; + -*b) + _ip_addresses return ;; - -c) + -*c) _ssh_ciphers "$1" return ;; - -J) - _known_hosts_real -a -F "$configfile" -- "$cur" + -*[DeLpRW]) return ;; - -m) - _ssh_macs "$1" + -*[EFiS]) + _filedir return ;; - -l) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + -*I) + _filedir so return ;; - -O) - COMPREPLY=( $( compgen -W 'check forward exit stop' -- "$cur" ) ) + -*J) + _known_hosts_real -a -F "$configfile" -- "$cur" return ;; - -o) - _ssh_options + -*l) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; - -Q) - _ssh_queries "$1" + -*m) + _ssh_macs "$1" return ;; - -w) - _available_interfaces + -*O) + COMPREPLY=( $(compgen -W 'check forward exit stop' -- "$cur") ) return ;; - -b) - _ip_addresses + -*o) + _ssh_options "$1" return ;; - -D|-e|-L|-p|-R|-W) + -*Q) + _ssh_queries "$1" return ;; - -4|-6) - ipvx=$prev + -*w) + _available_interfaces + return ;; esac @@ -229,7 +279,7 @@ _ssh() COMPREPLY=( "${COMPREPLY[@]/#/-F}" ) cur=-F$cur # Restore cur elif [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _known_hosts_real $ipvx -a -F "$configfile" -- "$cur" @@ -237,7 +287,7 @@ _ssh() _count_args if [[ $args -gt 1 ]]; then compopt -o filenames - COMPREPLY+=( $( compgen -c -- "$cur" ) ) + COMPREPLY+=( $(compgen -c -- "$cur") ) fi fi } && @@ -258,28 +308,31 @@ _sftp() local ipvx case $prev in - -b|-F|-i) - _filedir + -*4*) + ipvx=-4 + ;; + -*6*) + ipvx=-6 + ;; + -*[BDlPRs]) return ;; - -o) - _ssh_options + -*[bFi]) + _filedir return ;; - -c) + -*c) _ssh_ciphers return ;; - -S) - _command + -*o) + _ssh_options return ;; - -B|-D|-l|-P|-R|-s) + -*S) + _command return ;; - -4|-6) - ipvx=$prev - ;; esac if [[ "$cur" == -F* ]]; then @@ -289,7 +342,7 @@ _sftp() COMPREPLY=( "${COMPREPLY[@]/#/-F}" ) cur=-F$cur # Restore cur elif [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _known_hosts_real $ipvx -a -F "$configfile" -- "$cur" fi @@ -312,7 +365,7 @@ _scp_remote_files() local path=${cur#*:} # unescape (3 backslashes to 1 for chars we escaped) - path=$( command sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path" ) + path=$(command sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path") # default to home dir of specified user on remote host if [[ -z $path ]]; then @@ -322,16 +375,16 @@ _scp_remote_files() local files if [[ $1 == -d ]]; then # escape problematic characters; remove non-dirs - files=$( ssh -o 'Batchmode yes' $userhost \ + files=$(ssh -o 'Batchmode yes' $userhost \ command ls -aF1dL "$path*" 2>/dev/null | \ - command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d' ) + command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d') else # escape problematic characters; remove executables, aliases, pipes # and sockets; add space at end of file names - files=$( ssh -o 'Batchmode yes' $userhost \ + files=$(ssh -o 'Batchmode yes' $userhost \ command ls -aF1dL "$path*" 2>/dev/null | \ command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \ - -e 's/[^\/]$/& /g' ) + -e 's/[^\/]$/& /g') fi COMPREPLY+=( $files ) } @@ -351,10 +404,10 @@ _scp_local_files() fi if $dirsonly ; then - COMPREPLY+=( $( command ls -aF1dL $cur* 2>/dev/null | \ + COMPREPLY+=( $(command ls -aF1dL $cur* 2>/dev/null | \ command sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") ) else - COMPREPLY+=( $( command ls -aF1dL $cur* 2>/dev/null | \ + COMPREPLY+=( $(command ls -aF1dL $cur* 2>/dev/null | \ command sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \ -e 's/[^\/]$/& /g' -e "s/^/$1/") ) fi @@ -378,31 +431,34 @@ _scp() local ipvx case $prev in - -l|-P) + -*4*) + ipvx=-4 + ;; + -*6*) + ipvx=-6 + ;; + -*c) + _ssh_ciphers + COMPREPLY=( "${COMPREPLY[@]/%/ }" ) return ;; - -F|-i) + -*[Fi]) _filedir compopt +o nospace return ;; - -c) - _ssh_ciphers - COMPREPLY=( "${COMPREPLY[@]/%/ }" ) + -*[lP]) return ;; - -o) + -*o) _ssh_options return ;; - -S) + -*S) _command compopt +o nospace return ;; - -4|-6) - ipvx=$prev - ;; esac _expand || return @@ -420,8 +476,8 @@ _scp() else case $cur in -*) - COMPREPLY=( $( compgen -W '$( _parse_usage "${words[0]}" )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "${words[0]}")' \ + -- "$cur") ) COMPREPLY=( "${COMPREPLY[@]/%/ }" ) return ;; diff --git a/completions/ssh-add b/completions/ssh-add index 4d47c0d0..d9157893 100644 --- a/completions/ssh-add +++ b/completions/ssh-add @@ -6,17 +6,17 @@ _ssh_add() _init_completion || return case $prev in - -t) + -*[tE]) return ;; - -s|-e) + -*[se]) _filedir so return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" "-\?" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" "-\?")' -- "$cur") ) return fi diff --git a/completions/ssh-copy-id b/completions/ssh-copy-id index 1e81172c..cb4cf920 100644 --- a/completions/ssh-copy-id +++ b/completions/ssh-copy-id @@ -5,15 +5,24 @@ _ssh_copy_id() local cur prev words cword _init_completion || return + _xfunc ssh _ssh_suboption_check "$1" && return + case $prev in -i) _filedir pub return ;; + -p) + return + ;; + -o) + _xfunc ssh _ssh_options + return + ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) else _known_hosts_real -a -- "$cur" fi diff --git a/completions/ssh-keygen b/completions/ssh-keygen index d1eafa9e..5c449fc0 100644 --- a/completions/ssh-keygen +++ b/completions/ssh-keygen @@ -6,51 +6,51 @@ _ssh_keygen() _init_completion -n = || return case $prev in - -a|-b|-C|-I|-J|-j|-M|-N|-n|-r|-P|-S|-V|-W|-z) + -*[abCIJjMNnrPSVWz]) return ;; - -E) - COMPREPLY=( $( compgen -W 'md5 sha256' -- "$cur" ) ) + -*E) + COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") ) return ;; - -F|-R) + -*[FR]) # TODO: trim this down to actual entries in known hosts files _known_hosts_real -- "$cur" return ;; - -D) + -*D) _filedir so return ;; - -f|-G|-K|-s|-T) + -*[fGKsT]) _filedir return ;; - -m) - COMPREPLY=( $( compgen -W 'PEM PKCS8 RFC4716' -- "$cur" ) ) + -*m) + COMPREPLY=( $(compgen -W 'PEM PKCS8 RFC4716' -- "$cur") ) return ;; - -O) + -*O) if [[ $cur != *=* ]]; then - COMPREPLY=( $( compgen -W 'clear force-command= + COMPREPLY=( $(compgen -W 'clear force-command= no-agent-forwarding no-port-forwarding no-pty no-user-rc no-x11-forwarding permit-agent-forwarding permit-port-forwarding permit-pty permit-user-rc - permit-x11-forwarding source-address=' -- "$cur" ) ) + permit-x11-forwarding source-address=' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi return ;; - -t) - COMPREPLY=( $( compgen -W 'dsa ecdsa ed25519 rsa rsa1' -- "$cur" ) ) + -*t) + COMPREPLY=( $(compgen -W 'dsa ecdsa ed25519 rsa rsa1' -- "$cur") ) return ;; esac if [[ $cur == -* ]]; then - local opts=$( _parse_usage "$1" "-?" ) - [[ -z "$opts" ]] && opts=$( _parse_help "$1" "-?" ) # OpenSSH < 7 - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + local opts=$(_parse_usage "$1" "-?") + [[ -z "$opts" ]] && opts=$(_parse_help "$1" "-?") # OpenSSH < 7 + COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) fi } && complete -F _ssh_keygen ssh-keygen diff --git a/completions/sshmitm b/completions/sshmitm index 192835c0..8b320fa8 100644 --- a/completions/sshmitm +++ b/completions/sshmitm @@ -6,7 +6,7 @@ _sshmitm() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _known_hosts_real -- "$cur" fi diff --git a/completions/sshow b/completions/sshow index 8c3cdc4c..e9ea9c2d 100644 --- a/completions/sshow +++ b/completions/sshow @@ -6,14 +6,18 @@ _sshow() _init_completion || return case $prev in - -i) + -*i) _available_interfaces -a return ;; + -*p) + _filedir pcap + return + ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) fi } && diff --git a/completions/strace b/completions/strace index eae169b4..339780b6 100644 --- a/completions/strace +++ b/completions/strace @@ -10,7 +10,7 @@ _strace() for (( i=1; i <= cword; i++ )); do case ${words[$i]} in -o|-e|-p) - i=$((i+1)) + (( i++ )) continue ;; -*) @@ -26,7 +26,7 @@ _strace() else case $prev in - -e) + -*e) if [[ "$cur" == *=* ]]; then prev=${cur/=*/} cur=${cur/*=/} @@ -41,9 +41,9 @@ _strace() [[ $define == "#define" && \ $syscall =~ ^__NR_(.+) ]] && \ syscalls[${BASH_REMATCH[1]}]=1 - done 2>/dev/null < /usr/include/asm/unistd.h + done 2>/dev/null /dev/null < $unistd + done 2>/dev/null <$unistd fi - COMPREPLY=( $( compgen -W '${!syscalls[@]} file + COMPREPLY=( $(compgen -W '${!syscalls[@]} file process network signal ipc desc all none' \ - -- "$cur" ) ) + -- "$cur") ) return ;; esac else compopt -o nospace - COMPREPLY=( $( compgen -S"=" -W 'trace abbrev verbose raw - signal read write' -- "$cur" ) ) + COMPREPLY=( $(compgen -S"=" -W 'trace abbrev verbose raw + signal read write' -- "$cur") ) fi return ;; - -o) + -*o) _filedir return ;; - -p) + -*p) _pids return ;; - -S) - COMPREPLY=( $( compgen -W 'time calls name nothing' \ - -- "$cur" ) ) + -*S) + COMPREPLY=( $(compgen -W 'time calls name nothing' -- "$cur") ) return ;; - -u) + -*u) _allowed_users return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-c -d -f -ff -F --help -i -q -r -t -tt - -ttt -T -v -V -x -xx -a -e -o -O -p -s -S -u -E' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) else - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) fi fi } && diff --git a/completions/strings b/completions/strings index 27c00497..b4e13ab6 100644 --- a/completions/strings +++ b/completions/strings @@ -6,20 +6,21 @@ _strings() _init_completion -s || return case $prev in - -h|--help|-v|-V|--version|-n|--bytes) + --help|--version|--bytes|-!(-*)[hvVn]) return ;; - -t|--radix) - COMPREPLY=( $( compgen -W 'o d x' -- "$cur" ) ) + --radix|-!(-*)t) + COMPREPLY=( $(compgen -W 'o d x' -- "$cur") ) return ;; - -T|--target) - COMPREPLY=( $( compgen -W '$( LC_ALL=C "$1" --help 2>/dev/null | \ - command sed -ne "s/: supported targets: \(.*\)/\1/p" )' -- "$cur" ) ) + --target|-!(-*)T) + COMPREPLY=( $(compgen -W '$(LC_ALL=C "$1" --help 2>/dev/null | \ + command sed -ne "s/: supported targets: \(.*\)/\1/p")' \ + -- "$cur") ) return ;; - -e|--encoding) - COMPREPLY=( $( compgen -W 's S b l B L' -- "$cur" ) ) + --encoding|-!(-*)e) + COMPREPLY=( $(compgen -W 's S b l B L' -- "$cur") ) return ;; esac @@ -27,7 +28,7 @@ _strings() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return elif [[ $cur == @* ]]; then diff --git a/completions/sudo b/completions/sudo index 2fe1c001..1b8e508f 100644 --- a/completions/sudo +++ b/completions/sudo @@ -2,45 +2,49 @@ _sudo() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return local i mode=normal [[ $1 == *sudoedit ]] && mode=edit [[ $mode == normal ]] && - for (( i=1; i <= COMP_CWORD; i++ )); do - if [[ ${COMP_WORDS[i]} != -* ]]; then + for (( i=1; i <= cword; i++ )); do + if [[ ${words[i]} != -* ]]; then local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin - local root_command=${COMP_WORDS[i]} + local root_command=${words[i]} _command_offset $i return fi - if [[ ${COMP_WORDS[i]} == -e ]]; then + if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then mode=edit break fi - [[ ${COMP_WORDS[i]} == -[uUgCp] ]] && ((i++)) + [[ ${words[i]} == \ + -@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] \ + && ((i++)) done case "$prev" in - -u|-U) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + --user|--other-user|-!(-*)[uU]) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; - -g) - COMPREPLY=( $( compgen -g -- "$cur" ) ) + --group|-!(-*)g) + COMPREPLY=( $(compgen -g -- "$cur") ) return ;; - -C|-p) - # argument required but no completions available + --close-from|--prompt|-!(-*)[Cp]) return ;; esac + $split && return + if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-A -b -C -E -e -g -H -h -i -K -k -L -l -ll - -n -P -p -S -s -U -u -V -v' -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace return fi if [[ $mode == edit ]]; then diff --git a/completions/svk b/completions/svk index d78d3557..f94356e1 100644 --- a/completions/svk +++ b/completions/svk @@ -14,11 +14,11 @@ _svk() propget pg pget proplist pl plist propset ps pset pull push resolved revert smerge sm status st stat switch sw sync sy update up verify' - if [[ $cword -eq 1 ]] ; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--version' -- "$cur") ) else - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) fi else case $prev in @@ -27,8 +27,7 @@ _svk() return ;; --encoding) - COMPREPLY=( $( compgen -W \ - '$( iconv --list | command sed -e "s@//@@;" )' -- "$cur" ) ) + _xfunc iconv _iconv_charsets return ;; esac @@ -173,26 +172,26 @@ _svk() esac options+=" --help -h" - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) else case $command in help|h|\?) - COMPREPLY=( $( compgen -W "$commands environment commands - intro" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$commands environment commands + intro" -- "$cur") ) ;; admin) - COMPREPLY=( $( compgen -W 'help deltify dump hotcopy + COMPREPLY=( $(compgen -W 'help deltify dump hotcopy list-dblogs list-unused-dblogs load lstxns recover - rmtxns setlog verify rmcache' -- "$cur" ) ) + rmtxns setlog verify rmcache' -- "$cur") ) ;; patch) - COMPREPLY=( $( compgen -W '--ls --list --cat --view + COMPREPLY=( $(compgen -W '--ls --list --cat --view --regen --regenerate --up --update --apply --rm - --delete' -- "$cur" ) ) + --delete' -- "$cur") ) ;; sync) - COMPREPLY=( $( compgen -W "$( $1 mirror --list \ - 2>/dev/null | awk '/^\//{print $1}' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 mirror --list \ + 2>/dev/null | awk '/^\//{print $1}')" -- "$cur") ) ;; co|checkout|push|pull) if [[ "$cur" == //*/* ]]; then @@ -200,8 +199,8 @@ _svk() else path=// fi - COMPREPLY=( $( compgen -W "$( $1 list $path 2>/dev/null | \ - command sed -e 's|\(.*\)|'$path'\1|')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 list $path 2>/dev/null | \ + command sed -e 's|\(.*\)|'$path'\1|')" -- "$cur") ) ;; *) _filedir diff --git a/completions/sync_members b/completions/sync_members index 2fe50eaf..653c0ea9 100644 --- a/completions/sync_members +++ b/completions/sync_members @@ -7,7 +7,7 @@ _sync_members() case $prev in -w|-g|-d|--welcome-msg|--goodbye-msg|--digest) - COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) return ;; -d|--file) @@ -19,8 +19,8 @@ _sync_members() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--no-change --welcome-msg --goodbye-msg - --digest --notifyadmin --file --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--no-change --welcome-msg --goodbye-msg + --digest --notifyadmin --file --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/synclient b/completions/synclient index b7ebf026..e7371cb7 100644 --- a/completions/synclient +++ b/completions/synclient @@ -2,7 +2,7 @@ _synclient() { - local cur prev words cword split + local cur prev words cword _init_completion -n = || return case $prev in @@ -12,10 +12,10 @@ _synclient() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) elif [[ $cur != *=?* ]]; then - COMPREPLY=( $( compgen -S = -W '$( $1 -l 2>/dev/null | \ - awk "/^[ \t]/ { print \$1 }" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -S = -W '$($1 -l 2>/dev/null | \ + awk "/^[ \t]/ { print \$1 }")' -- "$cur") ) compopt -o nospace fi } && diff --git a/completions/sysbench b/completions/sysbench index 3d2b7b1e..fc942048 100644 --- a/completions/sysbench +++ b/completions/sysbench @@ -11,80 +11,79 @@ _sysbench() return ;; --init-rng|--debug|--validate) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; --test) - COMPREPLY=( $( compgen -W 'fileio cpu memory threads mutex oltp' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'fileio cpu memory threads mutex oltp' \ + -- "$cur") ) return ;; --cpu-max-prime) return ;; --file-test-mode) - COMPREPLY=( $( compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \ + -- "$cur") ) return ;; --file-io-mode) - COMPREPLY=( $( compgen -W 'sync async fastmmap slowmmap' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'sync async fastmmap slowmmap' -- "$cur") ) return ;; --file-extra-flags) - COMPREPLY=( $( compgen -W 'sync dsync direct' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'sync dsync direct' -- "$cur") ) return ;; --file-fsync-all|--file-fsync-end) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; --file-fsync-mode) - COMPREPLY=( $( compgen -W 'fsync fdatasync' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'fsync fdatasync' -- "$cur") ) return ;; --memory-scope) - COMPREPLY=( $( compgen -W 'global local' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'global local' -- "$cur") ) return ;; --memory-hugetlb) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; --memory-oper) - COMPREPLY=( $( compgen -W 'read write none' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'read write none' -- "$cur") ) return ;; --memory-access-mode) - COMPREPLY=( $( compgen -W 'seq rnd' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'seq rnd' -- "$cur") ) return ;; --oltp-test-mode) - COMPREPLY=( $( compgen -W 'simple complex nontrx sp' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'simple complex nontrx sp' -- "$cur") ) return ;; --oltp-read-only|--oltp-skip-trx|--oltp-quto-inc|--mysql-ssl) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; --oltp-nontrx-mode) - COMPREPLY=( $( compgen -W 'select update_key update_nokey insert - delete' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'select update_key update_nokey insert + delete' -- "$cur") ) return ;; --oltp-dist-type) - COMPREPLY=( $( compgen -W 'uniform gaussian special' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'uniform gaussian special' -- "$cur") ) return ;; --db-driver) - COMPREPLY=( $( compgen -W "$( $1 --test=oltp help 2>/dev/null | + COMPREPLY=( $(compgen -W "$($1 --test=oltp help 2>/dev/null | command sed -e '/^.*database drivers:/,/^$/!d' \ - -ne 's/^ *\([^ ]*\) .*/\1/p' )" -- "$cur" ) ) + -ne 's/^ *\([^ ]*\) .*/\1/p')" -- "$cur") ) return ;; --db-ps-mode) - COMPREPLY=( $( compgen -W 'auto disable' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'auto disable' -- "$cur") ) return ;; --mysql-socket) @@ -92,12 +91,12 @@ _sysbench() return ;; --mysql-table-engine) - COMPREPLY=( $( compgen -W 'myisam innodb bdb heap ndbcluster - federated' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'myisam innodb bdb heap ndbcluster + federated' -- "$cur") ) return ;; --mysql-engine-trx) - COMPREPLY=( $( compgen -W 'yes no auto' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'yes no auto' -- "$cur") ) return ;; --*) @@ -114,18 +113,17 @@ _sysbench() fi done - local opts=$( _parse_help "$1" ) + local opts=$(_parse_help "$1") if [[ $test ]]; then - local help=( $( _parse_help "$1" "--test=$test help" ) ) + local help=( $(_parse_help "$1" "--test=$test help") ) opts="${opts[@]/--test=/} ${help[@]} prepare run cleanup help version" fi if [[ "$cur" == -* || ! $test ]]; then - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else - COMPREPLY=( $( compgen -W "prepare run cleanup help version" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "prepare run cleanup help version" -- "$cur") ) fi } && complete -F _sysbench sysbench diff --git a/completions/sysctl b/completions/sysctl index 8216f989..e683977b 100644 --- a/completions/sysctl +++ b/completions/sysctl @@ -6,24 +6,23 @@ _sysctl() _init_completion || return case $prev in - --help|--version) + --help|--version|--pattern|-!(-*)[hVr]) return ;; - -p) + --load|-!(-*)[pf]) _filedir conf return ;; esac if [[ $cur == -* ]]; then - local opts="$( _parse_help "$1" )" - [[ $opts ]] || opts="$( _parse_usage "$1" )" - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + local opts="$(_parse_help "$1")" + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) else local suffix= - [[ $prev == -w ]] && suffix== - COMPREPLY=( $( compgen -S "$suffix" -W \ - "$( PATH="$PATH:/sbin" sysctl -N -a 2>/dev/null )" -- "$cur" ) ) + [[ $prev == -w ]] && suffix="=" + COMPREPLY=( $(compgen -S "$suffix" -W \ + "$(PATH="$PATH:/sbin" sysctl -N -a 2>/dev/null)" -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/tar b/completions/tar index 2886f745..2ed98e78 100644 --- a/completions/tar +++ b/completions/tar @@ -57,7 +57,7 @@ __gtar_parse_help_opt() separator= ;; *) - echo >&2 "not an option $opt" + echo "bash_completion: $FUNCNAME: unknown option $opt" >&2 return 1 ;; esac @@ -136,11 +136,11 @@ __gnu_tar_parse_help() __gtar_parse_warnings() { local line - while IFS= read line; do + LC_ALL=C tar --warning= 2>&1 | while IFS= read line; do if [[ $line =~ ^[[:blank:]]*-[[:blank:]]*[\`\']([a-zA-Z0-9-]+)\'$ ]]; then echo "${BASH_REMATCH[1]} no-${BASH_REMATCH[1]}" fi - done <<<"$(LC_ALL=C tar --warning= 2>&1)" + done } @@ -313,7 +313,7 @@ __tar_complete_mode() generated+=" $cur$c" done - COMPREPLY=( $( compgen -W "$generated" ) ) + COMPREPLY=( $(compgen -W "$generated") ) return 0 } @@ -322,7 +322,7 @@ __tar_complete_mode() __gtar_complete_lopts() { local rv - COMPREPLY=( $( compgen -W "$long_opts" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$long_opts" -- "$cur") ) rv=$? [[ $COMPREPLY == *= ]] && compopt -o nospace return $rv @@ -341,7 +341,7 @@ __gtar_complete_sopts() generated+=" $cur$c" done - COMPREPLY=( $( compgen -W "$generated" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$generated" -- "$cur") ) } @@ -426,16 +426,16 @@ __tar_try_list_archive() __tar_cleanup_prev() { if [[ "$prev" =~ ^-[a-zA-Z0-9?]*$ ]]; then - # transformate '-caf' ~> '-f' + # transform '-caf' ~> '-f' prev="-$(__tar_last_char "$prev")" fi } __tar_detect_ext() { - local tars='@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)))|t@([abglx]z|b?(z)2))' + local tars='@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)|zst))|t@([abglx]z|b?(z)2|zst))' ext="$tars" - regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\|o\)\?\)\)\?\|t\([abglx]z\|bz\?2\)\)' + regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\|o\)\?\|zst\)\)\?\|t\([abglx]z\|bz\?2\|zst\)\)' case "$tar_mode_arg" in --*) @@ -452,8 +452,7 @@ __tar_detect_ext() esac ;; +([^ZzJjy])f) - ext="$tars" - regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\|o\)\?\)\)\?\|t\([abglx]z\|bz\?2\)\)' + # Pass through using defaults above ;; *[Zz]*f) ext='@(@(t?(ar.)|gem.|spkg.)@(gz|Z)|taz)' @@ -513,53 +512,53 @@ _gtar() # user (TODO: is there any sane way to deal with this?). This case # statement successes only if there already is PREV. case $prev in - -C|--directory) + --directory|-!(-*)C) _filedir -d break ;; --atime-preserve) - COMPREPLY=( $( compgen -W 'replace system' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'replace system' -- "$cur") ) break ;; --group) - COMPREPLY=( $( compgen -g -- "$cur" ) ) + COMPREPLY=( $(compgen -g -- "$cur") ) break ;; --owner) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) break ;; - -F|--info-script|--new-volume-script|--rmt-command|--rsh-command|\ - -I|--use-compress-program) + --info-script|--new-volume-script|--rmt-command|--rsh-command|\ + --use-compress-program|-!(-*)[FI]) compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) break ;; - --volno-file|--add-file|-T|--files-from|-X|--exclude-from|\ - --index-file|--listed-incremental|-g) + --volno-file|--add-file|--files-from|--exclude-from|\ + --index-file|--listed-incremental|-!(-*)[TXg]) _filedir break ;; - -H|--format) - COMPREPLY=( $( compgen -W 'gnu oldgnu pax posix ustar v7' \ - -- "$cur" ) ) + --format|-!(-*)H) + COMPREPLY=( $(compgen -W 'gnu oldgnu pax posix ustar v7' \ + -- "$cur") ) break ;; --quoting-style) - COMPREPLY=( $( compgen -W 'literal shell shell-always c c-maybe - escape locale clocale' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'literal shell shell-always c c-maybe + escape locale clocale' -- "$cur") ) break ;; --totals) - COMPREPLY=( $( compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \ + -- "$cur") ) break ;; --warning) - COMPREPLY=( $( compgen -W "$(__gtar_parse_warnings)" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(__gtar_parse_warnings)" -- "$cur") ) break ;; - --file|-f|-!(-*)f) + --file|-!(-*)f) __tar_file_option "$ext" break ;; @@ -579,7 +578,7 @@ _gtar() # Most probably, when code goes here, the PREV variable contains # some string from "$long_arg_none" and we want continue. ;; - -[a-zA-Z0-9?]) + -!(-*)[a-zA-Z0-9?]) # argument required but no completion yet [[ "$short_arg_req" =~ ${prev##-} ]] && break ;; @@ -695,7 +694,7 @@ _posix_tar() _tar() { local cmd=${COMP_WORDS[0]} func line - read line <<<"$($cmd --version 2>/dev/null)" + line="$($cmd --version 2>/dev/null)" case "$line" in *GNU*) func=_gtar diff --git a/completions/tcpdump b/completions/tcpdump index 44b0afa7..d93c8795 100644 --- a/completions/tcpdump +++ b/completions/tcpdump @@ -2,43 +2,60 @@ _tcpdump() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return case $prev in - -r|-w|-F) + -!(-*)[rwFV]) _filedir return ;; - -i) + --interface|-!(-*)i) _available_interfaces -a return ;; - -m) + -!(-*)m) _filedir mib return ;; - -T) - COMPREPLY=( $( compgen -W 'aodv cnfp rpc rtp rtcp snmp tftp vat - wb' -- "$cur" ) ) + -!(-*)T) + COMPREPLY=( $(compgen -W 'aodv carp cnfp lmp pgm pgm_zmtp1 radius + resp rpc rtcp rtp rtcp snmp tftp vat vxlan wb zmtp1' \ + -- "$cur") ) return ;; - -z) + -!(-*)z) compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) return ;; - -Z) + --relinquish-privileges|-!(-*)Z) _allowed_users return ;; - -B|-c|-C|-D|-E|-G|-M|-s|-W|-y) + -!(-*)[BcCDEGMsWy]) + return + ;; + --time-stamp-type|-!(-*)j) + COMPREPLY=( $(compgen -W 'host host_lowprec host_hiprec adapter + adapter_unsynced' -- "$cur") ) + return + ;; + --direction|-!(-*)Q) + COMPREPLY=( $(compgen -W 'in out inout' -- "$cur") ) + return + ;; + --time-stamp-precision) + COMPREPLY=( $(compgen -W 'micro nano' -- "$cur") ) return ;; esac + $split && return + if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/tcpkill b/completions/tcpkill index a25fedae..200cfc38 100644 --- a/completions/tcpkill +++ b/completions/tcpkill @@ -6,14 +6,14 @@ _tcpkill() _init_completion || return case $prev in - -i) + -*i) _available_interfaces -a return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur") ) fi } && diff --git a/completions/tcpnice b/completions/tcpnice index 9fdae9ba..0302d46d 100644 --- a/completions/tcpnice +++ b/completions/tcpnice @@ -6,14 +6,14 @@ _tcpnice() _init_completion || return case $prev in - -i) + -*i) _available_interfaces -a return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) fi } && diff --git a/completions/timeout b/completions/timeout index ccc66ae7..b5851baa 100644 --- a/completions/timeout +++ b/completions/timeout @@ -13,14 +13,14 @@ _timeout() fi found=true fi - [[ ${COMP_WORDS[i]} == -@(k|-kill-after|s|-signal) ]] && ((i++)) + [[ ${COMP_WORDS[i]} == -@(-kill-after|-signal|!(-*)[ks]) ]] && ((i++)) done case $prev in - --help|--version|-k|--kill-after) + --help|--version|--kill-after|-!(-*)k) return ;; - -s|--signal) + --signal|-!(-*)s) _signals return ;; @@ -29,7 +29,7 @@ _timeout() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && diff --git a/completions/tipc b/completions/tipc index 3523a295..d85f5e9c 100644 --- a/completions/tipc +++ b/completions/tipc @@ -4,10 +4,10 @@ _tipc_media() { local optind=$1 if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'media' -- $cur) ) + COMPREPLY=( $(compgen -W 'media' -- $cur) ) return 0 elif [[ $cword -eq $optind+1 ]]; then - COMPREPLY=( $( compgen -W 'udp eth ib' -- $cur) ) + COMPREPLY=( $(compgen -W 'udp eth ib' -- $cur) ) return 0 fi @@ -31,28 +31,28 @@ _tipc_bearer() { if [[ $cword -eq $optind+2 ]]; then case "$media" in "udp") - COMPREPLY=( $( compgen -W 'name' -- $cur) ) + COMPREPLY=( $(compgen -W 'name' -- $cur) ) ;; "eth" | "ib") - COMPREPLY=( $( compgen -W 'device' -- $cur) ) + COMPREPLY=( $(compgen -W 'device' -- $cur) ) ;; esac elif [[ $cword -eq $optind+3 ]]; then case "$media" in "udp") local names=$(tipc bearer list 2>/dev/null | awk -F: '/^udp:/ {print $2}') - COMPREPLY=( $( compgen -W '$names' -- $cur) ) + COMPREPLY=( $(compgen -W '$names' -- $cur) ) ;; "eth") local interfaces=$(command ls /sys/class/net/) - COMPREPLY=( $( compgen -W '$interfaces' -- $cur ) ) + COMPREPLY=( $(compgen -W '$interfaces' -- $cur) ) ;; esac fi } _tipc_link_opts() { - COMPREPLY=( $( compgen -W 'priority tolerance window' -- $cur) ) + COMPREPLY=( $(compgen -W 'priority tolerance window' -- $cur) ) } _tipc_link() { @@ -60,7 +60,7 @@ _tipc_link() { local filter=$2 if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'link' -- $cur) ) + COMPREPLY=( $(compgen -W 'link' -- $cur) ) elif [[ $cword -eq $optind+1 ]]; then # awk drops link state and last trailing : local links=$(tipc link list 2>/dev/null | \ @@ -68,7 +68,7 @@ _tipc_link() { if [[ $filter == "peers" ]]; then links=$(command sed '/broadcast-link/d' <<<"$links") fi - COMPREPLY=( $( compgen -W '$links' -- $cur ) ) + COMPREPLY=( $(compgen -W '$links' -- $cur) ) fi } @@ -83,29 +83,29 @@ _tipc() # Flags can be placed anywhere in the commandline case "$cur" in -*) - COMPREPLY=( $( compgen -W '-h --help' -- $cur ) ) + COMPREPLY=( $(compgen -W '-h --help' -- $cur) ) return ;; esac if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'bearer link media nametable node socket' -- $cur ) ) + COMPREPLY=( $(compgen -W 'bearer link media nametable node socket' -- $cur) ) return fi case "${words[$optind]}" in bearer) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'enable disable set get list' -- $cur ) ) + COMPREPLY=( $(compgen -W 'enable disable set get list' -- $cur) ) return fi case "${words[$optind]}" in enable) local media params - let optind++ + (( optind++ )) if [[ $cword -lt $optind+4 ]]; then _tipc_bearer $optind @@ -133,30 +133,30 @@ _tipc() # If the previous word was a known paramater we assume a value for # that key Note that this would break if the user attempts to use a # kown key as value - for i in ${params[@]}; do + for i in "${params[@]}"; do if [[ $prev == $i ]]; then return fi done # In order not to print already used options we remove them - for p in ${words[@]}; do - for i in ${params[@]}; do + for p in "${words[@]}"; do + for i in "${params[@]}"; do if [[ $p == $i ]]; then params=( "${params[@]/$i}" ) fi done done - COMPREPLY=( $( compgen -W '${params[@]}' -- $cur) ) + COMPREPLY=( $(compgen -W '${params[@]}' -- $cur) ) ;; disable) - let optind++ + (( optind++ )) _tipc_bearer $optind ;; get) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then _tipc_link_opts @@ -165,7 +165,7 @@ _tipc() fi ;; set) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then _tipc_link_opts @@ -176,16 +176,16 @@ _tipc() esac ;; link) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'get set list statistics' -- $cur ) ) + COMPREPLY=( $(compgen -W 'get set list statistics' -- $cur) ) return fi case "${words[$optind]}" in get) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then _tipc_link_opts @@ -194,7 +194,7 @@ _tipc() fi ;; set) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then _tipc_link_opts @@ -203,10 +203,10 @@ _tipc() fi ;; statistics) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'show reset' -- $cur) ) + COMPREPLY=( $(compgen -W 'show reset' -- $cur) ) return fi @@ -219,16 +219,16 @@ _tipc() esac ;; media) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'get set list' -- $cur ) ) + COMPREPLY=( $(compgen -W 'get set list' -- $cur) ) return fi case "${words[$optind]}" in get) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then _tipc_link_opts @@ -237,7 +237,7 @@ _tipc() fi ;; set) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then _tipc_link_opts @@ -248,34 +248,34 @@ _tipc() esac ;; nametable) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'show' -- $cur ) ) + COMPREPLY=( $(compgen -W 'show' -- $cur) ) fi ;; node) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'list get set' -- $cur ) ) + COMPREPLY=( $(compgen -W 'list get set' -- $cur) ) return fi case "${words[$optind]}" in get|set) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'address netid' -- $cur ) ) + COMPREPLY=( $(compgen -W 'address netid' -- $cur) ) fi esac ;; socket) - let optind++ + (( optind++ )) if [[ $cword -eq $optind ]]; then - COMPREPLY=( $( compgen -W 'list' -- $cur ) ) + COMPREPLY=( $(compgen -W 'list' -- $cur) ) fi ;; esac diff --git a/completions/tox b/completions/tox index 5812fcbf..a6418aca 100644 --- a/completions/tox +++ b/completions/tox @@ -6,10 +6,10 @@ _tox() _init_completion || return case $prev in - -h|--help|--version|-n|--num|-i|--index-url|--hashseed|--force-dep) + --help|--version|--num|--index-url|--hashseed|--force-dep|-!(-*)[hni]) return ;; - -c) + -!(-*)c) _filedir ini return ;; @@ -17,18 +17,21 @@ _tox() _filedir return ;; - -e) - local envs=$( "$1" --listenvs-all 2>/dev/null ) + -!(-*)e) + local envs=$( + { "$1" --listenvs-all || "$1" --listenvs; } 2>/dev/null ) local prefix=""; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -W "$envs ALL" -- "${cur##*,}" ) ) + COMPREPLY=( $(compgen -W "$envs ALL" -- "${cur##*,}") ) [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi } && complete -F _tox tox + +# ex: filetype=sh diff --git a/completions/tracepath b/completions/tracepath index bd2f3ea3..29dec3e8 100644 --- a/completions/tracepath +++ b/completions/tracepath @@ -6,13 +6,14 @@ _tracepath() _init_completion || return case $prev in - -l) + -*[lmp]) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) return fi diff --git a/completions/tshark b/completions/tshark index bd795c24..2f18d0a3 100644 --- a/completions/tshark +++ b/completions/tshark @@ -2,18 +2,46 @@ _tshark() { - local cur prev words cword + local cur prev words cword prefix _init_completion -n : || return - case $prev in - -f|-s|-B|-D|-L|-c|-R|-N|-d|-C|-e|-E|-z|-h|-v|-o|-K) + case $cur in + -o*) + prefix=-o + ;; + -X*) + prefix=-X + ;; + esac + + case ${prefix:-$prev} in + --*) + # Fallback to completion of long options below. + ;; + -o*) + if [[ $cur == *:* ]]; then + cur=${cur#*:} + _filedir + else + [ -n "$_tshark_prefs" ] || + _tshark_prefs="$("$1" -G defaultprefs 2>/dev/null | command\ + sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' | + tr '\n' ' ')" + COMPREPLY=( $(compgen -P "$prefix" -W "$_tshark_prefs" \ + -- "${cur:${#prefix}}") ) + [[ $COMPREPLY == *: ]] && compopt -o nospace + fi + return + ;; + -*[fsBDLcRNdCeEzhvoK]) return ;; - -i) - _available_interfaces -a + -*i) + COMPREPLY=( $(compgen -W \ + "$("$1" -D 2>/dev/null | awk '{print $2}')" -- "$cur") ) return ;; - -y) + -*y) local opts i for (( i=${#words[@]}-1; i > 0; i-- )); do if [[ ${words[i]} == -i ]]; then @@ -21,82 +49,87 @@ _tshark() break fi done - COMPREPLY=( $( compgen -W "$( "$1" $opts -L 2>&1 | \ - awk '/^ / { print $1 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$("$1" $opts -L 2>/dev/null | \ + awk '/^ / { print $1 }')" -- "$cur") ) return ;; - -a|-b) - COMPREPLY=( $( compgen -W 'duration: filesize: files:' \ - -- "$cur" ) ) + -*[ab]) + COMPREPLY=( $(compgen -W 'duration: filesize: files:' -- "$cur") ) [[ $COMPREPLY == *: ]] && compopt -o nospace return ;; - -r) - _filedir pcap + -*r) + _filedir '@(pcap?(ng)|cap)?(.gz)' return ;; - -H) + -*H) _filedir return ;; - -w) + -*w) _filedir [[ $cur == @(|-) ]] && COMPREPLY+=( - ) return ;; - -F) - COMPREPLY=( $( compgen -W "$( "$1" -F 2>&1 | \ - awk '/^ / { print $1 }' )" -- "$cur" ) ) + -*F) + COMPREPLY=( $(compgen -W "$("$1" -F 2>&1 | \ + awk '/^ / { print $1 }')" -- "$cur") ) return ;; - -O) + -*O) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -W "$( "$1" -G protocols 2>&1 | cut -f 3 )" \ - -- "${cur##*,}" ) ) + [ -n "$_tshark_protocols" ] || + _tshark_protocols="$("$1" -G protocols 2>/dev/null | + cut -f 3 | tr '\n' ' ')" + COMPREPLY=( $(compgen -W "$_tshark_protocols" -- "${cur##*,}") ) [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; - -T) - # TODO: could be parsed from "-T ." output - COMPREPLY=( $( compgen -W 'ps text pdml psml fields' -- "$cur" ) ) + -*T) + # Parse from: tshark -T . 2>&1 | awk -F \" '/^\t*"/ { print $2 }' + COMPREPLY=( $(compgen -W \ + 'pdml ps psml json jsonraw ek tabs text fields' -- "$cur") ) return ;; - -t) - # TODO: could be parsed from "-t ." output - COMPREPLY=( $( compgen -W 'ad a r d dd e' -- "$cur" ) ) + -*t) + # Parse from: tshark -t . 2>&1 | awk -F \" '/^\t*"/ { print $2 }' + COMPREPLY=( $(compgen -W \ + 'a ad adoy d dd e r u ud udoy' -- "$cur") ) return ;; - -u) + -*u) # TODO: could be parsed from "-u ." output - COMPREPLY=( $( compgen -W 's hms' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 's hms' -- "$cur") ) return ;; - -W) - COMPREPLY=( $( compgen -W 'n' -- "$cur" ) ) + -*W) + COMPREPLY=( $(compgen -W 'n' -- "$cur") ) return ;; - -X) - if [[ $cur == lua_script:* ]]; then + -*X) + if [[ ${cur:${#prefix}} == lua_script:* ]]; then cur=${cur#*:} _filedir lua else - COMPREPLY=( $( compgen -W 'lua_script:' -- "$cur" ) ) + COMPREPLY=( $(compgen -P "$prefix" -W 'lua_script:' -- \ + "${cur:${#prefix}}") ) [[ $COMPREPLY == *: ]] && compopt -o nospace fi return ;; - -G) - COMPREPLY=( $( compgen -W "$( "$1" -G ? 2>/dev/null | \ + -*G) + COMPREPLY=( $(compgen -W "$("$1" -G \? 2>/dev/null | \ awk '/^[ \t]*-G / \ - { sub("^[[]","",$2); sub("[]]$","",$2); print $2 }' )" \ - -- "$cur" ) ) + { sub("^[[]","",$2); sub("[]]$","",$2); print $2 }')" \ + -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \ + -- "$cur") ) return fi } && diff --git a/completions/tune2fs b/completions/tune2fs index 3695fea1..ab79cd51 100644 --- a/completions/tune2fs +++ b/completions/tune2fs @@ -6,48 +6,50 @@ _tune2fs() _init_completion || return case $prev in - -c|-C|-E|-i|-J|-L|-m|-r|-T) + -*[cCEiJLmrT]) return ;; - -e) - COMPREPLY=( $( compgen -W 'continue remount-ro panic' -- "$cur" ) ) + -*e) + COMPREPLY=( $(compgen -W 'continue remount-ro panic' -- "$cur") ) return ;; - -g) + -*g) _gids - COMPREPLY=( $( compgen -g -W '${COMPREPLY[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -g -W '${COMPREPLY[@]}' -- "$cur") ) return ;; - -M) + -*M) _filedir -d return ;; - -o) + -*o) local -a opts=(^debug ^bsdgroups ^user_xattr ^acl ^uid16 - ^journal_data ^journal_data_ordered ^journal_data_writeback) - COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" ) ) + ^journal_data ^journal_data_ordered ^journal_data_writeback + ^nobarrier ^block_validity ^discard ^nodelalloc) + COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur") ) return ;; - -O) - local -a opts=(^dir_index ^dir_nlink ^extent ^extra_isize ^filetype - ^flex_bg ^has_journal ^huge_file ^large_file ^resize_inode + -*O) + local -a opts=(^dir_index ^dir_nlink ^encrypt ^extent ^extra_isize + ^filetype ^flex_bg ^has_journal ^huge_file ^large_file + ^metadata_csum ^mmp ^project ^quota ^read-only ^resize_inode ^sparse_super ^uninit_bg) - COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur") ) return ;; - -u) + -*u) _uids - COMPREPLY=( $( compgen -u -W '${COMPREPLY[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -u -W '${COMPREPLY[@]}' -- "$cur") ) return ;; - -U) - COMPREPLY=( $( compgen -W 'clear random time' -- "$cur" ) ) + -*U) + COMPREPLY=( $(compgen -W 'clear random time' -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi diff --git a/completions/ulimit b/completions/ulimit new file mode 100644 index 00000000..3887cdf5 --- /dev/null +++ b/completions/ulimit @@ -0,0 +1,42 @@ +# bash completion for ulimit -*- shell-script -*- + +_ulimit() +{ + local cur prev words cword + _init_completion || return + + # TODO combined option support (-aH, -Sc etc) + + local mode + case $prev in + -a) + COMPREPLY=( $(compgen -W "-S -H" -- "$cur") ) + return + ;; + -[SH]) + ;; + -*) + mode=$prev + ;; + esac + + if [[ -z "$mode" ]]; then + local word + for word in "${words[@]}"; do + [[ $word == -*a* ]] && return + done + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + return + fi + fi + + local args + _count_args + [[ $args -eq 1 ]] && \ + COMPREPLY=( $(compgen -W "soft hard unlimited" -- "$cur") ) +} && +complete -F _ulimit ulimit + +# ex: filetype=sh diff --git a/completions/umount b/completions/umount deleted file mode 100644 index 6d4b3c8f..00000000 --- a/completions/umount +++ /dev/null @@ -1,21 +0,0 @@ -# umount(8) completion -*- shell-script -*- - -if [[ $OSTYPE == *linux* ]]; then - . "$BASH_SOURCE.linux" - return -fi - -# umount(8) completion. This relies on the mount point being the third -# space-delimited field in the output of mount(8) -# -_umount() -{ - local cur prev words cword - _init_completion || return - - local IFS=$'\n' - COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) ) -} && -complete -F _umount -o dirnames umount - -# ex: filetype=sh diff --git a/completions/umount.linux b/completions/umount.linux deleted file mode 100644 index 28bfc9c9..00000000 --- a/completions/umount.linux +++ /dev/null @@ -1,140 +0,0 @@ -# umount(8) completion -*- shell-script -*- - -# Just like COMPREPLY=(`compgen -W "${COMPREPLY[*]}" -- "$cur"`), only better! -# -# This will correctly escape special characters in COMPREPLY. -_reply_compgen_array() -{ - # Create the argument for compgen -W by escaping twice. - # - # One round of escape is because we want to reply with escaped arguments. A - # second round is required because compgen -W will helpfully expand it's - # argument. - local i wlist - for i in ${!COMPREPLY[*]}; do - local q=$(quote "$(printf %q "${COMPREPLY[$i]}")") - wlist+=$q$'\n' - done - - # We also have to add another round of escaping to $cur. - local ecur="$cur" - ecur=${ecur//\\/\\\\} - ecur=${ecur//\'/\\\'} - - # Actually generate completions. - local oldifs=$IFS - IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)' - IFS=$oldifs -} - -# Unescape strings in the linux fstab(5) format (with octal escapes). -__linux_fstab_unescape() { - eval $1="'${!1//\'/\\047}'" - eval $1="'${!1/%\\/\\\\}'" - eval "$1=$'${!1}'" -} - -# Complete linux fstab entries. -# -# Reads a file from stdin in the linux fstab(5) format; as used by /etc/fstab -# and /proc/mounts. -_linux_fstab() -{ - COMPREPLY=() - - # Read and unescape values into COMPREPLY - local fs_spec fs_file fs_other - local oldifs="$IFS" - while read -r fs_spec fs_file fs_other; do - if [[ $fs_spec == [#]* ]]; then continue; fi - if [[ $1 == -L ]]; then - local fs_label=${fs_spec/#LABEL=} - if [[ $fs_label != "$fs_spec" ]]; then - __linux_fstab_unescape fs_label - IFS=$'\0' - COMPREPLY+=("$fs_label") - IFS=$oldifs - fi - else - __linux_fstab_unescape fs_spec - __linux_fstab_unescape fs_file - IFS=$'\0' - [[ $fs_spec == */* ]] && COMPREPLY+=("$fs_spec") - [[ $fs_file == */* ]] && COMPREPLY+=("$fs_file") - IFS=$oldifs - fi - done - - # Add relative paths to COMPREPLY - if [[ $cur && $cur != /* ]]; then - local realcur - [[ $cur == */ ]] && # don't let readlink drop last / from path - realcur="$( readlink -f "$cur." 2> /dev/null )/" || - realcur=$( readlink -f "$cur" 2> /dev/null ) - if [[ $realcur ]]; then - local dirrealcur= dircur= basecur - if [[ $cur == */* ]]; then - dirrealcur="${realcur%/*}/" - dircur="${cur%/*}/" - fi - basecur=${cur#"$dircur"} - local i n=${#COMPREPLY[@]} - for (( i=0; i < $n; i++ )); do - [[ "${COMPREPLY[i]}" == "$realcur"* ]] && - COMPREPLY+=( $( cd "$dircur" 2> /dev/null && - compgen -f -d -P "$dircur" \ - -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur" ) ) - done - fi - fi - - _reply_compgen_array -} - -_umount() -{ - local cur prev words cword - _init_completion || return - - case "$prev" in - -t) - # FIXME: no - local split=false - if [[ "$cur" == ?*,* ]]; then - prev="${cur%,*}" - cur="${cur##*,}" - split=true - fi - COMPREPLY=( $( compgen -W 'adfs affs autofs btrfs cifs coda - cramfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs - iso9660 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc qnx4 - ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs - umsdos usbfs vfat xfs' -- "$cur" ) ) - _fstypes - $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) - return - ;; - -O) - # argument required but no completions available - return - ;; - esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l - --no-canonicalize --fake' -- "$cur" ) ) - [[ $COMPREPLY ]] && return - fi - - if [[ -r /proc/mounts ]]; then - # Linux /proc/mounts is properly quoted. This is important when - # unmounting usb devices with pretty names. - _linux_fstab < /proc/mounts - else - local IFS=$'\n' - COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) ) - fi -} && -complete -F _umount -o dirnames umount - -# ex: filetype=sh diff --git a/completions/unace b/completions/unace index 0f8963e0..a58bd6f0 100644 --- a/completions/unace +++ b/completions/unace @@ -6,10 +6,10 @@ _unace() _init_completion || return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur") ) else if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'e l t v x' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'e l t v x' -- "$cur") ) else _filedir ace fi diff --git a/completions/unpack200 b/completions/unpack200 index 1c97ecbe..393df04d 100644 --- a/completions/unpack200 +++ b/completions/unpack200 @@ -6,15 +6,15 @@ _unpack200() _init_completion -s || return case $prev in - '-?'|-h|--help|-V|--version|-J) + --help|--version|-!(-*)[?hVJ]) return ;; - -H|--deflate-hint) - COMPREPLY=( $( compgen -W 'true false keep' -- "$cur" ) ) + --deflate-hint|-!(-*)H) + COMPREPLY=( $(compgen -W 'true false keep' -- "$cur") ) return ;; - -l|--log-file) - COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) + --log-file|-!(-*)l) + COMPREPLY=( $(compgen -W '-' -- "$cur") ) _filedir log return ;; @@ -32,9 +32,9 @@ _unpack200() done if ! $pack ; then - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '--deflate-hint= --remove-pack-file - --verbose --quiet --log-file= --help --version' -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '--deflate-hint= --remove-pack-file + --verbose --quiet --log-file= --help --version' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir 'pack?(.gz)' diff --git a/completions/unrar b/completions/unrar index 3340d24c..5381876f 100644 --- a/completions/unrar +++ b/completions/unrar @@ -6,12 +6,12 @@ _unrar() _init_completion || return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-ad -ap -av- -c- -cfg- -cl -cu -dh -ep -f + COMPREPLY=( $(compgen -W '-ad -ap -av- -c- -cfg- -cl -cu -dh -ep -f -idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta -tb -tn -to -u -v - -ver -vp -x -x@ -y' -- "$cur" ) ) + -ver -vp -x -x@ -y' -- "$cur") ) else if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'e l lb lt p t v vb vt x' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'e l lb lt p t v vb vt x' -- "$cur") ) else _filedir rar fi diff --git a/completions/unshunt b/completions/unshunt index 8815f843..214fa423 100644 --- a/completions/unshunt +++ b/completions/unshunt @@ -6,7 +6,7 @@ _unshunt() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else _filedir -d fi diff --git a/completions/update-alternatives b/completions/update-alternatives index 43cc3229..e9ba476b 100644 --- a/completions/update-alternatives +++ b/completions/update-alternatives @@ -13,7 +13,7 @@ _installed_alternatives() break fi done - COMPREPLY=( $( compgen -W '$( command ls $admindir )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(command ls $admindir)' -- "$cur") ) } _update_alternatives() @@ -60,7 +60,7 @@ _update_alternatives() _filedir ;; 1) - COMPREPLY=( $( compgen -W '--slave' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--slave' -- "$cur") ) ;; 3) _installed_alternatives @@ -82,9 +82,9 @@ _update_alternatives() _installed_alternatives ;; *) - COMPREPLY=( $( compgen -W '--verbose --quiet --help --version + COMPREPLY=( $(compgen -W '--verbose --quiet --help --version --altdir --admindir --install --remove --auto --display - --config --set' -- "$cur" ) ) + --config --set' -- "$cur") ) esac } && complete -F _update_alternatives update-alternatives alternatives diff --git a/completions/update-rc.d b/completions/update-rc.d index 85c9a5a4..384b8dd4 100644 --- a/completions/update-rc.d +++ b/completions/update-rc.d @@ -17,15 +17,15 @@ _update_rc_d() options=( -f -n ) if [[ $cword -eq 1 || "$prev" == -* ]]; then - valid_options=( $( \ - tr " " "\n" <<<"${words[@]} ${options[@]}" \ - | command sed -ne "/$( command sed "s/ /\\|/g" <<<"${options[@]}" )/p" \ + valid_options=( $(\ + tr " " "\n" <<<"${words[*]} ${options[*]}" \ + | command sed -ne "/$(command sed "s/ /\\|/g" <<<"${options[*]}")/p" \ | sort | uniq -u \ ) ) - COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \ - -X '$( tr " " "|" <<<${words[@]} )' -- "$cur" ) ) - elif [[ "$prev" == ?($( tr " " "|" <<<${services[@]} )) ]]; then - COMPREPLY=( $( compgen -W 'remove defaults start stop' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${options[@]} ${services[@]}' \ + -X '$(tr " " "|" <<<${words[@]})' -- "$cur") ) + elif [[ "$prev" == ?($(tr " " "|" <<<"${services[*]}")) ]]; then + COMPREPLY=( $(compgen -W 'remove defaults start stop' -- "$cur") ) elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then @@ -53,7 +53,7 @@ _update_rc_d() COMPREPLY=() fi elif [[ "$prev" == "." ]]; then - COMPREPLY=( $( compgen -W "start stop" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "start stop" -- "$cur") ) else COMPREPLY=() fi diff --git a/completions/upgradepkg b/completions/upgradepkg index 2a4b9845..7b775769 100644 --- a/completions/upgradepkg +++ b/completions/upgradepkg @@ -6,8 +6,8 @@ _upgradepkg() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--dry-run --install-new --reinstall - --verbose' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--dry-run --install-new --reinstall + --verbose' -- "$cur") ) return fi @@ -16,9 +16,9 @@ _upgradepkg() cur="${cur#*%}" local nofiles IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur" ) ) + COMPREPLY=( $(compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur") ) [[ $COMPREPLY ]] || nofiles=1 - COMPREPLY+=( $( compgen -P "$prev%" -S '/' -d -- "$cur" ) ) + COMPREPLY+=( $(compgen -P "$prev%" -S '/' -d -- "$cur") ) [[ $nofiles ]] && compopt -o nospace return fi diff --git a/completions/urlsnarf b/completions/urlsnarf index b6bf069c..d3581c5f 100644 --- a/completions/urlsnarf +++ b/completions/urlsnarf @@ -6,14 +6,18 @@ _urlsnarf() _init_completion || return case $prev in - -i) + -*i) _available_interfaces -a return ;; + -*p) + _filedir pcap + return + ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) fi } && diff --git a/completions/uscan b/completions/uscan index aafc1dfd..de0e7174 100644 --- a/completions/uscan +++ b/completions/uscan @@ -7,7 +7,7 @@ _uscan() case $prev in --package) - COMPREPLY=( $( _xfunc apt-cache _apt_cache_src_packages )) + COMPREPLY=( $(_xfunc apt-cache _apt_cache_src_packages)) return ;; --watchfile) @@ -26,13 +26,7 @@ _uscan() $split && return - COMPREPLY=( $( compgen -W ' --report --no-download --report-status - --download --destdir --force-download --pasv --no-pasv --symlink --rename - --repack --no-symlink --dehs --no-dehs --download-current-version --verbose - --no-verbose --debug --user-agent --useragent --no-conf --help - --version --timeout --package --upstream-version --watchfile - --download-version --check-dirname-level --check-dirname-regex - ' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _uscan uscan diff --git a/completions/useradd b/completions/useradd index fa8e58cc..8e095441 100644 --- a/completions/useradd +++ b/completions/useradd @@ -9,27 +9,27 @@ _useradd() # with -u/--uid case $prev in - -c|--comment|-h|--help|-e|--expiredate|-f|--inactive|-K|--key|\ - -p|--password|-u|--uid|-Z|--selinux-user) + --comment|--help|--expiredate|--inactive|--key|--password|--uid|\ + --selinux-user|-!(-*)[chefKpuZ]) return ;; - -b|--base-dir|-d|--home-dir|-k|--skel|-R|--root) + --base-dir|--home-dir|--skel|--root|-!(-*)[bdkR]) _filedir -d return ;; - -g|--gid) + --gid|-!(-*)g) _gids - COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $(compgen -g)' \ + -- "$cur") ) return ;; - -G|--groups) + --groups|-!(-*)G) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -g -- "${cur##*,}" ) ) + COMPREPLY=( $(compgen -g -- "${cur##*,}") ) [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; - -s|--shell) + --shell|-!(-*)s) _shells return ;; @@ -38,7 +38,7 @@ _useradd() $split && return [[ "$cur" == -* ]] && \ - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _useradd useradd diff --git a/completions/userdel b/completions/userdel index 05bc2f75..7d637d2e 100644 --- a/completions/userdel +++ b/completions/userdel @@ -6,21 +6,21 @@ _userdel() _init_completion || return case $prev in - -h|--help) + --help|-!(-*)h) return ;; - -R|--root) + --root|-!(-*)R) _filedir -d return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) } && complete -F _userdel userdel diff --git a/completions/usermod b/completions/usermod index 9d478c3a..3d0efdbd 100644 --- a/completions/usermod +++ b/completions/usermod @@ -9,27 +9,27 @@ _usermod() # with -u/--uid case $prev in - -c|--comment|-d|--home|-e|--expiredate|-f|--inactive|-h|--help|\ - -l|--login|-p|--password|-u|--uid|-Z|--selinux-user) + --comment|--home|--expiredate|--inactive|--help|--login|--password|\ + --uid|--selinux-user|-!(-*)[cdefhlpuZ]) return ;; - -g|--gid) + --gid|-!(-*)g) _gids - COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $(compgen -g)' \ + -- "$cur") ) return ;; - -G|--groups) + --groups|-!(-*)G) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -g -- "${cur##*,}" ) ) + COMPREPLY=( $(compgen -g -- "${cur##*,}") ) [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; - -R|--root) + --root|-!(-*)R) _filedir -d return ;; - -s|--shell) + --shell|-!(-*)s) _shells return ;; @@ -39,11 +39,11 @@ _usermod() if [[ "$cur" == -* ]]; then # TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi - COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -u -- "$cur") ) } && complete -F _usermod usermod diff --git a/completions/valgrind b/completions/valgrind index 97e4cc59..2df09707 100644 --- a/completions/valgrind +++ b/completions/valgrind @@ -31,24 +31,24 @@ _valgrind() --tool) # Tools seem to be named e.g. like memcheck-amd64-linux from which # we want to grab memcheck. - COMPREPLY=( $( compgen -W '$( - for f in /usr{,/local}/lib{,64}/valgrind/*; do - [[ $f != *.so && -x $f ]] && - command sed -ne "s/^.*\/\(.*\)-\([^-]*\)-\([^-]*\)/\1/p" <<<$f - done )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$( + for f in /usr{,/local}/lib{,64,exec}/valgrind/*; do + [[ $f != *.so && -x $f && $f =~ ^.*/(.*)-[^-]+-[^-]+ ]] && + printf "%s\n" "${BASH_REMATCH[1]}" + done)' -- "$cur") ) return ;; --sim-hints) - COMPREPLY=( $( compgen -W 'lax-ioctls enable-outer' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'lax-ioctls enable-outer' -- "$cur") ) return ;; --soname-synonyms) - COMPREPLY=( $( compgen -W 'somalloc' -S = -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'somalloc' -S = -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return ;; --kernel-variant) - COMPREPLY=( $( compgen -W 'bproc' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'bproc' -- "$cur") ) return ;; # callgrind: @@ -58,19 +58,19 @@ _valgrind() ;; # exp-dhat: --sort-by) - COMPREPLY=( $( compgen -W 'max-bytes-live tot-bytes-allocd - max-blocks-live' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'max-bytes-live tot-bytes-allocd + max-blocks-live' -- "$cur") ) return ;; # massif: --time-unit) - COMPREPLY=( $( compgen -W 'i ms B' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'i ms B' -- "$cur") ) return ;; # generic cases parsed from --help output --+([-A-Za-z0-9_])) - local value=$( $1 --help-debug $tool 2>/dev/null | \ - command sed -ne "s|^[[:blank:]]*$prev=\([^[:blank:]]\{1,\}\).*|\1|p" ) + local value=$($1 --help-debug $tool 2>/dev/null | \ + command sed -ne "s|^[[:blank:]]*$prev=\([^[:blank:]]\{1,\}\).*|\1|p") case $value in \) _filedir @@ -78,18 +78,18 @@ _valgrind() ;; \) compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) return ;; \<+([0-9])..+([0-9])\>) - COMPREPLY=( $( compgen -W "{${value:1:((${#value}-2))}}" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "{${value:1:((${#value}-2))}}" \ + -- "$cur") ) return ;; # "yes", "yes|no", etc (but not "string", "STR", # "hint1,hint2,...") yes|+([-a-z0-9])\|+([-a-z0-9\|])) - COMPREPLY=( $( IFS='|' compgen -W '$value' -- "$cur" ) ) + COMPREPLY=( $(IFS='|' compgen -W '$value' -- "$cur") ) return ;; esac @@ -99,8 +99,8 @@ _valgrind() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" "--help $tool" )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help $tool")' \ + -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/vipw b/completions/vipw index cb54a840..46771a0a 100644 --- a/completions/vipw +++ b/completions/vipw @@ -6,16 +6,16 @@ _vipw() _init_completion || return case $prev in - -h|--help) + --help|-!(-*)h) return ;; - -R|--root) + --root|-!(-*)R) _filedir -d return ;; esac - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) } && complete -F _vipw vipw vigr diff --git a/completions/vmstat b/completions/vmstat index 769620a7..f15d4089 100644 --- a/completions/vmstat +++ b/completions/vmstat @@ -6,20 +6,20 @@ _vmstat() _init_completion || return case $prev in - -h|--help|-V|--version|-c|-M|-N|-n|-w|-p|--partition) + --help|--version|--partition|-!(-*)[hVcMNnwp]) return ;; - -S|--unit) + --unit|-!(-*)S) [[ $OSTYPE == *linux* ]] && \ - COMPREPLY=( $( compgen -W 'k K m M' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'k K m M' -- "$cur") ) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY ]] || \ - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) fi } && complete -F _vmstat vmstat diff --git a/completions/vncviewer b/completions/vncviewer index 9b307331..000ba1a8 100644 --- a/completions/vncviewer +++ b/completions/vncviewer @@ -27,8 +27,8 @@ _tightvncviewer() return ;; -encodings) - COMPREPLY=( $( compgen -W 'copyrect tight hextile zlib corre rre - raw' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'copyrect tight hextile zlib corre rre + raw' -- "$cur") ) return ;; -via) @@ -39,10 +39,10 @@ _tightvncviewer() if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-help -listen -via -shared -noshared + COMPREPLY=( $(compgen -W '-help -listen -via -shared -noshared -viewonly -fullscreen -noraiseonbeep -passwd -encodings -bgr233 -owncmap -truecolour -truecolor -depth -compresslevel -quality - -nojpeg -nocursorshape -x11cursor' -- "$cur" ) ) + -nojpeg -nocursorshape -x11cursor' -- "$cur") ) else _known_hosts_real -- "$cur" fi @@ -52,26 +52,24 @@ complete -F _tightvncviewer tightvncviewer # NOTE: - VNC Viewer options are case insensitive. # Preferred case is taken from -help. -# - Both single dash (-) and double dash (--) are allowed as option prefix _xvnc4viewer() { local cur prev words cword _init_completion || return - # Convert double dash to single dash - case ${prev/#--/-} in + # Both single dash (-) and double dash (--) are allowed as option prefix + local opt=${prev/#--/-} + case ${opt,,} in # -passwd, -PasswordFile - -[pP][aA][sS][sS][wW][dD]|-[pP][aA][sS][sS][wW][oO][rR][dD][fF][iI][lL][eE]) + -passwd|-passwordfile) _filedir return ;; - # -PreferredEncoding - -[pP][rR][eE][fF][eE][rR][rR][eE][dD][eE][nN][cC][oO][dD][iI][nN][gG]) - COMPREPLY=( $( compgen -W 'zrle hextile raw' -- "$cur" ) ) + -preferredencoding) + COMPREPLY=( $(compgen -W 'zrle hextile raw' -- "$cur") ) return ;; - # -via - -[vV][iI][aA]) + -via) _known_hosts_real -- "$cur" return ;; @@ -87,11 +85,11 @@ _xvnc4viewer() WMDecorationWidth ZlibLevel ) [[ "$cur" == --* ]] && dash=-- || dash=- - local IFS=$' \t\n' reset=$( shopt -p nocasematch ); shopt -s nocasematch + local IFS=$' \t\n' reset=$(shopt -p nocasematch); shopt -s nocasematch local option - COMPREPLY=( $( for option in "${options[@]}"; do + COMPREPLY=( $(for option in "${options[@]}"; do [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option - done ) ) + done) ) $reset else _known_hosts_real -- "$cur" diff --git a/completions/vpnc b/completions/vpnc index b7b8c14a..5eb5be71 100644 --- a/completions/vpnc +++ b/completions/vpnc @@ -16,12 +16,12 @@ _vpnc() return ;; --vendor) - COMPREPLY=( $( compgen -W 'cisco netscreen' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'cisco netscreen' -- "$cur") ) return ;; --natt-mode) - COMPREPLY=( $( compgen -W 'natt none force-natt cisco-udp' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'natt none force-natt cisco-udp' \ + -- "$cur") ) return ;; --script|--pid-file|--ca-file) @@ -29,23 +29,23 @@ _vpnc() return ;; --dh) - COMPREPLY=( $( compgen -W 'dh1 dh2 dh5' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'dh1 dh2 dh5' -- "$cur") ) return ;; --pfs) - COMPREPLY=( $( compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur") ) return ;; --ifmode) - COMPREPLY=( $( compgen -W 'tun tap' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'tun tap' -- "$cur") ) return ;; --debug) - COMPREPLY=( $( compgen -W '0 1 2 3 99' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '0 1 2 3 99' -- "$cur") ) return ;; --auth-mode) - COMPREPLY=( $( compgen -W 'psk cert hybrid' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'psk cert hybrid' -- "$cur") ) return ;; --ca-dir) @@ -54,14 +54,13 @@ _vpnc() ;; --password-helper) compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) + COMPREPLY=( $(compgen -c -- "$cur") ) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --long-help)' -- "$cur") ) elif [[ "$cur" == */* ]]; then # explicit filename _filedir conf @@ -74,7 +73,7 @@ _vpnc() $reset IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -W '${configs[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${configs[@]}' -- "$cur") ) fi } && complete -F _vpnc vpnc diff --git a/completions/watch b/completions/watch index bcc356f8..eb04df89 100644 --- a/completions/watch +++ b/completions/watch @@ -10,10 +10,10 @@ _watch() local offset=0 i for (( i=1; i <= cword; i++ )); do case ${words[i]} in - -h|--help|--version) + --help|--version|-!(-*)h) return ;; - -n|--interval) + --interval|-!(-*)n) (( i++ )) continue ;; @@ -31,12 +31,12 @@ _watch() fi case $prev in - -d|--differences) + --differences|-!(-*)d) [[ $cur != -* ]] && \ - COMPREPLY=( $( compgen -W 'cumulative' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'cumulative' -- "$cur") ) return ;; - -n|--interval) + --interval|-!(-*)n) return ;; esac @@ -44,7 +44,7 @@ _watch() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/webmitm b/completions/webmitm index 308f2281..d50bc3e3 100644 --- a/completions/webmitm +++ b/completions/webmitm @@ -6,7 +6,7 @@ _webmitm() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) else _known_hosts_real -- "$cur" fi diff --git a/completions/wget b/completions/wget index 95011bef..b27d860d 100644 --- a/completions/wget +++ b/completions/wget @@ -6,18 +6,18 @@ _wget() _init_completion -s || return case $prev in - -V|--version|-h|--help) + --version|--help|-!(-*)[hV]) return ;; --progress) - COMPREPLY=( $( compgen -W 'bar dot' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'bar dot' -- "$cur") ) return ;; --bind-address) - _ip_addresses "$cur" + _ip_addresses return ;; - -D|--domains|--exclude-domains) + --domains|--exclude-domains|-!(-*)D) _known_hosts_real -- "$cur" return ;; @@ -37,53 +37,53 @@ _wget() excludes+=( ascii ) ;; esac - local excludes_str=$( export IFS='|'; echo "${excludes[*]}"; ) + local excludes_str=$(export IFS='|'; echo "${excludes[*]}";) # prevopt is the previous options string used as a prefix # to avoid COMPREPLY replacing them with the $lastopt completion local lastopt=${cur/*,} prevopt= [[ $cur == *,* ]] && prevopt=${cur%,*}, - COMPREPLY=( $( compgen -P "$prevopt" -X "@($excludes_str)" \ + COMPREPLY=( $(compgen -P "$prevopt" -X "@($excludes_str)" \ -W 'unix windows nocontrol ascii lowercase uppercase' \ - -- "$lastopt" ) ) + -- "$lastopt") ) # +o nospace when no more valid option is possible (= append a space) - local opt_as_arr=( $( echo ${COMPREPLY[0]//,/ } ) ) + local opt_as_arr=( $(echo ${COMPREPLY[0]//,/ }) ) [[ ${#opt_as_arr[@]} -lt 4 ]] && compopt -o nospace return ;; --prefer-family) - COMPREPLY=( $( compgen -W 'IPv4 IPv6 none' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'IPv4 IPv6 none' -- "$cur") ) return ;; - -P|--directory-prefix|--ca-directory|--warc-tempdir) + --directory-prefix|--ca-directory|--warc-tempdir|-!(-*)P) _filedir -d return ;; - -o|--output-file|-a|--append-output|--config|--load-cookies|\ - --save-cookies|--post-file|--certificate|--ca-certificate|\ - --private-key|--random-file|--egd-file|--warc-file|--warc-dedup) + --output-file|--append-output|--config|--load-cookies|--save-cookies|\ + --post-file|--certificate|--ca-certificate|--private-key|\ + --random-file|--egd-file|--warc-file|--warc-dedup|-!(-*)[oa]) _filedir return ;; - -O|--output-document|-i|--input-file) + --output-document|--input-file|-!(-*)[Oi]) _filedir && [[ $cur == - || -z $cur ]] && COMPREPLY+=( - ) return ;; --secure-protocol) - COMPREPLY=( $( compgen -W 'auto SSLv2 SSLv3 TLSv1' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'auto SSLv2 SSLv3 TLSv1' -- "$cur") ) return ;; --certificate-type|--private-key-type) - COMPREPLY=( $( compgen -W 'PEM DER' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'PEM DER' -- "$cur") ) return ;; --follow-tags|--ignore-tags) local lastopt=${cur/*,} prevopt= [[ $cur == *,* ]] && prevopt=${cur%,*}, - COMPREPLY=( $( compgen -P "$prevopt" -W 'a abbr acronym address + COMPREPLY=( $(compgen -P "$prevopt" -W 'a abbr acronym address applet area b base basefont bdo big blockquote body br button caption center cite code col colgroup dd del dir div dfn dl dt em fieldset font form frame frameset h6 head hr html i iframe @@ -91,37 +91,37 @@ _wget() noframes noscript object ol optgroup option p param pre q s samp script select small span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var xmp' \ - -- "$lastopt" ) ) + -- "$lastopt") ) return ;; - -t|--tries|-T|--timeout|--dns-timeout|--connect-timeout|--read-timeout|\ - -w|--wait|--waitretry|--cut-dirs|--max-redirect|-l|--level) + --tries|--timeout|--dns-timeout|--connect-timeout|--read-timeout|\ + --wait|--waitretry|--cut-dirs|--max-redirect|--level|-!(-*)[tTwl]) # expect integer number - COMPREPLY+=( $( compgen -P "$cur" -W "{0..9}" ) ) + COMPREPLY+=( $(compgen -P "$cur" -W "{0..9}") ) compopt -o nospace return ;; - -Q|--quota|--limit-rate|--warc-max-size) + --quota|--limit-rate|--warc-max-size|-!(-*)Q) # expect size if [[ $cur == *[km] ]]; then - COMPREPLY=( $( compgen -W "$cur" ) ) + COMPREPLY=( $(compgen -W "$cur") ) elif [[ $cur ]]; then - COMPREPLY=( $( compgen -P "$cur" -W "{0..9} k m" ) ) + COMPREPLY=( $(compgen -P "$cur" -W "{0..9} k m") ) compopt -o nospace else - COMPREPLY=( $( compgen -W "{0..9}" ) ) + COMPREPLY=( $(compgen -W "{0..9}") ) compopt -o nospace fi return ;; --user|--http-user|--proxy-user|--ftp-user) - COMPREPLY=( $( compgen -W "$( command sed -n \ + COMPREPLY=( $(compgen -W "$(command sed -n \ '/^login/s/^[[:blank:]]*login[[:blank:]]//p' ~/.netrc \ - 2>/dev/null )" -- "$cur" ) ) + 2>/dev/null)" -- "$cur") ) return ;; --header) - COMPREPLY=( $( compgen -W 'Accept Accept-Charset Accept-Encoding + COMPREPLY=( $(compgen -W 'Accept Accept-Charset Accept-Encoding Accept-Language Accept-Ranges Age Allow Authorization Cache-Control Connection Content-Encoding Content-Language Content-Length Content-Location Content-MD5 Content-Range @@ -130,31 +130,29 @@ _wget() Last-Modified Location Max-Forwards Pragma Proxy-Authenticate Proxy-Authorization Range Referer Retry-After Server TE Trailer Transfer-Encoding Upgrade User-Agent Vary Via Warning - WWW-Authenticate' -- "$cur" ) ) + WWW-Authenticate' -- "$cur") ) compopt -o nospace return ;; --local-encoding|--remote-encoding) - type -P xauth &>/dev/null && \ - COMPREPLY=( $( compgen -W '$( iconv -l 2>/dev/null | \ - command sed -e "s@/*\$@@" -e "s/[,()]//g" 2>/dev/null )' -- "$cur" ) ) + type -P xauth &>/dev/null && _xfunc iconv _iconv_charsets return ;; - -e|--execute) + --execute|-!(-*)e) return # TODO base=STR ;; --report-speed) - COMPREPLY=( $( compgen -W 'bits' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'bits' -- "$cur") ) return ;; --regex-type) - COMPREPLY=( $( compgen -W 'posix' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'posix' -- "$cur") ) return ;; - -B|--base|--password|--ftp-password|--http-password|--proxy-password|\ - --default-page|--referer|-U|--user-agent|--post-data|--warc-header|-A|\ - --accept|-R|--reject|--accept-regex|--reject-regex|-I|\ - --include-directories|-X|--exclude-directories) + --base|--password|--ftp-password|--http-password|--proxy-password|\ + --default-page|--referer|--user-agent|--post-data|--warc-header|\ + --accept|--reject|--accept-regex|--reject-regex|--include-directories|\ + --exclude-directories|-!(-*)[BUARIX]) # argument required but no completions available return ;; @@ -163,7 +161,7 @@ _wget() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi diff --git a/completions/wine b/completions/wine index be299755..f871e744 100644 --- a/completions/wine +++ b/completions/wine @@ -7,7 +7,7 @@ _wine() if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) [[ $COMPREPLY ]] && return fi _filedir '@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR]|[mM][sS][iI])' diff --git a/completions/withlist b/completions/withlist index 913e410b..cd030a27 100644 --- a/completions/withlist +++ b/completions/withlist @@ -6,8 +6,8 @@ _withlist() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--lock --interactive --run --all --quiet - --help' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--lock --interactive --run --all --quiet + --help' -- "$cur") ) else _xfunc list_lists _mailman_lists fi diff --git a/completions/wodim b/completions/wodim index 7380166b..ac1dc5a9 100644 --- a/completions/wodim +++ b/completions/wodim @@ -16,8 +16,8 @@ _cdrecord() _filedir ;; blank) - COMPREPLY=( $( compgen -W 'help all fast track unreserve trtail - unclose session' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'help all fast track unreserve trtail + unclose session' -- "$cur") ) ;; driveropts) if [[ $cur == *=* ]]; then @@ -25,31 +25,30 @@ _cdrecord() cur=${cur#*=} case $prev in varirec) - COMPREPLY=( $( compgen -W "-2 -1 0 1 2" \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W "-2 -1 0 1 2" -- "$cur") ) ;; gigarec) - COMPREPLY=( $( compgen -W "0.6 0.7 0.8 1.0 1.2 1.3 - 1.4" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "0.6 0.7 0.8 1.0 1.2 1.3 + 1.4" -- "$cur") ) ;; tattoofile) _filedir ;; esac else - COMPREPLY=( $( compgen -W 'burnfree noburnfree varirec= + COMPREPLY=( $(compgen -W 'burnfree noburnfree varirec= gigarec= audiomaster forcespeed noforcespeed speedread nospeedread singlesession nosinglesession hidecdr - nohidecdr tattooinfo tattoofile=' -- "$cur" ) ) + nohidecdr tattooinfo tattoofile=' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi ;; driver) - COMPREPLY=( $( compgen -W "$( $1 driver=help 2>&1 | \ - awk 'NR > 1 { print $1 }' ) help" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$($1 driver=help 2>&1 | \ + awk 'NR > 1 { print $1 }') help" -- "$cur") ) ;; minbuf) - COMPREPLY=( $( compgen -W '{25..95}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{25..95}' -- "$cur") ) ;; esac return @@ -83,10 +82,10 @@ _cdrecord() # files are always eligible completion _filedir # track options are always available - COMPREPLY+=( $( compgen -W '${track_options[@]}' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '${track_options[@]}' -- "$cur") ) # general options are no more available after file or track option if [[ $track_mode -eq 0 ]]; then - COMPREPLY+=( $( compgen -W '${generic_options[@]}' -- "$cur" ) ) + COMPREPLY+=( $(compgen -W '${generic_options[@]}' -- "$cur") ) fi [[ $COMPREPLY == *= ]] && compopt -o nospace } && diff --git a/completions/wol b/completions/wol index 1ce25b05..0222b24d 100644 --- a/completions/wol +++ b/completions/wol @@ -6,20 +6,20 @@ _wol() _init_completion -s -n : || return case $prev in - -V|--version|--help|-p|--port|--passwd|-w|--wait) + --version|--help|--port|--passwd|--wait|-!(-*)[Vpw]) return ;; - -h|--host|-i|--ipaddr) + --host|--ipaddr|-!(-*)[hi]) # Broadcast addresses local PATH=$PATH:/sbin - COMPREPLY=( $( { ip addr show || ifconfig -a; } 2>/dev/null | \ + COMPREPLY=( $({ ip addr show || ifconfig -a; } 2>/dev/null | \ command sed -ne 's/.*[[:space:]]Bcast:\([^[:space:]]*\).*/\1/p' -ne \ 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' -ne \ - 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' ) ) + 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p') ) _known_hosts_real -- "$cur" return ;; - -f|--file) + --file|-!(-*)f) _filedir return ;; @@ -28,7 +28,7 @@ _wol() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/wsimport b/completions/wsimport index a7f591e7..406a47d7 100644 --- a/completions/wsimport +++ b/completions/wsimport @@ -22,7 +22,7 @@ _wsimport() return ;; -target) - COMPREPLY=( $( compgen -W '2.0 2.1 2.2' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '2.0 2.1 2.2' -- "$cur") ) return ;; -clientjar) @@ -35,8 +35,7 @@ _wsimport() _known_hosts_real -- "${cur#-httpproxy:}" return elif [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) [[ $COMPREPLY == *: ]] && compopt -o nospace __ltrim_colon_completions "$cur" return diff --git a/completions/wtf b/completions/wtf index 26a0d4b8..6a596a3b 100644 --- a/completions/wtf +++ b/completions/wtf @@ -7,7 +7,7 @@ _wtf() _init_completion || return [[ $prev == -f ]] && _filedir && return - [[ ${words[@]} == *\ -f* ]] && addf= || addf=-f + [[ "${words[*]}" == *\ -f* ]] && addf= || addf=-f if [[ $cur == -* ]]; then COMPREPLY=( $addf ) return @@ -32,8 +32,8 @@ _wtf() [[ -z "$db" ]] && return fi - COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db* 2>/dev/null ) $addf" \ - -- "${cur^^}" ) ) + COMPREPLY=( $(compgen -W "$(cut -f 1 -s $db* 2>/dev/null) $addf" \ + -- "${cur^^}") ) } && complete -F _wtf wtf diff --git a/completions/wvdial b/completions/wvdial index e456f1b1..e0316617 100644 --- a/completions/wvdial +++ b/completions/wvdial @@ -18,7 +18,7 @@ _wvdial() case $cur in -*) - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace ;; *) @@ -33,7 +33,7 @@ _wvdial() done # parse config files for sections and # remove default section - COMPREPLY=( $( command sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \ + COMPREPLY=( $(command sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \ 2>/dev/null | command grep -v '^Defaults$')) # escape spaces COMPREPLY=${COMPREPLY// /\\ } diff --git a/completions/xdg-mime b/completions/xdg-mime index 92d5b838..72e92c66 100644 --- a/completions/xdg-mime +++ b/completions/xdg-mime @@ -2,8 +2,8 @@ _xdg_mime_mimetype() { - COMPREPLY+=( $( compgen -S / -W 'application audio font image message model - multipart text video' -- "$cur" ) ) + COMPREPLY+=( $(compgen -S / -W 'application audio font image message model + multipart text video' -- "$cur") ) [[ $COMPREPLY == */ ]] && compopt -o nospace } @@ -17,18 +17,18 @@ _xdg_mime() if [[ $args -eq 1 ]]; then if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '--help --manual --version' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--help --manual --version' -- "$cur") ) return fi - COMPREPLY=( $( compgen -W \ - 'query default install uninstall' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + 'query default install uninstall' -- "$cur") ) return fi case ${words[1]} in query) if [[ $args -eq 2 ]]; then - COMPREPLY=( $( compgen -W 'filetype default' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'filetype default' -- "$cur") ) return fi case ${words[2]} in # TODO and $args -eq 3 (takes only one arg!) @@ -43,25 +43,25 @@ _xdg_mime() desktops=( "${desktops[@]##*/}" ) $reset IFS=$'\n' - COMPREPLY=( $( compgen -W '${desktops[@]}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '${desktops[@]}' -- "$cur") ) else _xdg_mime_mimetype fi ;; install) if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '--mode --novendor' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--mode --novendor' -- "$cur") ) elif [[ $prev == --mode ]]; then - COMPREPLY=( $( compgen -W 'user system' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'user system' -- "$cur") ) else _filedir xml fi ;; uninstall) if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '--mode' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '--mode' -- "$cur") ) elif [[ $prev == --mode ]]; then - COMPREPLY=( $( compgen -W 'user system' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'user system' -- "$cur") ) else _filedir xml fi @@ -69,3 +69,5 @@ _xdg_mime() esac } && complete -F _xdg_mime xdg-mime + +# ex: filetype=sh diff --git a/completions/xdg-settings b/completions/xdg-settings index 15f040d4..c14d37ba 100644 --- a/completions/xdg-settings +++ b/completions/xdg-settings @@ -12,18 +12,20 @@ _xdg_settings() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( "$1" --help | - command sed -e "s/[{|]/\n/g" | _parse_help - )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$("$1" --help | + tr "{|" "\n" | _parse_help -)' -- "$cur") ) return fi local args _count_args if [[ $args -eq 1 ]]; then - COMPREPLY=( $( compgen -W "get check set" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "get check set" -- "$cur") ) elif [[ $args -eq 2 ]]; then - COMPREPLY=( $( compgen -W \ - '$( "$1" --list | awk "!/^Known/ { print \$1 }" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$("$1" --list | awk "!/^Known/ { print \$1 }")' -- "$cur") ) fi } && complete -F _xdg_settings xdg-settings + +# ex: filetype=sh diff --git a/completions/xfreerdp b/completions/xfreerdp index 9ca7ac81..f025cfce 100644 --- a/completions/xfreerdp +++ b/completions/xfreerdp @@ -3,34 +3,62 @@ _xfreerdp() { local cur prev words cword - _init_completion || return + _init_completion -n : || return - case $prev in + case $prev in # old/dash syntax -k) - COMPREPLY=( $( compgen -W "$($1 --kbd-list | \ - awk '/^0x/ {print $1}')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$("$1" --kbd-list | + awk "/^0x/ { print \$1 }")' -- "$cur") ) return ;; -a) - COMPREPLY=( $( compgen -W '8 15 16 24 32' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '8 15 16 24 32' -- "$cur") ) return ;; -x) - COMPREPLY=( $( compgen -W 'b broadband m modem l lan' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'broadband modem lan' -- "$cur") ) return ;; --plugin) - COMPREPLY=( $( compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur") ) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -t -g -a -z -f -x -O -o -k - --kbd-list -h --plugin --data' -- "$cur" ) ) + case $cur in # new/slash syntax + /kbd:*) + COMPREPLY=( $(compgen -W '$("$1" /kbd-list | + awk "/^0x/ { print \$1 }")' -- "${cur#/kbd:}") ) + return + ;; + /bpp:*) + COMPREPLY=( $(compgen -W '8 15 16 24 32' -- "${cur#/bpp:}") ) + return + ;; + /*:*|/help|/version|-h|--help|--version) + return + ;; + esac + + if [[ "$cur" == /* ]]; then + COMPREPLY=( $(compgen -W '$("$1" --help | + awk "\$1 ~ /^\\// && \$1 !~ /^.(flag\$|option:)/ { sub(\":.*\",\":\",\$1); print \$1 }")' \ + -- "$cur") ) + [[ $COMPREPLY == *: ]] && compopt -o nospace + elif [[ "$cur" == [+-]* ]]; then + local char=${cur:0:1} + local help="$($1 --help)" + if [[ "$help" == */help* ]]; then # new/slash syntax + COMPREPLY=( $(compgen -W '$(awk " + \$1 ~ /^[+-]/ && \$1 !~ /^.toggle\$/ { sub(\"^.\",\"$char\",\$1); print \$1 } + " <<<"$help")' -- "$cur") ) + else # old/dash syntax + COMPREPLY=( $(_parse_help - <<<"$help") ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]%:}' -- "$cur") ) + fi else - COMPREPLY=( $( compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \ - 2>/dev/null)" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \ + 2>/dev/null)" -- "$cur") ) fi } && diff --git a/completions/xgamma b/completions/xgamma index 7b9d43cc..005928d2 100644 --- a/completions/xgamma +++ b/completions/xgamma @@ -7,9 +7,9 @@ _xgamma() case "$prev" in -screen) - local screens=$( xrandr --query 2>/dev/null | command sed -n \ - '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null ) - COMPREPLY=( $( compgen -W "$screens" -- "$cur" ) ) + local screens=$(xrandr --query 2>/dev/null | command sed -n \ + '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null) + COMPREPLY=( $(compgen -W "$screens" -- "$cur") ) return ;; -gamma|-rgamma|-ggamma|-bgamma) @@ -17,7 +17,7 @@ _xgamma() if [[ $cur && "$cur" != *.* ]]; then COMPREPLY=( . ) fi - COMPREPLY+=( $( compgen -W "{0..9}" ) ) + COMPREPLY+=( $(compgen -W "{0..9}") ) compopt -o nospace return ;; @@ -26,15 +26,15 @@ _xgamma() if [[ "$cur" == :* && "$cur" != :*.* ]]; then # FIXME: where to get local display numbers? local display=${cur#:} - COMPREPLY=( $( compgen -W "${display:-0}." ) ) + COMPREPLY=( $(compgen -W "${display:-0}.") ) compopt -o nospace elif [[ "$cur" == :*.* ]]; then # local screen numbers - local t screens=$( xrandr --query 2>/dev/null | command sed -ne \ - '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null ) + local t screens=$(xrandr --query 2>/dev/null | command sed -ne \ + '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null) t="${cur#:}" - COMPREPLY=( $( compgen -P "${t%.*}." -W "$screens" -- \ - "${cur##*.}" ) ) + COMPREPLY=( $(compgen -P "${t%.*}." -W "$screens" -- \ + "${cur##*.}") ) elif [[ "$cur" != *:* ]]; then # complete hostnames _known_hosts_real -c -- "$cur" @@ -43,13 +43,13 @@ _xgamma() fi compopt -o nospace fi - # no dislpay completion for remote hosts + # no display completion for remote hosts return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY ]] && return fi diff --git a/completions/xm b/completions/xm deleted file mode 100644 index c720fae1..00000000 --- a/completions/xm +++ /dev/null @@ -1,222 +0,0 @@ -# bash completion for xm -*- shell-script -*- - -_xen_domain_names() -{ - COMPREPLY=( $( compgen -W "$( xm list 2>/dev/null | \ - awk '!/Name|Domain-0/ { print $1 }' )" -- "$cur" ) ) -} - -_xen_domain_ids() -{ - COMPREPLY=( $( compgen -W "$( xm list 2>/dev/null | \ - awk '!/Name|Domain-0/ { print $2 }' )" -- "$cur" ) ) -} - -_xm() -{ - local cur prev words cword - _init_completion || return - - # TODO: _split_longopt - - local args command commands options - - commands='console vncviewer create new delete destroy domid domname - dump-core list mem-max mem-set migrate pause reboot rename reset - restore resume save shutdown start suspend sysrq trigger top unpause - uptime usb-add usb-del vcpu-list vcpu-pin vcpu-set debug-keys dmesg - info log serve sched-credit sched-sedf block-attach block-detach - block-list block-configure network-attach network-detach network-list - vtpm-list pci-attach pci-detach pci-list pci-list-assignable-devices - scsi-attach scsi-detach scsi-list vnet-list vnet-create vnet-delete - labels addlabel rmlabel getlabel dry-run resources dumppolicy setpolicy - resetpolicy getpolicy shell help' - - if [[ $cword -eq 1 ]] ; then - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) - else - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - fi - - command=${words[1]} - if [[ "$cur" == -* ]]; then - # possible options for the command - case $command in - create) - options='-c' - ;; - dmesg) - options='--clear' - ;; - list) - options='--long' - ;; - reboot) - options='-w -a' - ;; - shutdown) - options='-w -a -R -H' - ;; - sched-credit) - options='-d -w -c' - ;; - block-list|network-list|vtpm-list|vnet-list) - options='-l --long' - ;; - getpolicy) - options='--dumpxml' - ;; - new) - options='-h --help --help_config -q --quiet --path= -f= - --defconfig= -F= --config= -b --dryrun -x --xmldryrun - -s --skipdtd -p --paused -c --console_autoconnect' - ;; - esac - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) - else - case $command in - console|destroy|domname|domid|list|mem-set|mem-max| \ - pause|reboot|rename|shutdown|unpause|vcpu-list|vcpu-pin| \ - vcpu-set|block-list|network-list|vtpm-list) - _count_args - case $args in - 2) - _xen_domain_names - ;; - esac - ;; - migrate) - _count_args - case $args in - 2) - _xen_domain_names - ;; - 3) - _known_hosts_real -- "$cur" - ;; - esac - ;; - restore|dry-run|vnet-create) - _filedir - ;; - save) - _count_args - case $args in - 2) - _xen_domain_names - ;; - 3) - _filedir - ;; - esac - ;; - sysrq) - _count_args - case $args in - 2) - _xen_domain_names - ;; - 3) - COMPREPLY=( $( compgen -W "r s e i u b" \ - -- "$cur" ) ) - ;; - esac - ;; - block-attach) - _count_args - case $args in - 2) - _xen_domain_names - ;; - 3) - COMPREPLY=( $( compgen -W "phy: file:" \ - -- "$cur" ) ) - ;; - 5) - COMPREPLY=( $( compgen -W "w r" -- "$cur" ) ) - ;; - 6) - _xen_domain_names - ;; - esac - ;; - block-detach) - _count_args - case $args in - 2) - _xen_domain_names - ;; - 3) - COMPREPLY=( $( compgen -W "$( xm block-list $prev \ - 2>/dev/null | awk '!/Vdev/ { print $1 }' )" \ - -- "$cur" ) ) - ;; - esac - ;; - network-attach) - _count_args - case $args in - 2) - _xen_domain_names - ;; - *) - COMPREPLY=( $( compgen -W "script= ip= mac= bridge= - backend=" -- "$cur" ) ) - ;; - esac - ;; - network-detach) - _count_args - case $args in - 2) - _xen_domain_names - ;; - 3) - COMPREPLY=( $(compgen -W "$( xm network-list $prev \ - 2>/dev/null | awk '!/Idx/ { print $1 }' )" \ - -- "$cur" ) ) - ;; - esac - ;; - sched-credit) - case $prev in - -d) - _xen_domain_names - return - ;; - esac - ;; - create) - _filedir - COMPREPLY+=( \ - $( compgen -W '$( command ls /etc/xen 2>/dev/null )' \ - -- "$cur" ) ) - ;; - new) - case $prev in - -f|-F|--defconfig|--config) - _filedir - return - ;; - --path) - _filedir -d - return - ;; - esac - - _count_args - case $args in - 2) - _xen_domain_names - ;; - esac - ;; - esac - fi - fi -} && -complete -F _xm xm - -# ex: filetype=sh diff --git a/completions/xmllint b/completions/xmllint index e9a35d06..f5865b39 100644 --- a/completions/xmllint +++ b/completions/xmllint @@ -10,7 +10,7 @@ _xmllint() _filedir return ;; - --path|--dtdvalidfpi|--maxmem|--encode|--pattern) + --path|--dtdvalidfpi|--maxmem|--pattern|--xpath) # argument required but no completions available return ;; @@ -30,10 +30,18 @@ _xmllint() _filedir 'sch?(.gz)' return ;; + --encode) + _xfunc iconv _iconv_charsets + return + ;; + --pretty) + COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") ) + return + ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) COMPREPLY=( "${COMPREPLY[@]%:}" ) return fi diff --git a/completions/xmlwf b/completions/xmlwf index dd7a5457..9cd0e195 100644 --- a/completions/xmlwf +++ b/completions/xmlwf @@ -6,22 +6,22 @@ _xmlwf() _init_completion || return case $prev in - -d) + -*d) _filedir -d return ;; - -e) - COMPREPLY=( $( compgen -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1' \ - -- "$cur" ) ) + -*e) + COMPREPLY=( $(compgen -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1' \ + -- "$cur") ) return ;; - -v) + -*v) return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) return fi diff --git a/completions/xmms b/completions/xmms index 88e65bd4..9f084c38 100644 --- a/completions/xmms +++ b/completions/xmms @@ -6,17 +6,19 @@ _xmms() _init_completion -s || return case $prev in - -h|--help|-v|--version) + --help|--version|-!(-*)[hv]) return ;; - -S|--toggle-shuffle|-R|--toggle-repeat|-A|--toggle-advance) - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + --toggle-shuffle|--toggle-repeat|--toggle-advance|-!(-*)[SRA]) + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) return ;; esac + $split && return + if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) else _filedir '@(mp[23]|ogg|wav|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)' fi diff --git a/completions/xmodmap b/completions/xmodmap index 4db899b1..38bc6391 100644 --- a/completions/xmodmap +++ b/completions/xmodmap @@ -12,8 +12,7 @@ _xmodmap() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-display -help -grammar -verbose -quiet -n - -e -pm -pk -pke -pp' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) return fi diff --git a/completions/xrandr b/completions/xrandr index 841904a5..9b5b6a59 100644 --- a/completions/xrandr +++ b/completions/xrandr @@ -12,8 +12,8 @@ _xrandr() return ;; --output|--left-of|--right-of|--above|--below|--same-as) - local outputs=$( "$1" | awk '/connected/ {print $1}' ) - COMPREPLY=( $( compgen -W "$outputs" -- "$cur" ) ) + local outputs=$("$1" | awk '/connected/ {print $1}') + COMPREPLY=( $(compgen -W "$outputs" -- "$cur") ) return ;; --mode) @@ -25,37 +25,38 @@ _xrandr() fi done if [[ $output ]]; then - local modes=$( "$1" | command sed -e "1,/$output/ d" \ + local modes=$("$1" | command sed -e "1,/^$output / d" \ -e "/connected/,$ d" \ - -e "s/\([^[:space:]]\)[[:space:]].*/\1/" ) - COMPREPLY=( $( compgen -W "$modes" -- "$cur" ) ) + -e "s/\([^[:space:]]\)[[:space:]].*/\1/") + COMPREPLY=( $(compgen -W "$modes" -- "$cur") ) fi return ;; -o|--orientation) - COMPREPLY=( $( compgen -W 'normal inverted left right 0 1 2 3' -- \ - "$cur" ) ) + COMPREPLY=( $(compgen -W 'normal inverted left right 0 1 2 3' -- \ + "$cur") ) return ;; --reflect) - COMPREPLY=( $( compgen -W 'normal x y xy' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'normal x y xy' -- "$cur") ) return ;; --rotate) - COMPREPLY=( $( compgen -W 'normal inverted left right' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'normal inverted left right' -- "$cur") ) return ;; --setprovideroutputsource|--setprovideroffloadsink) - local providers=$( "$1" --listproviders 2>/dev/null | - command sed -ne 's/.* name:\([^ ]*\).*/\1/p' ) - COMPREPLY=( $( compgen -W "$providers" -- "$cur" ) ) + local providers=$("$1" --listproviders 2>/dev/null | + command sed -ne 's/.* name:\([^ ]*\).*/\1/p') + COMPREPLY=( $(compgen -W "$providers" -- "$cur") ) # TODO 2nd arg needed, is that a provider as well? return ;; esac - COMPREPLY=( $( compgen -W '$( "$1" -help 2>&1 | - command sed -e "s/ or / /g" -e "s/<[^>]*>]//g" | _parse_help - )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$("$1" -help 2>&1 | + command sed -e "s/ or / /g" -e "s/<[^>]*>]//g" | _parse_help -)' \ + -- "$cur") ) } && complete -F _xrandr xrandr diff --git a/completions/xrdb b/completions/xrdb index 1f517cb3..d9f11439 100644 --- a/completions/xrdb +++ b/completions/xrdb @@ -16,7 +16,7 @@ _xrdb() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) return fi diff --git a/completions/xsltproc b/completions/xsltproc index 98d3e72a..241de67b 100644 --- a/completions/xsltproc +++ b/completions/xsltproc @@ -16,8 +16,8 @@ _xsltproc() ;; --encoding) # some aliases removed - COMPREPLY=( $( compgen -W "$( iconv -l | command sed -e '/^UTF[1378]/d' \ - -e '/^ISO[0-9_]/d' -e '/^8859/d' -e 's/\/.*//')" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(iconv -l | command sed -e '/^UTF[1378]/d' \ + -e '/^ISO[0-9_]/d' -e '/^8859/d' -e 's/\/.*//')" -- "$cur") ) return ;; --param|--stringparam) @@ -37,7 +37,7 @@ _xsltproc() [[ $cword -gt 2 && `_get_cword '' 2` == --?(string)param ]] && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) COMPREPLY=( "${COMPREPLY[@]%:}" ) else # TODO: 1st file xsl|xslt, 2nd XML diff --git a/completions/xxd b/completions/xxd index f190d75a..f6bcb4a2 100644 --- a/completions/xxd +++ b/completions/xxd @@ -12,7 +12,7 @@ _xxd() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) return fi diff --git a/completions/xz b/completions/xz index 7499ffb5..b64921f1 100644 --- a/completions/xz +++ b/completions/xz @@ -15,25 +15,23 @@ _xz() _filedir return ;; - -C|--check) - COMPREPLY=( $( compgen -W 'crc32 crc64 sha256 none' -- "$cur" ) ) + --check|-!(-*)C) + COMPREPLY=( $(compgen -W 'crc32 crc64 sha256 none' -- "$cur") ) return ;; - -F|--format) - COMPREPLY=( $( compgen -W 'auto xz lzma raw' -- "$cur" ) ) + --format|-!(-*)F) + COMPREPLY=( $(compgen -W 'auto xz lzma raw' -- "$cur") ) return ;; - -T|--threads) - COMPREPLY=( $( compgen -W "{0..$(_ncpus)}" -- "$cur" ) ) + --threads|-!(-*)T) + COMPREPLY=( $(compgen -W "{0..$(_ncpus)}" -- "$cur") ) return ;; - -M|--memlimit|--memlimit-compress|--memlimit-decompress|--memory|\ - -S|--suffix|--delta|--lzma1|--lzma2) - # argument required but no completions available + --memlimit|--memlimit-compress|--memlimit-decompress|--memory|\ + --suffix|--delta|--lzma1|--lzma2|-!(-*)[MS]) return ;; - -h|--help|-H|--long-help|-V|--version|--info-memory) - # all other arguments are noop with these + --help|--long-help|--version|--info-memory|-!(-*)[hHV]) return ;; esac @@ -41,8 +39,8 @@ _xz() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \ - -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1" --long-help) {-1..-9}' \ + -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -51,8 +49,7 @@ _xz() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) } && complete -F _xz xz pxz diff --git a/completions/xzdec b/completions/xzdec index 5475a8e2..6b402eb3 100644 --- a/completions/xzdec +++ b/completions/xzdec @@ -6,12 +6,10 @@ _xzdec() _init_completion -s || return case $prev in - -M|--memory) - # argument required but no completions available + --memory|-!(-*)M) return ;; - -h|--help|-V|--version) - # all other arguments are noop with these + --help|--version|-!(-*)[hV]) return ;; esac @@ -19,7 +17,7 @@ _xzdec() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi diff --git a/completions/ypmatch b/completions/ypmatch index c6de48b3..655390f2 100644 --- a/completions/ypmatch +++ b/completions/ypmatch @@ -12,13 +12,13 @@ _ypmatch() if [[ $cmd == ypmatch && $cword -eq 1 && ${#words[@]} -eq 3 ]]; then map=${words[2]} - COMPREPLY=( $( compgen -W '$( ypcat $map 2>/dev/null | \ - cut -d':' -f 1 )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(ypcat $map 2>/dev/null | \ + cut -d':' -f 1)' -- "$cur") ) else [[ $cmd == ypmatch && $cword -ne 2 ]] && return - COMPREPLY=( $( compgen -W \ - '$( printf "%s\n" $(ypcat -x 2>/dev/null | \ - cut -d"\"" -f 2) )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(printf "%s\n" $(ypcat -x 2>/dev/null | \ + cut -d"\"" -f 2))' -- "$cur") ) fi } && complete -F _ypmatch ypmatch ypcat diff --git a/completions/yum-arch b/completions/yum-arch index 9dac178e..f2b902a3 100644 --- a/completions/yum-arch +++ b/completions/yum-arch @@ -5,8 +5,8 @@ _yum_arch() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]] ; then - COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur" ) ) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur") ) else _filedir -d fi diff --git a/completions/zopfli b/completions/zopfli index ee2c890c..3c7ea403 100644 --- a/completions/zopfli +++ b/completions/zopfli @@ -12,8 +12,8 @@ _zopfli() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W \ - '$( _parse_help "$1" -h | command sed -e "s/#$//" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W \ + '$(_parse_help "$1" -h | command sed -e "s/#$//")' -- "$cur") ) [[ $COMPREPLY == --i ]] && compopt -o nospace return fi @@ -22,8 +22,7 @@ _zopfli() local IFS=$'\n' xspec="*.@(gz|t[ag]z)" compopt -o filenames - COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ - $( compgen -d -- "$cur" ) ) + COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) } && complete -F _zopfli zopfli diff --git a/completions/zopflipng b/completions/zopflipng index 88ddbe68..3d815404 100644 --- a/completions/zopflipng +++ b/completions/zopflipng @@ -10,7 +10,7 @@ _zopflipng() return ;; --splitting) - COMPREPLY=( $( compgen -W '{0..3}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) return ;; esac @@ -18,13 +18,13 @@ _zopflipng() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( _parse_help "$1" -h ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]%:}' -- "$cur" ) ) + COMPREPLY=( $(_parse_help "$1" -h) ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]%:}' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace return fi - if [[ ${words[@]} != *\ --prefix=* ]]; then + if [[ "${words[*]}" != *\ --prefix=* ]]; then # 2 png args only if --prefix not given local args _count_args -- cgit v1.2.1