diff options
Diffstat (limited to 'completions')
425 files changed, 6188 insertions, 4421 deletions
diff --git a/completions/.gitignore b/completions/.gitignore new file mode 100644 index 00000000..60a2d949 --- /dev/null +++ b/completions/.gitignore @@ -0,0 +1,205 @@ +7za +aclocal-1.1[012345] +alpine +alternatives +animate +apropos +arm-koji +asciidoc.py +autoheader +automake-1.1[012345] +autossh +autoupdate +bsdtar +btdownloadcurses.py +btdownloadgui.py +c++ +cc +cdrecord +ci +ciptool +civclient +civserver +clzip +co +colormake +compare +compgen +composite +conjure +cowthink +createdb +createuser +dcop +declare +dfutool +display +dpkg-deb +dpkg-query +dpkg-reconfigure +dropdb +dropuser +edquota +f77 +f95 +filebucket +freeciv-sdl +freeciv-xaw +g++ +g4 +g77 +g95 +gcj +gfortran +gkrellm2 +gmake +gmplayer +gnumake +gpc +hciattach +hciconfig +hd +host +hping +hping3 +identify +ifdown +ifstatus +import +insmod.static +javac +javadoc +kplayer +l2ping +lbzip2 +ldapadd +ldapcompare +ldapdelete +ldapmodify +ldapmodrdn +ldappasswd +ldapwhoami +lintian-info +lusermod +lvchange +lvcreate +lvdisplay +lvextend +lvmdiskscan +lvreduce +lvremove +lvrename +lvresize +lvs +lvscan +lz4c +mailsnarf +mdecrypt +mencoder +micropython +mkisofs +mogrify +montage +mplayer2 +msgsnarf +muttng +ncal +pbzip2 +pccardctl +pdlzip +perldoc +phing +pigz +pinfo +ping6 +pkg_deinstall +pkg_info +pkill +plzip +pm-suspend +pm-suspend-hybrid +pmake +postalias +ppc-koji +puppetca +puppetd +puppetdoc +puppetmasterd +puppetqd +puppetrun +pvchange +pvcreate +pvdisplay +pvmove +pvremove +pvs +pvscan +pxz +py.test-[23] +pydoc3 +python2 +python3 +pypy +pypy3 +pyvenv-3.[45] +qemu-kvm +qemu-system-i386 +qemu-system-x86_64 +quotacheck +quotaoff +quotaon +ralsh +rcsdiff +rdict +repquota +rfcomm +rlog +rpm2targz +rpm2txz +rpmbuild +rpmbuild-md5 +s390-koji +sbcl-mt +scp +sdptool +setquota +sftp +sidedoor +slogin +smbcacls +smbcquotas +smbget +smbpasswd +smbtar +smbtree +sparc-koji +spovray +star +stream +sudoedit +tightvncviewer +tracepath6 +typeset +vgcfgbackup +vgcfgrestore +vgchange +vgck +vgconvert +vgcreate +vgdisplay +vgexport +vgextend +vgimport +vgmerge +vgmknodes +vgreduce +vgremove +vgrename +vgs +vgscan +vgsplit +vigr +whatis +xpovray +xvnc4viewer +ypcat diff --git a/completions/2to3 b/completions/2to3 new file mode 100644 index 00000000..4dd29bf4 --- /dev/null +++ b/completions/2to3 @@ -0,0 +1,39 @@ +# bash completion for 2to3 -*- shell-script -*- + +_2to3() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help|--add-suffix) + return + ;; + -f|--fix|-x|--nofix) + COMPREPLY=( $( compgen -W \ + "$( $1 --list-fixes 2>/dev/null | command sed -e 1d )" -- "$cur" ) ) + return + ;; + -j|--processes) + COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) + return + ;; + -o|--output-dir) + _filedir -d + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir py +} && +complete -F _2to3 2to3 + +# ex: filetype=sh diff --git a/completions/7z b/completions/7z new file mode 100644 index 00000000..5599b708 --- /dev/null +++ b/completions/7z @@ -0,0 +1,119 @@ +# 7z(1) completion -*- shell-script -*- + +_7z() +{ + local cur prev words cword + _init_completion -n = || return + + if [[ $cword -eq 1 ]]; then + COMPREPLY=( $( compgen -W 'a b d e l t u x' -- "$cur" ) ) + return + fi + + local mode + [[ ${words[1]} == [adu] ]] && mode=w || mode=r + + case $cur in + -ao*) + COMPREPLY=( $( compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}" ) ) + return + ;; + -?(a)[ix]*) + local opt + if [[ $cur == -a[ix]* ]]; then + opt=${cur:0:3} cur=${cur:3} + else + opt=${cur:0:2} cur=${cur:2} + fi + if [[ $cur != *[@\!]* ]]; then + 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" + compopt -o filenames + fi + return + ;; + -mhe=*|-mhc=*|-ms=*|-mt=*) + COMPREPLY=( $( compgen -W 'on off' -- "${cur#*=}" ) ) + return + ;; + -mx=*) + 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" + compopt -o nospace -o filenames + return + ;; + -r?*) + 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}" ) ) + return + ;; + -ssc?*) + 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}" ) ) + else + 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}" ) ) + fi + return + ;; + -m*=*|-p*|-u*|-v*) + return + ;; + esac + + if [[ $cur == -* ]]; then + 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" ) ) + [[ $COMPREPLY == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] || + compopt -o nospace + return + fi + + local args + _count_args = + if [[ $args -eq 2 ]]; then + _filedir_xspec unzip + [[ $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)' + else + if [[ ${words[1]} == d ]]; then + local IFS=$'\n' + 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" ) ) + compopt -o filenames + else + _filedir + fi + fi +} && +complete -F _7z 7z 7za + +# ex: filetype=sh diff --git a/completions/Makefile.am b/completions/Makefile.am index f312b3a9..f04d7c36 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -1,12 +1,16 @@ bashcompdir = $(pkgdatadir)/completions -bashcomp_DATA = a2x \ +bashcomp_DATA = 2to3 \ + 7z \ + a2x \ abook \ aclocal \ acpi \ + adb \ add_members \ alias \ ant \ apache2ctl \ + appdata-validate \ apt-build \ apt-cache \ apt-get \ @@ -23,11 +27,13 @@ bashcomp_DATA = a2x \ autoscan \ avctrl \ badblocks \ + bind \ bk \ brctl \ btdownloadheadless.py \ + bts \ bzip2 \ - cal \ + _cal \ cancel \ cardctl \ ccache \ @@ -37,13 +43,15 @@ bashcomp_DATA = a2x \ change_pw \ check_db \ check_perms \ + checksec \ + _chfn \ chgrp \ chkconfig \ chown \ chpasswd \ chronyc \ chrpath \ - chsh \ + _chsh \ cksfv \ cleanarch \ clisp \ @@ -62,10 +70,11 @@ bashcomp_DATA = a2x \ cvs \ cvsps \ dd \ + deja-dup \ desktop-file-validate \ dhclient \ dict \ - dmesg \ + _dmesg \ dnsspoof \ dot \ dpkg \ @@ -76,7 +85,7 @@ bashcomp_DATA = a2x \ dumpe2fs \ e2freefrag \ e2label \ - eject \ + _eject \ eog \ ether-wake \ evince \ @@ -92,6 +101,8 @@ bashcomp_DATA = a2x \ filesnarf \ find \ find_member \ + flake8 \ + freebsd-update \ freeciv-gtk2 \ freeciv-server \ function \ @@ -104,7 +115,9 @@ bashcomp_DATA = a2x \ genisoimage \ getent \ gkrellm \ + gm \ gnatmake \ + gnokii \ gnome-mplayer \ gpasswd \ gpg \ @@ -120,12 +133,13 @@ bashcomp_DATA = a2x \ gzip \ hcitool \ hddtemp \ - hexdump \ + _hexdump \ hid2hci \ + hostname \ hping2 \ htop \ htpasswd \ - hwclock \ + _hwclock \ iconv \ id \ idn \ @@ -137,7 +151,7 @@ bashcomp_DATA = a2x \ installpkg \ interdiff \ invoke-rc.d \ - ionice \ + _ionice \ ip \ iperf \ ipmitool \ @@ -154,7 +168,9 @@ bashcomp_DATA = a2x \ jarsigner \ java \ javaws \ + jpegoptim \ jps \ + jshint \ k3b \ kcov \ kill \ @@ -177,7 +193,7 @@ bashcomp_DATA = a2x \ list_lists \ list_members \ list_owners \ - look \ + _look \ lpq \ lpr \ lrzip \ @@ -187,6 +203,7 @@ bashcomp_DATA = a2x \ luseradd \ luserdel \ lvm \ + lz4 \ lzip \ lzma \ lzop \ @@ -206,12 +223,15 @@ bashcomp_DATA = a2x \ mkinitrd \ mktemp \ mmsitepass \ + _mock \ modinfo \ modprobe \ + _modules \ monodevelop \ mount \ mount.linux \ mplayer \ + mr \ msynctool \ mtx \ munindoc \ @@ -225,20 +245,22 @@ bashcomp_DATA = a2x \ nc \ ncftp \ nethogs \ - newgrp \ + _newgrp \ newlist \ newusers \ ngrep \ nmap \ - nmcli \ + _nmcli \ nslookup \ ntpdate \ openssl \ opera \ + optipng \ p4 \ pack200 \ passwd \ patch \ + pdftotext \ perl \ pgrep \ pidof \ @@ -255,7 +277,9 @@ bashcomp_DATA = a2x \ pm-hibernate \ pm-is-supported \ pm-powersave \ + pngfix \ portinstall \ + portsnap \ portupgrade \ postcat \ postconf \ @@ -271,9 +295,12 @@ bashcomp_DATA = a2x \ pwd \ pwdx \ pwgen \ + py.test \ pydoc \ + pyflakes \ pylint \ python \ + pyvenv \ qdbus \ qemu \ qrunner \ @@ -283,9 +310,10 @@ bashcomp_DATA = a2x \ rdesktop \ remove_members \ removepkg \ - renice \ + _renice \ + _repomanage \ reportbug \ - reptyr \ + _reptyr \ resolvconf \ rfkill \ ri \ @@ -298,7 +326,8 @@ bashcomp_DATA = a2x \ rpmcheck \ rrdtool \ rsync \ - rtcwake \ + _rtcwake \ + _runuser \ sbcl \ sbopkg \ screen \ @@ -315,25 +344,33 @@ bashcomp_DATA = a2x \ ssh \ ssh-add \ ssh-copy-id \ + ssh-keygen \ sshfs \ sshmitm \ sshow \ strace \ strings \ - su \ + _su \ sudo \ svcadm \ svk \ + _svn \ + _svnadmin \ + _svnlook \ sync_members \ + synclient \ sysbench \ sysctl \ tar \ tcpdump \ tcpkill \ tcpnice \ + timeout \ + tipc \ tracepath \ tshark \ tune2fs \ + _udevadm \ umount \ umount.linux \ unace \ @@ -359,6 +396,7 @@ bashcomp_DATA = a2x \ withlist \ wodim \ wol \ + _write \ wsimport \ wtf \ wvdial \ @@ -377,13 +415,21 @@ bashcomp_DATA = a2x \ xz \ xzdec \ ypmatch \ - yum-arch + _yum \ + yum-arch \ + zopfli \ + zopflipng -EXTRA_DIST = $(bashcomp_DATA) \ - _mock _modules _subversion _udevadm _yum _yum-utils +EXTRA_DIST = $(bashcomp_DATA) CLEANFILES = \ + 7za \ + aclocal-1.10 \ aclocal-1.11 \ + aclocal-1.12 \ + aclocal-1.13 \ + aclocal-1.14 \ + aclocal-1.15 \ alpine \ alternatives \ animate \ @@ -391,9 +437,15 @@ CLEANFILES = \ arm-koji \ asciidoc.py \ autoheader \ + automake-1.10 \ automake-1.11 \ + automake-1.12 \ + automake-1.13 \ + automake-1.14 \ + automake-1.15 \ autossh \ autoupdate \ + bsdtar \ btdownloadcurses.py \ btdownloadgui.py \ c++ \ @@ -412,6 +464,7 @@ CLEANFILES = \ conjure \ cowthink \ createdb \ + createuser \ dcop \ declare \ dfutool \ @@ -420,14 +473,19 @@ CLEANFILES = \ dpkg-query \ dpkg-reconfigure \ dropdb \ + dropuser \ edquota \ + f77 \ + f95 \ filebucket \ freeciv-sdl \ freeciv-xaw \ g++ \ g4 \ g77 \ + g95 \ gcj \ + gfortran \ gkrellm2 \ gmake \ gmplayer \ @@ -469,9 +527,11 @@ CLEANFILES = \ lvresize \ lvs \ lvscan \ + lz4c \ mailsnarf \ mdecrypt \ mencoder \ + micropython \ mkisofs \ mogrify \ montage \ @@ -510,9 +570,18 @@ CLEANFILES = \ pvs \ pvscan \ pxz \ + py.test-2 \ + py.test-3 \ pydoc3 \ + pypy \ + pypy3 \ python2 \ python3 \ + pyvenv-3.4 \ + pyvenv-3.5 \ + qemu-kvm \ + qemu-system-i386 \ + qemu-system-x86_64 \ quotacheck \ quotaoff \ quotaon \ @@ -532,6 +601,7 @@ CLEANFILES = \ sdptool \ setquota \ sftp \ + sidedoor \ slogin \ smbcacls \ smbcquotas \ @@ -541,6 +611,7 @@ CLEANFILES = \ smbtree \ sparc-koji \ spovray \ + star \ stream \ sudoedit \ tightvncviewer \ @@ -571,7 +642,12 @@ CLEANFILES = \ ypcat symlinks: $(targetdir) $(DATA) - for file in aclocal-1.11 ; do \ + for file in 7za ; do \ + rm -f $(targetdir)/$$file && \ + $(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 \ rm -f $(targetdir)/$$file && \ $(LN_S) aclocal $(targetdir)/$$file ; \ done @@ -583,7 +659,8 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) asciidoc $(targetdir)/$$file ; \ done - for file in automake-1.11 ; do \ + for file in automake-1.10 automake-1.11 automake-1.12 automake-1.13 \ + automake-1.14 automake-1.15 ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) automake $(targetdir)/$$file ; \ done @@ -605,7 +682,7 @@ symlinks: $(targetdir) $(DATA) done for file in ncal ; do \ rm -f $(targetdir)/$$file && \ - $(LN_S) cal $(targetdir)/$$file ; \ + $(LN_S) _cal $(targetdir)/$$file ; \ done for file in pccardctl ; do \ rm -f $(targetdir)/$$file && \ @@ -648,7 +725,7 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) function $(targetdir)/$$file ; \ done - for file in g++ c++ g77 gcj gpc cc ; do \ + for file in cc c++ g++ gfortran f77 g77 f95 g95 gcj gpc ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) gcc $(targetdir)/$$file ; \ done @@ -671,7 +748,7 @@ symlinks: $(targetdir) $(DATA) done for file in hd ; do \ rm -f $(targetdir)/$$file && \ - $(LN_S) hexdump $(targetdir)/$$file ; \ + $(LN_S) _hexdump $(targetdir)/$$file ; \ done for file in hping hping3 ; do \ rm -f $(targetdir)/$$file && \ @@ -719,6 +796,10 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) lvm $(targetdir)/$$file ; \ done + for file in lz4c ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) lz4 $(targetdir)/$$file ; \ + done for file in clzip pdlzip plzip ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) lzip $(targetdir)/$$file ; \ @@ -775,7 +856,7 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) pm-hibernate $(targetdir)/$$file ; \ done - for file in createdb dropdb ; do \ + for file in createdb createuser dropdb dropuser ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) psql $(targetdir)/$$file ; \ done @@ -792,18 +873,30 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) puppet $(targetdir)/$$file ; \ done + for file in py.test-2 py.test-3 ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) py.test $(targetdir)/$$file ; \ + done for file in pydoc3 ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) pydoc $(targetdir)/$$file ; \ done - for file in python2 python3 ; do \ + for file in pypy pypy3 python2 python3 micropython ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) python $(targetdir)/$$file ; \ done + for file in pyvenv-3.4 pyvenv-3.5 ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) pyvenv $(targetdir)/$$file ; \ + done for file in dcop ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) qdbus $(targetdir)/$$file ; \ done + for file in qemu-kvm qemu-system-i386 qemu-system-x86_64 ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) qemu $(targetdir)/$$file ; \ + done for file in setquota edquota quotacheck repquota quotaon quotaoff ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) quota $(targetdir)/$$file ; \ @@ -828,7 +921,7 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) sbcl $(targetdir)/$$file ; \ done - for file in slogin autossh sftp scp ; do \ + for file in slogin autossh sftp scp sidedoor ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) ssh $(targetdir)/$$file ; \ done @@ -871,3 +964,11 @@ all-local: symlinks install-data-local: targetdir = $(DESTDIR)$(bashcompdir) install-data-local: symlinks + +check-local: + ret=0 + for file in $(bashcomp_DATA) ; do \ + $${bashcomp_bash:-$${BASH:-bash}} \ + -O extglob -n $$file || ret=$$? ; \ + done ; \ + exit $$ret diff --git a/completions/Makefile.in b/completions/Makefile.in deleted file mode 100644 index fef6ebc6..00000000 --- a/completions/Makefile.in +++ /dev/null @@ -1,1258 +0,0 @@ -# Makefile.in generated by automake 1.11.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ - esac; \ - test $$am__dry = yes; \ - } -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = completions -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(bashcompdir)" -DATA = $(bashcomp_DATA) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -compatdir = @compatdir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -bashcompdir = $(pkgdatadir)/completions -bashcomp_DATA = a2x \ - abook \ - aclocal \ - acpi \ - add_members \ - alias \ - ant \ - apache2ctl \ - apt-build \ - apt-cache \ - apt-get \ - aptitude \ - arch \ - arping \ - arpspoof \ - asciidoc \ - aspell \ - autoconf \ - automake \ - autoreconf \ - autorpm \ - autoscan \ - avctrl \ - badblocks \ - bk \ - brctl \ - btdownloadheadless.py \ - bzip2 \ - cal \ - cancel \ - cardctl \ - ccache \ - cfagent \ - cfrun \ - chage \ - change_pw \ - check_db \ - check_perms \ - chgrp \ - chkconfig \ - chown \ - chpasswd \ - chronyc \ - chrpath \ - chsh \ - cksfv \ - cleanarch \ - clisp \ - clone_member \ - complete \ - config_list \ - configure \ - convert \ - cowsay \ - cpan2dist \ - cpio \ - cppcheck \ - crontab \ - cryptsetup \ - curl \ - cvs \ - cvsps \ - dd \ - desktop-file-validate \ - dhclient \ - dict \ - dmesg \ - dnsspoof \ - dot \ - dpkg \ - dpkg-source \ - dselect \ - dsniff \ - dumpdb \ - dumpe2fs \ - e2freefrag \ - e2label \ - eject \ - eog \ - ether-wake \ - evince \ - explodepkg \ - export \ - faillog \ - fbgs \ - fbi \ - feh \ - file \ - file-roller \ - filefrag \ - filesnarf \ - find \ - find_member \ - freeciv-gtk2 \ - freeciv-server \ - function \ - fusermount \ - gcc \ - gcl \ - gdb \ - genaliases \ - gendiff \ - genisoimage \ - getent \ - gkrellm \ - gnatmake \ - gnome-mplayer \ - gpasswd \ - gpg \ - gpg2 \ - gphoto2 \ - gprof \ - groupadd \ - groupdel \ - groupmems \ - groupmod \ - growisofs \ - grpck \ - gzip \ - hcitool \ - hddtemp \ - hexdump \ - hid2hci \ - hping2 \ - htop \ - htpasswd \ - hwclock \ - iconv \ - id \ - idn \ - iftop \ - ifup \ - info \ - inject \ - insmod \ - installpkg \ - interdiff \ - invoke-rc.d \ - ionice \ - ip \ - iperf \ - ipmitool \ - ipsec \ - iptables \ - ipv6calc \ - iscsiadm \ - isql \ - iwconfig \ - iwlist \ - iwpriv \ - iwspy \ - jar \ - jarsigner \ - java \ - javaws \ - jps \ - k3b \ - kcov \ - kill \ - killall \ - kldload \ - kldunload \ - koji \ - ktutil \ - larch \ - lastlog \ - ldapsearch \ - ldapvi \ - lftp \ - lftpget \ - lilo \ - links \ - lintian \ - lisp \ - list_admins \ - list_lists \ - list_members \ - list_owners \ - look \ - lpq \ - lpr \ - lrzip \ - lsof \ - lua \ - luac \ - luseradd \ - luserdel \ - lvm \ - lzip \ - lzma \ - lzop \ - macof \ - mailmanctl \ - make \ - makepkg \ - man \ - mc \ - mcrypt \ - mdadm \ - mdtool \ - medusa \ - mii-diag \ - mii-tool \ - minicom \ - mkinitrd \ - mktemp \ - mmsitepass \ - modinfo \ - modprobe \ - monodevelop \ - mount \ - mount.linux \ - mplayer \ - msynctool \ - mtx \ - munindoc \ - munin-node-configure \ - munin-run \ - munin-update \ - mussh \ - mutt \ - mysql \ - mysqladmin \ - nc \ - ncftp \ - nethogs \ - newgrp \ - newlist \ - newusers \ - ngrep \ - nmap \ - nmcli \ - nslookup \ - ntpdate \ - openssl \ - opera \ - p4 \ - pack200 \ - passwd \ - patch \ - perl \ - pgrep \ - pidof \ - pine \ - ping \ - pkg-config \ - pkg-get \ - pkg_delete \ - pkgadd \ - pkgrm \ - pkgtool \ - pkgutil \ - plague-client \ - pm-hibernate \ - pm-is-supported \ - pm-powersave \ - portinstall \ - portupgrade \ - postcat \ - postconf \ - postfix \ - postmap \ - postsuper \ - povray \ - prelink \ - protoc \ - psql \ - puppet \ - pwck \ - pwd \ - pwdx \ - pwgen \ - pydoc \ - pylint \ - python \ - qdbus \ - qemu \ - qrunner \ - querybts \ - quota \ - rcs \ - rdesktop \ - remove_members \ - removepkg \ - renice \ - reportbug \ - reptyr \ - resolvconf \ - rfkill \ - ri \ - rmlist \ - rmmod \ - route \ - rpcdebug \ - rpm \ - rpm2tgz \ - rpmcheck \ - rrdtool \ - rsync \ - rtcwake \ - sbcl \ - sbopkg \ - screen \ - sh \ - sitecopy \ - slackpkg \ - slapt-get \ - slapt-src \ - smartctl \ - smbclient \ - snownews \ - sqlite3 \ - ss \ - ssh \ - ssh-add \ - ssh-copy-id \ - sshfs \ - sshmitm \ - sshow \ - strace \ - strings \ - su \ - sudo \ - svcadm \ - svk \ - sync_members \ - sysbench \ - sysctl \ - tar \ - tcpdump \ - tcpkill \ - tcpnice \ - tracepath \ - tshark \ - tune2fs \ - umount \ - umount.linux \ - unace \ - unpack200 \ - unrar \ - unshunt \ - update-alternatives \ - update-rc.d \ - upgradepkg \ - urlsnarf \ - useradd \ - userdel \ - usermod \ - valgrind \ - vipw \ - vmstat \ - vncviewer \ - vpnc \ - watch \ - webmitm \ - wget \ - wine \ - withlist \ - wodim \ - wol \ - wsimport \ - wtf \ - wvdial \ - xfreerdp \ - xgamma \ - xhost \ - xm \ - xmllint \ - xmlwf \ - xmms \ - xmodmap \ - xrandr \ - xrdb \ - xsltproc \ - xxd \ - xz \ - xzdec \ - ypmatch \ - yum-arch - -EXTRA_DIST = $(bashcomp_DATA) \ - _mock _modules _subversion _udevadm _yum _yum-utils - -CLEANFILES = \ - aclocal-1.11 \ - alpine \ - alternatives \ - animate \ - apropos \ - arm-koji \ - asciidoc.py \ - autoheader \ - automake-1.11 \ - autossh \ - autoupdate \ - btdownloadcurses.py \ - btdownloadgui.py \ - c++ \ - cc \ - cdrecord \ - ci \ - ciptool \ - civclient \ - civserver \ - clzip \ - co \ - colormake \ - compare \ - compgen \ - composite \ - conjure \ - cowthink \ - createdb \ - dcop \ - declare \ - dfutool \ - display \ - dpkg-deb \ - dpkg-query \ - dpkg-reconfigure \ - dropdb \ - edquota \ - filebucket \ - freeciv-sdl \ - freeciv-xaw \ - g++ \ - g4 \ - g77 \ - gcj \ - gkrellm2 \ - gmake \ - gmplayer \ - gnumake \ - gpc \ - hciattach \ - hciconfig \ - hd \ - host \ - hping \ - hping3 \ - identify \ - ifdown \ - ifstatus \ - import \ - insmod.static \ - javac \ - javadoc \ - kplayer \ - l2ping \ - lbzip2 \ - ldapadd \ - ldapcompare \ - ldapdelete \ - ldapmodify \ - ldapmodrdn \ - ldappasswd \ - ldapwhoami \ - lintian-info \ - lusermod \ - lvchange \ - lvcreate \ - lvdisplay \ - lvextend \ - lvmdiskscan \ - lvreduce \ - lvremove \ - lvrename \ - lvresize \ - lvs \ - lvscan \ - mailsnarf \ - mdecrypt \ - mencoder \ - mkisofs \ - mogrify \ - montage \ - mplayer2 \ - msgsnarf \ - muttng \ - ncal \ - pbzip2 \ - pccardctl \ - pdlzip \ - perldoc \ - phing \ - pigz \ - pinfo \ - ping6 \ - pkg_deinstall \ - pkg_info \ - pkill \ - plzip \ - pm-suspend \ - pm-suspend-hybrid \ - pmake \ - postalias \ - ppc-koji \ - puppetca \ - puppetd \ - puppetdoc \ - puppetmasterd \ - puppetqd \ - puppetrun \ - pvchange \ - pvcreate \ - pvdisplay \ - pvmove \ - pvremove \ - pvs \ - pvscan \ - pxz \ - pydoc3 \ - python2 \ - python3 \ - quotacheck \ - quotaoff \ - quotaon \ - ralsh \ - rcsdiff \ - rdict \ - repquota \ - rfcomm \ - rlog \ - rpm2targz \ - rpm2txz \ - rpmbuild \ - rpmbuild-md5 \ - s390-koji \ - sbcl-mt \ - scp \ - sdptool \ - setquota \ - sftp \ - slogin \ - smbcacls \ - smbcquotas \ - smbget \ - smbpasswd \ - smbtar \ - smbtree \ - sparc-koji \ - spovray \ - stream \ - sudoedit \ - tightvncviewer \ - tracepath6 \ - typeset \ - vgcfgbackup \ - vgcfgrestore \ - vgchange \ - vgck \ - vgconvert \ - vgcreate \ - vgdisplay \ - vgexport \ - vgextend \ - vgimport \ - vgmerge \ - vgmknodes \ - vgreduce \ - vgremove \ - vgrename \ - vgs \ - vgscan \ - vgsplit \ - vigr \ - whatis \ - xpovray \ - xvnc4viewer \ - ypcat - -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign completions/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign completions/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-bashcompDATA: $(bashcomp_DATA) - @$(NORMAL_INSTALL) - @list='$(bashcomp_DATA)'; test -n "$(bashcompdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(bashcompdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(bashcompdir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(bashcompdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(bashcompdir)" || exit $$?; \ - done - -uninstall-bashcompDATA: - @$(NORMAL_UNINSTALL) - @list='$(bashcomp_DATA)'; test -n "$(bashcompdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(bashcompdir)'; $(am__uninstall_files_from_dir) -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(DATA) all-local -installdirs: - for dir in "$(DESTDIR)$(bashcompdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-bashcompDATA install-data-local - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-bashcompDATA - -.MAKE: install-am install-strip - -.PHONY: all all-am all-local check check-am clean clean-generic \ - distclean distclean-generic distdir dvi dvi-am html html-am \ - info info-am install install-am install-bashcompDATA \ - install-data install-data-am install-data-local install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ - uninstall-bashcompDATA - - -symlinks: $(targetdir) $(DATA) - for file in aclocal-1.11 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) aclocal $(targetdir)/$$file ; \ - done - for file in phing ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) ant $(targetdir)/$$file ; \ - done - for file in asciidoc.py ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) asciidoc $(targetdir)/$$file ; \ - done - for file in automake-1.11 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) automake $(targetdir)/$$file ; \ - done - for file in autoheader ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) autoreconf $(targetdir)/$$file ; \ - done - for file in autoupdate ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) autoscan $(targetdir)/$$file ; \ - done - for file in btdownloadcurses.py btdownloadgui.py ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) btdownloadheadless.py $(targetdir)/$$file ; \ - done - for file in lbzip2 pbzip2 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) bzip2 $(targetdir)/$$file ; \ - done - for file in ncal ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) cal $(targetdir)/$$file ; \ - done - for file in pccardctl ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) cardctl $(targetdir)/$$file ; \ - done - for file in compgen ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) complete $(targetdir)/$$file ; \ - done - for file in mogrify display animate identify montage composite \ - compare conjure import stream ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) convert $(targetdir)/$$file ; \ - done - for file in cowthink ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) cowsay $(targetdir)/$$file ; \ - done - for file in rdict ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) dict $(targetdir)/$$file ; \ - done - for file in dpkg-deb dpkg-query dpkg-reconfigure ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) dpkg $(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 \ - rm -f $(targetdir)/$$file && \ - $(LN_S) freeciv-gtk2 $(targetdir)/$$file ; \ - done - for file in civserver ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) freeciv-server $(targetdir)/$$file ; \ - done - for file in declare typeset ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) function $(targetdir)/$$file ; \ - done - for file in g++ c++ g77 gcj gpc cc ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) gcc $(targetdir)/$$file ; \ - done - for file in mkisofs ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) genisoimage $(targetdir)/$$file ; \ - done - for file in gkrellm2 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) gkrellm $(targetdir)/$$file ; \ - done - for file in pigz ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) gzip $(targetdir)/$$file ; \ - done - for file in sdptool l2ping rfcomm ciptool dfutool hciconfig \ - hciattach ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) hcitool $(targetdir)/$$file ; \ - done - for file in hd ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) hexdump $(targetdir)/$$file ; \ - done - for file in hping hping3 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) hping2 $(targetdir)/$$file ; \ - done - for file in ifdown ifstatus ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) ifup $(targetdir)/$$file ; \ - done - for file in pinfo ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) info $(targetdir)/$$file ; \ - done - for file in insmod.static ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) insmod $(targetdir)/$$file ; \ - done - for file in javac javadoc ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) java $(targetdir)/$$file ; \ - done - for file in arm-koji ppc-koji s390-koji sparc-koji ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) koji $(targetdir)/$$file ; \ - done - for file in ldapadd ldapmodify ldapdelete ldapcompare ldapmodrdn \ - ldapwhoami ldappasswd ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) ldapsearch $(targetdir)/$$file ; \ - done - for file in lintian-info ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) lintian $(targetdir)/$$file ; \ - done - for file in lusermod ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) luseradd $(targetdir)/$$file ; \ - done - for file in lvmdiskscan pvscan pvs pvdisplay pvchange pvcreate pvmove \ - pvremove vgscan vgs vgdisplay vgchange vgremove vgrename \ - vgreduce vgextend vgimport vgexport vgck vgconvert vgcreate \ - vgcfgbackup vgcfgrestore vgmerge vgsplit vgmknodes lvscan lvs \ - lvdisplay lvchange lvcreate lvremove lvrename lvreduce \ - lvresize lvextend ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) lvm $(targetdir)/$$file ; \ - done - for file in clzip pdlzip plzip ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) lzip $(targetdir)/$$file ; \ - done - for file in colormake gmake gnumake pmake ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) make $(targetdir)/$$file ; \ - done - for file in apropos whatis ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) man $(targetdir)/$$file ; \ - done - for file in mdecrypt ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) mcrypt $(targetdir)/$$file ; \ - done - for file in mplayer2 mencoder gmplayer kplayer ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) mplayer $(targetdir)/$$file ; \ - done - for file in muttng ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) mutt $(targetdir)/$$file ; \ - done - for file in host ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) nslookup $(targetdir)/$$file ; \ - done - for file in g4 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) p4 $(targetdir)/$$file ; \ - done - for file in perldoc ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) perl $(targetdir)/$$file ; \ - done - for file in alpine ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) pine $(targetdir)/$$file ; \ - done - for file in ping6 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) ping $(targetdir)/$$file ; \ - done - for file in pkg_info pkg_deinstall ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) pkg_delete $(targetdir)/$$file ; \ - done - for file in pkill ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) pgrep $(targetdir)/$$file ; \ - done - for file in pm-suspend pm-suspend-hybrid ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) pm-hibernate $(targetdir)/$$file ; \ - done - for file in createdb dropdb ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) psql $(targetdir)/$$file ; \ - done - for file in postalias ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) postmap $(targetdir)/$$file ; \ - done - for file in xpovray spovray ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) povray $(targetdir)/$$file ; \ - done - for file in puppetmasterd puppetd puppetca ralsh puppetrun puppetqd \ - filebucket puppetdoc ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) puppet $(targetdir)/$$file ; \ - done - for file in pydoc3 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) pydoc $(targetdir)/$$file ; \ - done - for file in python2 python3 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) python $(targetdir)/$$file ; \ - done - for file in dcop ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) qdbus $(targetdir)/$$file ; \ - done - for file in setquota edquota quotacheck repquota quotaon quotaoff ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) quota $(targetdir)/$$file ; \ - done - for file in ci co rlog rcsdiff ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) rcs $(targetdir)/$$file ; \ - done - for file in rpmbuild rpmbuild-md5 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) rpm $(targetdir)/$$file ; \ - done - for file in rpm2txz rpm2targz ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) rpm2tgz $(targetdir)/$$file ; \ - done - for file in smbget smbcacls smbcquotas smbpasswd smbtar smbtree ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) smbclient $(targetdir)/$$file ; \ - done - for file in sbcl-mt ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) sbcl $(targetdir)/$$file ; \ - done - for file in slogin autossh sftp scp ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) ssh $(targetdir)/$$file ; \ - done - for file in sudoedit ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) sudo $(targetdir)/$$file ; \ - done - for file in tracepath6 ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) tracepath $(targetdir)/$$file ; \ - done - for file in alternatives ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) update-alternatives $(targetdir)/$$file ; \ - done - for file in vigr ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) vipw $(targetdir)/$$file ; \ - done - for file in tightvncviewer xvnc4viewer ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) vncviewer $(targetdir)/$$file ; \ - done - for file in cdrecord ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) wodim $(targetdir)/$$file ; \ - done - for file in pxz ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) xz $(targetdir)/$$file ; \ - done - for file in ypcat ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) ypmatch $(targetdir)/$$file ; \ - done -.PHONY: symlinks - -all-local: targetdir = . -all-local: symlinks - -install-data-local: targetdir = $(DESTDIR)$(bashcompdir) -install-data-local: symlinks - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/completions/cal b/completions/_cal index 880b0b35..dfe49903 100644 --- a/completions/cal +++ b/completions/_cal @@ -1,5 +1,8 @@ # cal(1) completion -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + _cal() { local cur prev words cword @@ -31,4 +34,4 @@ _cal() } && complete -F _cal cal ncal -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/_chfn b/completions/_chfn new file mode 100644 index 00000000..334967fa --- /dev/null +++ b/completions/_chfn @@ -0,0 +1,8 @@ +# chfn(1) completion -*- shell-script -*- + +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + +complete -u chfn + +# ex: filetype=sh diff --git a/completions/chsh b/completions/_chsh index f65291a1..88e8522e 100644 --- a/completions/chsh +++ b/completions/_chsh @@ -1,5 +1,8 @@ # chsh(1) completion -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + _chsh() { local cur prev words cword @@ -7,11 +10,11 @@ _chsh() case $prev in --list-shells|--help|-v|--version) - return 0 + return ;; -s|--shell) _shells - return 0 + return ;; esac @@ -21,8 +24,7 @@ _chsh() _allowed_users fi - return 0 } && complete -F _chsh chsh -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dmesg b/completions/_dmesg index 3d9bc662..2ca7fdf1 100644 --- a/completions/dmesg +++ b/completions/_dmesg @@ -1,5 +1,8 @@ # dmesg(1) completion -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + _dmesg() { [[ $OSTYPE == *solaris* ]] && return # no args there @@ -28,4 +31,4 @@ _dmesg() } && complete -F _dmesg dmesg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/eject b/completions/_eject index d6b1f6d9..8f800f15 100644 --- a/completions/eject +++ b/completions/_eject @@ -1,5 +1,8 @@ # bash completion for eject(1) -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + _eject() { local cur prev words cword @@ -27,4 +30,4 @@ _eject() } && complete -F _eject eject -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/hexdump b/completions/_hexdump index c566f9d6..ed5cb08b 100644 --- a/completions/hexdump +++ b/completions/_hexdump @@ -1,5 +1,8 @@ # hexdump(1) completion -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + _hexdump() { local cur prev words cword @@ -26,4 +29,4 @@ _hexdump() } && complete -F _hexdump hexdump hd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/hwclock b/completions/_hwclock index 9f8f9b15..2d190283 100644 --- a/completions/hwclock +++ b/completions/_hwclock @@ -1,5 +1,8 @@ # hwclock(8) completion -*- shell-script -*- +# Use of this file is deprecated. Upstream completion is available in +# util-linux >= 2.23, use that instead. + _hwclock() { local cur prev words cword @@ -20,4 +23,4 @@ _hwclock() } && complete -F _hwclock hwclock -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ionice b/completions/_ionice index 6d9bdd46..9b378ee8 100644 --- a/completions/ionice +++ b/completions/_ionice @@ -1,5 +1,8 @@ # ionice(1) completion -*- shell-script -*- +# Use of this file is deprecated. Upstream completion is available in +# util-linux >= 2.23, use that instead. + _ionice() { local cur prev words cword @@ -54,4 +57,4 @@ _ionice() } && complete -F _ionice ionice -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/look b/completions/_look index df914452..6ea41cce 100644 --- a/completions/look +++ b/completions/_look @@ -1,5 +1,8 @@ # look(1) completion -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + _look() { local cur prev words cword @@ -11,4 +14,4 @@ _look() } && complete -F _look -o default look -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/_mock b/completions/_mock index c616aed0..9649d306 100644 --- a/completions/_mock +++ b/completions/_mock @@ -24,20 +24,20 @@ _mock() case $prev in -h|--help|--copyin|--copyout|--arch|-D|--define|--with|--without|\ --uniqueext|--rpmbuild_timeout|--sources|--cwd) - return 0 + return ;; -r|--root) COMPREPLY=( $( compgen -W "$( command ls $cfgdir )" -- "$cur" ) ) COMPREPLY=( ${COMPREPLY[@]/%.cfg/} ) - return 0 + return ;; --configdir|--resultdir) _filedir -d - return 0 + return ;; --spec) _filedir spec - return 0 + return ;; --target) # Yep, compatible archs, not compatible build archs @@ -45,17 +45,17 @@ _mock() # This would actually depend on what the target root # can be used to build for... COMPREPLY=( $( compgen -W "$( command rpm --showrc | \ - sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p' )" \ + command sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p' )" \ -- "$cur" ) ) - return 0 + return ;; --enable-plugin|--disable-plugin) COMPREPLY=( $( compgen -W "$plugins" -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]] ; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -66,4 +66,4 @@ _mock() } && complete -F _mock mock -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/_modules b/completions/_modules index b5a1d94a..9e48589b 100644 --- a/completions/_modules +++ b/completions/_modules @@ -23,13 +23,13 @@ _module_list () { - local modules="$( sed 's/:/ /g' <<<$LOADEDMODULES | sort )" + local modules="$( command sed 's/:/ /g' <<<$LOADEDMODULES | sort )" compgen -W "$modules" -- $1 } _module_path () { - local modules="$( sed 's/:/ /g' <<<$MODULEPATH | sort )" + local modules="$( command sed 's/:/ /g' <<<$MODULEPATH | sort )" compgen -W "$modules" -- $1 } @@ -38,7 +38,7 @@ _module_avail () local modules="$( \ module avail 2>&1 | \ command grep -E -v '^(-|$)' | \ - xargs printf '%s\n' | sed -e 's/(default)//g' | sort )" + xargs printf '%s\n' | command sed -e 's/(default)//g' | sort )" compgen -W "$modules" -- $1 } @@ -54,7 +54,7 @@ _module () local options options="$( module help 2>&1 | command grep -E '^[[:space:]]*\+' | \ - awk '{print $2}' | sed -e 's/|/ /g' | sort )" + awk '{print $2}' | command sed -e 's/|/ /g' | sort )" COMPREPLY=( $(compgen -W "$options" -- "$cur") ) @@ -77,8 +77,8 @@ _module () ;; esac fi - return 0 + } && complete -F _module -o default module -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/newgrp b/completions/_newgrp index ddcd79e8..0f0d3f93 100644 --- a/completions/newgrp +++ b/completions/_newgrp @@ -1,5 +1,8 @@ # newgrp(1) completion -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + _newgrp() { local cur prev words cword @@ -13,4 +16,4 @@ _newgrp() } && complete -F _newgrp newgrp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/nmcli b/completions/_nmcli index 00628b41..f77f0505 100644 --- a/completions/nmcli +++ b/completions/_nmcli @@ -1,4 +1,7 @@ -# nmcli completion -*- shell-script -*- +# nmcli completion -*- shell-script -*- + +# Use of this file is deprecated. Upstream completion is available in +# NetworkManager >= 0.9.8.0, use that instead. _nmcli_list() { @@ -39,35 +42,35 @@ _nmcli() case $prev in -m|--mode) COMPREPLY=( $( compgen -W 'tabular multiline' -- "$cur" ) ) - return 0 + return ;; -f|--fields) COMPREPLY=( $( compgen -W 'all common' -- "$cur" ) ) - return 0 + return ;; -e|--escape) _nmcli_list "yes no" - return 0 + return ;; id) _nmcli_con_id - return 0 + return ;; uuid) _nmcli_con_uuid - return 0 + return ;; iface) _available_interfaces - return 0 + return ;; bssid) _nmcli_ab_bssid - return 0 + return ;; wep-key-type) _nmcli_list "key phrase" - return 0 + return ;; esac @@ -87,23 +90,23 @@ _nmcli() case $command in enable) _nmcli_list "true false" - return 0 + return ;; sleep) _nmcli_list "true false" - return 0 + return ;; wifi) _nmcli_list "on off" - return 0 + return ;; wwan) _nmcli_list "on off" - return 0 + return ;; wimax) _nmcli_list "on off" - return 0 + return ;; esac @@ -114,7 +117,7 @@ _nmcli() case $command in list) COMPREPLY=( $( compgen -W 'id uuid' -- "$cur" ) ) - return 0 + return ;; up) if [[ "$cur" == -* ]]; then @@ -124,15 +127,15 @@ _nmcli() COMPREPLY=( $( compgen -W 'id uuid iface ap nsp' \ -- "$cur" ) ) fi - return 0 + return ;; down) COMPREPLY=( $( compgen -W 'id uuid' -- "$cur" ) ) - return 0 + return ;; delete) COMPREPLY=( $( compgen -W 'id uuid' -- "$cur" ) ) - return 0 + return ;; esac @@ -143,7 +146,7 @@ _nmcli() case $command in list) COMPREPLY=( $( compgen -W 'iface' -- "$cur" ) ) - return 0 + return ;; disconnect) if [[ "$cur" == -* ]]; then @@ -152,7 +155,7 @@ _nmcli() else COMPREPLY=( $( compgen -W 'iface' -- "$cur" ) ) fi - return 0 + return ;; wifi) local subcommand=${words[3]} @@ -161,7 +164,7 @@ _nmcli() list) COMPREPLY=( $( compgen -W 'iface bssid' \ -- "$cur" ) ) - return 0 + return ;; connect) if [[ "$cur" == -* ]]; then @@ -176,12 +179,12 @@ _nmcli() -- "$cur" ) ) fi fi - return 0 + return ;; esac COMPREPLY=( $( compgen -W 'list connect' -- "$cur" ) ) - return 0 + return ;; esac @@ -192,8 +195,7 @@ _nmcli() fi - return 0 } && complete -F _nmcli nmcli -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/renice b/completions/_renice index 60968eef..1f1a6102 100644 --- a/completions/renice +++ b/completions/_renice @@ -1,5 +1,8 @@ # renice(8) completion -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + _renice() { local cur prev words cword @@ -26,4 +29,4 @@ _renice() } && complete -F _renice renice -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/_yum-utils b/completions/_repomanage index 22b97af8..c1072e79 100644 --- a/completions/_yum-utils +++ b/completions/_repomanage @@ -8,7 +8,7 @@ _repomanage() local cur prev words cword split _init_completion -s || return - [[ "$prev" == -@(h|-help|k|-keep) ]] && return 0 + [[ "$prev" == -@([hk]|-help|-keep) ]] && return $split && return @@ -21,4 +21,4 @@ _repomanage() } && complete -F _repomanage repomanage -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/reptyr b/completions/_reptyr index 3097daa9..4a087b49 100644 --- a/completions/reptyr +++ b/completions/_reptyr @@ -1,5 +1,8 @@ # bash completion for reptyr(1) -*- shell-script -*- +# Use of this file is deprecated. Upstream completion is available in +# reptyr > 0.6.2, use that instead. + _reptyr() { local cur prev words cword @@ -7,17 +10,17 @@ _reptyr() case $prev in -l) - return 0 + return ;; esac if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi [[ $prev != +([0-9]) ]] && _pids } && complete -F _reptyr reptyr -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rtcwake b/completions/_rtcwake index f276c1be..b03c1244 100644 --- a/completions/rtcwake +++ b/completions/_rtcwake @@ -1,5 +1,8 @@ # bash completion for rtcwake -*- shell-script -*- +# Use of this file is deprecated. Upstream completion is available in +# util-linux >= 2.23, use that instead. + _rtcwake() { local cur prev words cword split @@ -7,23 +10,23 @@ _rtcwake() case "$prev" in --help|-h|--version|-V|--seconds|-s|--time|-t) - return 0 + return ;; --mode|-m) COMPREPLY=( $( compgen -W 'standby mem disk on no off' -- "$cur" ) ) - return 0 + return ;; --device|-d) COMPREPLY=( $( command ls -d /dev/rtc?* 2>/dev/null ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) } && complete -F _rtcwake rtcwake -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/_runuser b/completions/_runuser new file mode 100644 index 00000000..95cf930a --- /dev/null +++ b/completions/_runuser @@ -0,0 +1,8 @@ +# runuser(1) completion -*- shell-script -*- + +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + +complete -u runuser + +# ex: filetype=sh diff --git a/completions/su b/completions/_su index fccca47b..2b069498 100644 --- a/completions/su +++ b/completions/_su @@ -1,5 +1,8 @@ # bash completion for su(1) -*- shell-script -*- +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + if [[ $OSTYPE != *linux* ]]; then complete -u su # default completion return @@ -32,6 +35,7 @@ _su() # linux-specific completion fi COMPREPLY=( $( compgen -u -- "$cur" ) ) -} && complete -F _su su +} && +complete -F _su su -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/_subversion b/completions/_subversion deleted file mode 100644 index 2f1752c0..00000000 --- a/completions/_subversion +++ /dev/null @@ -1,344 +0,0 @@ -# svn completion -*- shell-script -*- - -# Use of this file is deprecated. Upstream completion is available in -# subversion >= 0.12.0, use that instead. - -_svn() -{ - local cur prev words cword - _init_completion || return - - local commands - commands='add blame praise annotate ann cat checkout co cleanup commit \ - ci copy cp delete del remove rm diff di export help ? h import \ - info list ls lock log merge mkdir move mv rename ren \ - propdel pdel pd propedit pedit pe propget pget pg \ - proplist plist pl propset pset ps resolved revert \ - status stat st switch sw unlock update up' - - if [[ $cword -eq 1 ]] ; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) - else - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) - fi - else - - case $prev in - --config-dir) - _filedir -d - return 0 - ;; - -F|--file|--targets) - _filedir - return 0 - ;; - --encoding) - COMPREPLY=( $( compgen -W '$( iconv --list | \ - sed -e "s@//@@;" )' -- "$cur" ) ) - return 0 - ;; - --editor-cmd|--diff-cmd|--diff3-cmd) - words=(words[0] $cur) - cword=1 - _command - return 0 - ;; - esac - - local command=${words[1]} - - if [[ "$cur" == -* ]]; then - # possible options for the command - local options - case $command in - add) - options='--auto-props --no-auto-props --force --targets - --no-ignore --non-recursive --quiet' - ;; - blame|annotate|ann|praise) - options='--revision --username --password --no-auth-cache - --non-interactive --verbose --incremental --xml' - ;; - cat) - options='--revision --username --password --no-auth-cache - --non-interactive' - ;; - checkout|co) - options='--revision --quiet --non-recursive --username - --password --no-auth-cache --non-interactive - --ignore-externals' - ;; - cleanup) - options='--diff3-cmd' - ;; - commit|ci) - options='--message --file --encoding --force-log --quiet - --non-recursive --targets --editor-cmd --username - --password --no-auth-cache --non-interactive - --no-unlock' - ;; - copy|cp) - options='--message --file --encoding --force-log --revision - --quiet --editor-cmd -username --password - --no-auth-cache --non-interactive' - ;; - delete|del|remove|rm) - options='--force --message --file --encoding --force-log - --quiet --targets --editor-cmd --username - --password --no-auth-cache --non-interactive' - ;; - diff|di) - options='--revision --extensions --diff-cmd - --no-diff-deleted --non-recursive --username - --password --no-auth-cache --non-interactive - --force --old --new --notice-ancestry' - ;; - export) - options='--revision --quiet --username --password - --no-auth-cache --non-interactive --non-recursive - --force --native-eol --ignore-externals' - ;; - import) - options='--auto-props --no-auto-props --message --file - --encoding --force-log --quiet --non-recursive - --no-ignore --editor-cmd --username --password - --no-auth-cache --non-interactive' - ;; - info) - options='--username --password --no-auth-cache - --non-interactive --revision --xml --targets - --recursive --incremental' - ;; - list|ls) - options='--revision --verbose --recursive --username - --password --no-auth-cache --non-interactive - --incremental --xml' - ;; - lock) - options='--message --file --encoding --force-log --targets - --force --username --password --no-auth-cache - --non-interactive' - ;; - log) - options='--revision --verbose --targets --username - --password --no-auth-cache --non-interactive - --stop-on-copy --incremental --xml --quiet - --limit' - ;; - merge) - options='--revision --non-recursive --quiet --force - --dry-run --diff3-cmd --username --password - --no-auth-cache --non-interactive - --ignore-ancestry' - ;; - mkdir) - options='--message --file --encoding --force-log --quiet - --editor-cmd --username --password --no-auth-cache - --non-interactive' - ;; - move|mv|rename|ren) - options='--message --file --encoding --force-log --revision - --quiet --force --editor-cmd --username --password - --no-auth-cache --non-interactive' - ;; - propdel|pdel|pd) - options='--quiet --recursive --revision --revprop - --username --password --no-auth-cache - --non-interactive' - ;; - propedit|pedit|pe) - options='--revision --revprop --encoding --editor-cmd - --username --password --no-auth-cache - --non-interactive --force' - ;; - propget|pget|pg) - options='--recursive --revision --revprop --strict - --username --password --no-auth-cache - --non-interactive' - ;; - proplist|plist|pl) - options='--verbose --recursive --revision --revprop --quiet - --username --password --no-auth-cache - --non-interactive' - ;; - propset|pset|ps) - options='--file --quiet --targets --recursive --revprop - --encoding --username --password --no-auth-cache - --non-interactive --revision --force' - ;; - resolved) - options='--targets --recursive --quiet' - ;; - revert) - options='--targets --recursive --quiet' - ;; - status|stat|st) - options='--show-updates --verbose --non-recursive --quiet - --username --password --no-auth-cache - --non-interactive --no-ignore --ignore-externals - --incremental --xml' - ;; - switch|sw) - options='--relocate --revision --non-recursive --quiet - --username --password --no-auth-cache - --non-interactive --diff3-cmd' - ;; - unlock) - options='--targets --force --username --password - --no-auth-cache --non-interactive' - ;; - update|up) - options='--revision --non-recursive --quiet --username - --password --no-auth-cache --non-interactive - --diff3-cmd --ignore-externals' - ;; - esac - options+=" --help --config-dir" - - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) - else - if [[ "$command" == @(help|h|\?) ]]; then - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) - else - _filedir - fi - fi - fi - - return 0 -} && -complete -F _svn svn - -_svnadmin() -{ - local cur prev words cword - _init_completion || return - - local commands - 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 [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) - else - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) - fi - else - case $prev in - --config-dir) - _filedir -d - return 0 - ;; - --fs-type) - COMPREPLY=( $( compgen -W 'fsfs bdb' -- "$cur" ) ) - return 0 - ;; - esac - - local command=${words[1]} - - if [[ "$cur" == -* ]]; then - # possible options for the command - local options - case $command in - create) - options='--bdb-txn-nosync --bdb-log-keep --config-dir - --fs-type' - ;; - deltify) - options='--revision --quiet' - ;; - dump) - options='--revision --incremental --quiet --deltas' - ;; - hotcopy) - options='--clean-logs' - ;; - load) - options='--ignore-uuid --force-uuid --parent-dir --quiet - --use-pre-commit-hook --use-post-commit-hook' - ;; - rmtxns) - options='--quiet' - ;; - setlog) - options='--revision --bypass-hooks' - ;; - esac - - options+=" --help" - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) - else - if [[ "$command" == @(help|h|\?) ]]; then - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) - else - _filedir - fi - fi - fi - - return 0 -} && -complete -F _svnadmin -o default svnadmin - -_svnlook() -{ - local cur prev words cword - _init_completion || return - - local commands - 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 [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) - else - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) - fi - else - local command=${words[1]} - - if [[ "$cur" == -* ]]; then - # possible options for the command - local options - case $command in - author|cat|date|dirs-changed|info|log) - options='--revision --transaction' - ;; - changed) - options='--revision --transaction --copy-info' - ;; - diff) - options='--revision --transaction --no-diff-deleted - --no-diff-added --diff-copy-from' - ;; - history) - options='--revision --show-ids' - ;; - propget|proplist) - options='--revision --transaction --revprop' - ;; - tree) - options='--revision --transaction --show-ids --full-paths' - ;; - esac - - options+=" --help" - COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) - else - if [[ "$command" == @(help|h|\?) ]]; then - COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) - else - _filedir - fi - fi - fi - - return 0 -} && -complete -F _svnlook -o default svnlook - -# ex: ts=4 sw=4 et filetype=sh diff --git a/completions/_svn b/completions/_svn new file mode 100644 index 00000000..37b6b2b4 --- /dev/null +++ b/completions/_svn @@ -0,0 +1,212 @@ +# svn completion -*- shell-script -*- + +# Use of this file is deprecated. Upstream completion is available in +# subversion >= 0.12.0, use that instead. + +_svn() +{ + local cur prev words cword + _init_completion || return + + local commands + commands='add blame praise annotate ann cat checkout co cleanup commit \ + ci copy cp delete del remove rm diff di export help ? h import \ + info list ls lock log merge mkdir move mv rename ren \ + propdel pdel pd propedit pedit pe propget pget pg \ + proplist plist pl propset pset ps resolved revert \ + status stat st switch sw unlock update up' + + if [[ $cword -eq 1 ]] ; then + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) + else + COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + fi + else + + case $prev in + --config-dir) + _filedir -d + return + ;; + -F|--file|--targets) + _filedir + return + ;; + --encoding) + COMPREPLY=( $( compgen -W '$( iconv --list | \ + command sed -e "s@//@@;" )' -- "$cur" ) ) + return + ;; + --editor-cmd|--diff-cmd|--diff3-cmd) + words=(words[0] $cur) + cword=1 + _command + return + ;; + esac + + local command=${words[1]} + + if [[ "$cur" == -* ]]; then + # possible options for the command + local options + case $command in + add) + options='--auto-props --no-auto-props --force --targets + --no-ignore --non-recursive --quiet' + ;; + blame|annotate|ann|praise) + options='--revision --username --password --no-auth-cache + --non-interactive --verbose --incremental --xml' + ;; + cat) + options='--revision --username --password --no-auth-cache + --non-interactive' + ;; + checkout|co) + options='--revision --quiet --non-recursive --username + --password --no-auth-cache --non-interactive + --ignore-externals' + ;; + cleanup) + options='--diff3-cmd' + ;; + commit|ci) + options='--message --file --encoding --force-log --quiet + --non-recursive --targets --editor-cmd --username + --password --no-auth-cache --non-interactive + --no-unlock' + ;; + copy|cp) + options='--message --file --encoding --force-log --revision + --quiet --editor-cmd -username --password + --no-auth-cache --non-interactive' + ;; + delete|del|remove|rm) + options='--force --message --file --encoding --force-log + --quiet --targets --editor-cmd --username + --password --no-auth-cache --non-interactive' + ;; + diff|di) + options='--revision --extensions --diff-cmd + --no-diff-deleted --non-recursive --username + --password --no-auth-cache --non-interactive + --force --old --new --notice-ancestry' + ;; + export) + options='--revision --quiet --username --password + --no-auth-cache --non-interactive --non-recursive + --force --native-eol --ignore-externals' + ;; + import) + options='--auto-props --no-auto-props --message --file + --encoding --force-log --quiet --non-recursive + --no-ignore --editor-cmd --username --password + --no-auth-cache --non-interactive' + ;; + info) + options='--username --password --no-auth-cache + --non-interactive --revision --xml --targets + --recursive --incremental' + ;; + list|ls) + options='--revision --verbose --recursive --username + --password --no-auth-cache --non-interactive + --incremental --xml' + ;; + lock) + options='--message --file --encoding --force-log --targets + --force --username --password --no-auth-cache + --non-interactive' + ;; + log) + options='--revision --verbose --targets --username + --password --no-auth-cache --non-interactive + --stop-on-copy --incremental --xml --quiet + --limit' + ;; + merge) + options='--revision --non-recursive --quiet --force + --dry-run --diff3-cmd --username --password + --no-auth-cache --non-interactive + --ignore-ancestry' + ;; + mkdir) + options='--message --file --encoding --force-log --quiet + --editor-cmd --username --password --no-auth-cache + --non-interactive' + ;; + move|mv|rename|ren) + options='--message --file --encoding --force-log --revision + --quiet --force --editor-cmd --username --password + --no-auth-cache --non-interactive' + ;; + propdel|pdel|pd) + options='--quiet --recursive --revision --revprop + --username --password --no-auth-cache + --non-interactive' + ;; + propedit|pedit|pe) + options='--revision --revprop --encoding --editor-cmd + --username --password --no-auth-cache + --non-interactive --force' + ;; + propget|pget|pg) + options='--recursive --revision --revprop --strict + --username --password --no-auth-cache + --non-interactive' + ;; + proplist|plist|pl) + options='--verbose --recursive --revision --revprop --quiet + --username --password --no-auth-cache + --non-interactive' + ;; + propset|pset|ps) + options='--file --quiet --targets --recursive --revprop + --encoding --username --password --no-auth-cache + --non-interactive --revision --force' + ;; + resolved) + options='--targets --recursive --quiet' + ;; + revert) + options='--targets --recursive --quiet' + ;; + status|stat|st) + options='--show-updates --verbose --non-recursive --quiet + --username --password --no-auth-cache + --non-interactive --no-ignore --ignore-externals + --incremental --xml' + ;; + switch|sw) + options='--relocate --revision --non-recursive --quiet + --username --password --no-auth-cache + --non-interactive --diff3-cmd' + ;; + unlock) + options='--targets --force --username --password + --no-auth-cache --non-interactive' + ;; + update|up) + options='--revision --non-recursive --quiet --username + --password --no-auth-cache --non-interactive + --diff3-cmd --ignore-externals' + ;; + esac + options+=" --help --config-dir" + + COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + else + if [[ "$command" == @(help|[h?]) ]]; then + COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + else + _filedir + fi + fi + fi + +} && +complete -F _svn svn + +# ex: filetype=sh diff --git a/completions/_svnadmin b/completions/_svnadmin new file mode 100644 index 00000000..395ae119 --- /dev/null +++ b/completions/_svnadmin @@ -0,0 +1,78 @@ +# svnadmin completion -*- shell-script -*- + +# Use of this file is deprecated. Upstream completion is available in +# subversion >= 0.12.0, use that instead. + +_svnadmin() +{ + local cur prev words cword + _init_completion || return + + local commands + 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 [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) + else + COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + fi + else + case $prev in + --config-dir) + _filedir -d + return + ;; + --fs-type) + COMPREPLY=( $( compgen -W 'fsfs bdb' -- "$cur" ) ) + return + ;; + esac + + local command=${words[1]} + + if [[ "$cur" == -* ]]; then + # possible options for the command + local options + case $command in + create) + options='--bdb-txn-nosync --bdb-log-keep --config-dir + --fs-type' + ;; + deltify) + options='--revision --quiet' + ;; + dump) + options='--revision --incremental --quiet --deltas' + ;; + hotcopy) + options='--clean-logs' + ;; + load) + options='--ignore-uuid --force-uuid --parent-dir --quiet + --use-pre-commit-hook --use-post-commit-hook' + ;; + rmtxns) + options='--quiet' + ;; + setlog) + options='--revision --bypass-hooks' + ;; + esac + + options+=" --help" + COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + else + if [[ "$command" == @(help|[h?]) ]]; then + COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + else + _filedir + fi + fi + fi + +} && +complete -F _svnadmin -o default svnadmin + +# ex: filetype=sh diff --git a/completions/_svnlook b/completions/_svnlook new file mode 100644 index 00000000..a4f34243 --- /dev/null +++ b/completions/_svnlook @@ -0,0 +1,63 @@ +# svnlook completion -*- shell-script -*- + +# Use of this file is deprecated. Upstream completion is available in +# subversion >= 0.12.0, use that instead. + +_svnlook() +{ + local cur prev words cword + _init_completion || return + + local commands + 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 [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) + else + COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + fi + else + local command=${words[1]} + + if [[ "$cur" == -* ]]; then + # possible options for the command + local options + case $command in + author|cat|date|dirs-changed|info|log) + options='--revision --transaction' + ;; + changed) + options='--revision --transaction --copy-info' + ;; + diff) + options='--revision --transaction --no-diff-deleted + --no-diff-added --diff-copy-from' + ;; + history) + options='--revision --show-ids' + ;; + propget|proplist) + options='--revision --transaction --revprop' + ;; + tree) + options='--revision --transaction --show-ids --full-paths' + ;; + esac + + options+=" --help" + COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) + else + if [[ "$command" == @(help|[h?]) ]]; then + COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) + else + _filedir + fi + fi + fi + +} && +complete -F _svnlook -o default svnlook + +# ex: filetype=sh diff --git a/completions/_udevadm b/completions/_udevadm index 51ec0e5d..80424dca 100644 --- a/completions/_udevadm +++ b/completions/_udevadm @@ -61,7 +61,7 @@ _udevadm() ;; *) COMPREPLY=( $( compgen -W "$( "$1" --help 2>/dev/null | - awk '/^[[:space:]]+/ { print $1 }' )" -- "$cur" ) ) + awk '/^[ \t]/ { print $1 }' )" -- "$cur" ) ) ;; esac return @@ -76,4 +76,4 @@ _udevadm() } && complete -F _udevadm udevadm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/_write b/completions/_write new file mode 100644 index 00000000..49e56ffe --- /dev/null +++ b/completions/_write @@ -0,0 +1,8 @@ +# write(1) completion -*- shell-script -*- + +# Use of this file is deprecated on Linux. Upstream completion is +# available in util-linux >= 2.23, use that instead. + +complete -u write + +# ex: filetype=sh diff --git a/completions/_yum b/completions/_yum index 7b3f76a4..f3a104bd 100644 --- a/completions/_yum +++ b/completions/_yum @@ -9,12 +9,12 @@ _yum_list() # 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 | \ - sed -ne '/^Available /d' -e '/^Installed /d' -e '/^Updated /d' \ + command sed -ne '/^Available /d' -e '/^Installed /d' -e '/^Updated /d' \ -e 's/[[:space:]].*//p' ) ) else # Drop first line (e.g. "Updated Packages") COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \ - sed -ne 1d -e 's/[[:space:]].*//p' ) ) + command sed -ne 1d -e 's/[[:space:]].*//p' ) ) fi } @@ -24,13 +24,13 @@ _yum_repolist() # http://yum.baseurl.org/ticket/83 # Drop first ("repo id repo name") and last ("repolist: ...") rows yum --noplugins -C repolist $1 2>/dev/null | \ - sed -ne '/^repo\s\s*id/d' -e '/^repolist:/d' -e 's/[[:space:]].*//p' + command sed -ne '/^repo\s\s*id/d' -e '/^repolist:/d' -e 's/[[:space:]].*//p' } _yum_plugins() { command ls /usr/lib/yum-plugins/*.py{,c,o} 2>/dev/null \ - | sed -ne 's|.*/\([^./]*\)\.py[co]\{0,1\}$|\1|p' | sort -u + | command sed -ne 's|.*/\([^./]*\)\.py[co]\{0,1\}$|\1|p' | sort -u } _yum() @@ -50,25 +50,25 @@ _yum() if [[ "$cur" == @(*/|[.~])* && \ "$special" == @(deplist|install|update|upgrade) ]]; then _filedir rpm - return 0 + return fi case $special in install) _yum_list available - return 0 + return ;; deplist|info) _yum_list all - return 0 + return ;; upgrade|update) _yum_list updates - return 0 + return ;; remove|erase) # _rpm_installed_packages is not arch-qualified _yum_list installed - return 0 + return ;; esac fi @@ -117,11 +117,11 @@ _yum() ;; -R|-x|--exclude) # argument required but no completions available - return 0 + return ;; -h|--help|--version) # no other options useful with these - return 0 + return ;; *) COMPREPLY=( $( compgen -W 'install update check-update upgrade @@ -132,14 +132,13 @@ _yum() ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 fi } && complete -F _yum yum -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/a2x b/completions/a2x index 7c330908..06c7c3a4 100644 --- a/completions/a2x +++ b/completions/a2x @@ -37,4 +37,4 @@ _a2x() } && complete -F _a2x a2x -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/abook b/completions/abook index 07a0f090..4bb0e8e3 100644 --- a/completions/abook +++ b/completions/abook @@ -10,43 +10,40 @@ _abook() { compopt -o nospace COMPREPLY=( "-" ) - return 0 + return } case $cur in -*) - _longopt abook - return 0 + _longopt "$1" + return ;; esac case $prev in --informat) - COMPREPLY=( $( compgen -W "$(abook --formats | \ - sed -n -e 's/^\t\([a-z]*\).*/\1/p' -e '/^$/q')" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "$($1 --formats | \ + command sed -n -e 's/^'$'\t''\([a-z]*\).*/\1/p' -e '/^$/q')" \ + -- "$cur" ) ) ;; --outformat) - COMPREPLY=( $( compgen -W "$(abook --formats | \ - sed -n -e '/^$/,$s/^\t\([a-z]*\).*/\1/p')" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "$($1 --formats | \ + command sed -n -e '/^$/,$s/^'$'\t''\([a-z]*\).*/\1/p')" \ + -- "$cur" ) ) ;; --infile) COMPREPLY=( $( compgen -W stdin -- "$cur" ) ) _filedir - return 0 ;; --outfile) COMPREPLY=( $( compgen -W stdout -- "$cur" ) ) _filedir - return 0 ;; --config|--datafile) _filedir - return 0 ;; esac } && complete -F _abook abook -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/aclocal b/completions/aclocal index 2bbc3152..7a3d6467 100644 --- a/completions/aclocal +++ b/completions/aclocal @@ -7,29 +7,29 @@ _aclocal() case "$prev" in --help|--print-ac-dir|--version) - return 0 + return ;; --acdir|-I) _filedir -d - return 0 + return ;; --output) _filedir - return 0 + return ;; --warnings|-W) local cats=( syntax unsupported ) COMPREPLY=( $( compgen -W \ '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && -complete -F _aclocal aclocal aclocal-1.11 +complete -F _aclocal aclocal aclocal-1.1{0..5} -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/acpi b/completions/acpi index 16ae0d6e..b748cbde 100644 --- a/completions/acpi +++ b/completions/acpi @@ -19,4 +19,4 @@ _acpi() } && complete -F _acpi acpi -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/adb b/completions/adb new file mode 100644 index 00000000..d069b425 --- /dev/null +++ b/completions/adb @@ -0,0 +1,66 @@ +# 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 70b916be..d582d94b 100644 --- a/completions/add_members +++ b/completions/add_members @@ -8,15 +8,15 @@ _add_members() case $prev in -r|-d|--regular-members-file|--digest-members-file) _filedir - return 0 + return ;; -w|-a|--welcome-msg|--admin-notify) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--regular-members-file --digest-members-file @@ -28,4 +28,4 @@ _add_members() } && complete -F _add_members add_members -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/alias b/completions/alias index 112dea3b..de2a57e8 100644 --- a/completions/alias +++ b/completions/alias @@ -10,11 +10,11 @@ _alias() COMPREPLY=( $( compgen -A alias -- "$cur" ) ) ;; *=) - COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | sed \ + COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | command sed \ -e 's|^alias '"$cur"'\(.*\)$|\1|' )" ) ;; esac } && complete -F _alias -o nospace alias -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ant b/completions/ant index dd3606dc..639cde97 100644 --- a/completions/ant +++ b/completions/ant @@ -1,38 +1,66 @@ # bash completion for ant and phing -*- shell-script -*- +_ant_parse_targets() +{ + local line basedir + + [[ $1 == */* ]] && basedir=${1%/*} || basedir=. + + # parse buildfile for targets + while read -rd '>' line; do + if [[ $line =~ \<(target|extension-point)[[:space:]].*name=[\"\']([^\"\']+) ]]; then + targets+=" ${BASH_REMATCH[2]}" + fi + done < $1 + + # parse imports + while read -rd '>' line; do + if [[ $line =~ \<import[[:space:]].*file=[\"\']([^\"\']+) ]]; then + local imported_buildfile + imported_buildfile="${basedir}/${BASH_REMATCH[1]}" + if [[ -f $imported_buildfile ]]; then + _ant_parse_targets $imported_buildfile + fi + fi + done < $1 +} + _ant() { local cur prev words cword _init_completion || return case $prev in + -h|-help|--h|--help|-projecthelp|-p|-version|-diagnostics) + return + ;; -buildfile|-file|-f) _filedir 'xml' - return 0 + return ;; -logfile|-l) _filedir - return 0 + return ;; -propertyfile) _filedir properties - return 0 + return ;; -nice) COMPREPLY=( $( compgen -W '{1..10}' -- "$cur" ) ) - return 0 + return ;; -lib) _filedir -d - return 0 + return ;; -logger|-listener|-inputhandler|-main|-find|-s) - return 0 + return ;; esac if [[ $cur == -D* ]]; then - return 0 + return elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) else @@ -45,15 +73,22 @@ _ant() break fi done - [[ ! -f $buildfile ]] && return 0 + if [[ $i -eq $cword ]]; then + for i in $ANT_ARGS; do + if [[ $prev == -@(?(build)file|f) ]]; then + buildfile=$i + break + fi + prev=$i + done + fi + [[ ! -f $buildfile ]] && return + + local targets + + # fill targets + _ant_parse_targets $buildfile - # parse buildfile for targets - local line targets - while read -rd '>' line; do - [[ $line =~ \ - \<(targe|extension-poin)t[[:space:]].*name=[\"\']([^\"\']+) ]] \ - && targets+=" ${BASH_REMATCH[2]}" - done < $buildfile COMPREPLY=( $( compgen -W '$targets' -- "$cur" ) ) fi } && @@ -61,4 +96,4 @@ complete -F _ant ant phing type complete-ant-cmd.pl &>/dev/null && \ complete -C complete-ant-cmd.pl -F _ant ant || : -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/apache2ctl b/completions/apache2ctl index f6fdeb30..74789744 100644 --- a/completions/apache2ctl +++ b/completions/apache2ctl @@ -6,11 +6,11 @@ _apache2ctl() _init_completion || return local APWORDS - APWORDS=$(apache2ctl 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | \ + APWORDS=$($1 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | \ tr "|" " ") COMPREPLY=( $( compgen -W "$APWORDS" -- "$cur" ) ) } && complete -F _apache2ctl apache2ctl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/appdata-validate b/completions/appdata-validate new file mode 100644 index 00000000..3285a3b3 --- /dev/null +++ b/completions/appdata-validate @@ -0,0 +1,32 @@ +# appdata-validate(1) completion -*- shell-script -*- + +_appdata_validate() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help|--version) + return + ;; + --output-format) + COMPREPLY=( $( compgen -W "$( $1 --help | + command sed -ne 's/--output-format.*\[\(.*\)\]/\1/' -e 's/|/ /gp' )" \ + -- "$cur" ) ) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir appdata.xml +} && +complete -F _appdata_validate appdata-validate + +# ex: filetype=sh diff --git a/completions/apt-build b/completions/apt-build index 3812b20d..0723bcc4 100644 --- a/completions/apt-build +++ b/completions/apt-build @@ -16,27 +16,23 @@ _apt_build() case $special in install|source|info) COMPREPLY=( $( apt-cache pkgnames "$cur" 2> /dev/null ) ) - return 0 ;; remove) COMPREPLY=( \ $( _xfunc dpkg _comp_dpkg_installed_packages "$cur" ) ) - return 0 - ;; - *) - return 0 ;; esac + return fi case $prev in - --patch|--build-dir|--repository-dir) - _filedir - return 0 - ;; - -h|--help) - return 0 - ;; + --patch|--build-dir|--repository-dir) + _filedir + return + ;; + -h|--help) + return + ;; esac if [[ "$cur" == -* ]]; then @@ -51,9 +47,7 @@ _apt_build() -- "$cur" ) ) fi - - return 0 } && complete -F _apt_build apt-build -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/apt-cache b/completions/apt-cache index 085a964d..bedae4e9 100644 --- a/completions/apt-cache +++ b/completions/apt-cache @@ -1,5 +1,20 @@ # Debian apt-cache(8) completion -*- shell-script -*- +# List APT binary packages +_apt_cache_packages() { + 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 +} + +# List APT source packages +_apt_cache_src_packages() { + compgen -W '$( _apt_cache_sources "$cur" )' -- "$cur" +} + _apt_cache() { local cur prev words cword @@ -19,34 +34,31 @@ _apt_cache() case $special in add) _filedir - return 0 ;; showsrc) - COMPREPLY=( $( apt-cache dumpavail | \ - command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) ) - return 0 + COMPREPLY=( $( _apt_cache_sources "$cur" ) ) ;; *) - COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" 2> /dev/null ) ) - return 0 + COMPREPLY=( $( _apt_cache_packages ) ) ;; esac + return fi case $prev in - -c|-p|-s|--config-file|--pkg-cache|--src-cache) - _filedir - return 0 - ;; - search) - if [[ "$cur" != -* ]]; then - return 0 - fi - ;; + -c|-p|-s|--config-file|--pkg-cache|--src-cache) + _filedir + return + ;; + search) + if [[ "$cur" != -* ]]; then + return + fi + ;; esac if [[ "$cur" == -* ]]; then @@ -64,9 +76,7 @@ _apt_cache() fi - - return 0 } && complete -F _apt_cache apt-cache -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/apt-get b/completions/apt-get index 8fe36f13..ce951050 100644 --- a/completions/apt-get +++ b/completions/apt-get @@ -23,33 +23,31 @@ _apt_get() # assume RPM based _xfunc rpm _rpm_installed_packages fi - return 0 ;; source) COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ 2> /dev/null ) $( apt-cache dumpavail | \ command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) ) - return 0 ;; *) COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ 2> /dev/null ) ) - return 0 ;; esac + return fi case $prev in -c|--config-file) - _filedir - return 0 - ;; + _filedir + return + ;; -t|--target-release|--default-release) - COMPREPLY=( $( apt-cache policy | \ - command grep "release.o=Debian,a=$cur" | \ - sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) ) - return 0 - ;; + COMPREPLY=( $( apt-cache policy | \ + command grep "release.o=Debian,a=$cur" | \ + command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) ) + return + ;; esac if [[ "$cur" == -* ]]; then @@ -68,8 +66,7 @@ _apt_get() changelog check clean autoclean autoremove' -- "$cur" ) ) fi - return 0 } && complete -F _apt_get apt-get -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/aptitude b/completions/aptitude index 3bcfa5cf..32c1dacf 100644 --- a/completions/aptitude +++ b/completions/aptitude @@ -9,7 +9,7 @@ _comp_dpkg_hold_packages() _comp_dpkg_hold_packages() { command grep -B 2 'hold' /var/lib/dpkg/status | \ - command grep "Package: $1" | cut -d\ -f2 + awk "/Package: $1/ { print \$2 }" } } @@ -26,7 +26,7 @@ _aptitude() local special i for (( i=0; i < ${#words[@]}-1; i++ )); do - if [[ ${words[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag|versions) ]]; then + if [[ ${words[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full|safe)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag|versions) ]]; then special=${words[i]} fi #exclude some mutually exclusive options @@ -35,39 +35,39 @@ _aptitude() done if [[ -n "$special" ]]; then - case $special in - install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade| \ - download|show|changelog|why|why-not|build-dep|add-user-tag| \ - remove-user-tag|versions) - COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) - return 0 - ;; - purge|remove|reinstall|forbid-version) - COMPREPLY=( \ - $( _xfunc dpkg _comp_dpkg_installed_packages "$cur" ) ) - return 0 - ;; - unhold) - COMPREPLY=( $( _comp_dpkg_hold_packages "$cur" ) ) - return 0 - ;; - esac + case $special in + 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 ) ) + return + ;; + purge|remove|reinstall|forbid-version) + COMPREPLY=( \ + $( _xfunc dpkg _comp_dpkg_installed_packages "$cur" ) ) + return + ;; + unhold) + COMPREPLY=( $( _comp_dpkg_hold_packages "$cur" ) ) + return + ;; + esac fi case $prev in # don't complete anything if these options are found - autoclean|clean|forget-new|search|safe-upgrade|upgrade|update|keep-all) - return 0 + autoclean|clean|forget-new|search|upgrade|update|keep-all) + return ;; -S) _filedir - return 0 + return ;; -t|--target-release|--default-release) COMPREPLY=( $( apt-cache policy | \ command grep "release.o=Debian,a=$cur" | \ - sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) ) - return 0 + command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) ) + return ;; esac @@ -81,8 +81,7 @@ _aptitude() remove-user-tag versions' -- "$cur" ) ) fi - return 0 } && complete -F _aptitude -o default aptitude -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/arch b/completions/arch index 74e9adec..cd33b4f0 100644 --- a/completions/arch +++ b/completions/arch @@ -11,19 +11,18 @@ _arch() case $prev in -w|-g|-d|--welcome-msg|--goodbye-msg|--digest) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -d|--file) _filedir - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--wipe --start --end --quiet --help' \ - -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) else local args=$cword for (( i=1; i < cword; i++ )); do @@ -44,4 +43,4 @@ _arch() } && complete -F _arch arch -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/arping b/completions/arping index 231a63be..a719e916 100644 --- a/completions/arping +++ b/completions/arping @@ -28,4 +28,4 @@ _arping() } && complete -F _arping arping -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/arpspoof b/completions/arpspoof index cf9c497a..7b515edb 100644 --- a/completions/arpspoof +++ b/completions/arpspoof @@ -8,11 +8,11 @@ _arpspoof() case $prev in -i) _available_interfaces -a - return 0 + return ;; -t) _known_hosts_real "$cur" - return 0 + return ;; esac @@ -25,4 +25,4 @@ _arpspoof() } && complete -F _arpspoof arpspoof -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/asciidoc b/completions/asciidoc index 722614f6..fb29fad4 100644 --- a/completions/asciidoc +++ b/completions/asciidoc @@ -49,4 +49,4 @@ _asciidoc() } && complete -F _asciidoc asciidoc asciidoc.py -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/aspell b/completions/aspell index b1cd4c5d..9457a5fa 100644 --- a/completions/aspell +++ b/completions/aspell @@ -2,15 +2,15 @@ _aspell_dictionary() { - local datadir - datadir=$( aspell config data-dir 2>/dev/null || echo /usr/lib/aspell ) + local datadir aspell=${1:-aspell} + datadir=$( $aspell config data-dir 2>/dev/null || echo /usr/lib/aspell ) # First, get aliases (dicts dump does not list them) - COMPREPLY=( $( command ls $datadir/*.alias 2>/dev/null ) ) - COMPREPLY=( ${COMPREPLY[@]%.alias} ) - COMPREPLY=( ${COMPREPLY[@]#$datadir/} ) + 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 -W '${COMPREPLY[@]}' -- "$cur" ) ) + COMPREPLY+=( $( $aspell dicts 2>/dev/null ) ) + COMPREPLY=( $( compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur" ) ) } _aspell() @@ -21,42 +21,42 @@ _aspell() case $prev in -c|-p|check|--conf|--personal|--repl|--per-conf) _filedir - return 0 + return ;; --conf-dir|--data-dir|--dict-dir|--home-dir|--local-data-dir|--prefix) _filedir -d - return 0 + return ;; dump|create|merge) COMPREPLY=( $( compgen -W 'master personal repl' -- "$cur" ) ) - return 0 + return ;; --mode) COMPREPLY=( $( compgen -W "$( $1 modes 2>/dev/null | \ awk '{ print $1 }' )" -- "$cur" ) ) - return 0 + return ;; --sug-mode) COMPREPLY=( $( compgen -W 'ultra fast normal bad-speller' \ -- "$cur" ) ) - return 0 + return ;; --keymapping) COMPREPLY=( $( compgen -W 'aspell ispell' -- "$cur" ) ) - return 0 + return ;; -d|--master) - _aspell_dictionary - return 0 + _aspell_dictionary "$1" + return ;; --add-filter|--rem-filter) COMPREPLY=( $( compgen -W "$( $1 filters 2>/dev/null | \ awk '{ print $1 }' )" -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= @@ -85,4 +85,4 @@ _aspell() } && complete -F _aspell aspell -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/autoconf b/completions/autoconf index fea524e7..c67f1bdb 100644 --- a/completions/autoconf +++ b/completions/autoconf @@ -7,25 +7,25 @@ _autoconf() case "$prev" in --help|-h|--version|-V|--trace|-t) - return 0 + return ;; --output|-o) _filedir - return 0 + return ;; --warnings|-W) local cats=( cross obsolete syntax ) COMPREPLY=( $( compgen -W \ '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) ) - return 0 + return ;; --prepend-include|-B|--include|-I) _filedir -d - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -37,4 +37,4 @@ _autoconf() } && complete -F _autoconf autoconf -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/automake b/completions/automake index 78bc6db2..c5fe1a10 100644 --- a/completions/automake +++ b/completions/automake @@ -7,21 +7,21 @@ _automake() case "$prev" in --help|--version) - return 0 + return ;; --warnings|-W) local cats=( gnu obsolete override portability syntax unsupported ) COMPREPLY=( $( compgen -W \ '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) ) - return 0 + return ;; --libdir) _filedir -d - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -31,6 +31,6 @@ _automake() _filedir } && -complete -F _automake automake automake-1.11 +complete -F _automake automake automake-1.1{0..5} -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/autoreconf b/completions/autoreconf index 8de40c88..c067cec1 100644 --- a/completions/autoreconf +++ b/completions/autoreconf @@ -7,27 +7,27 @@ _autoreconf() case "$prev" in --help|-h|--version|-V) - return 0 + return ;; --warnings|-W) local cats=( cross gnu obsolete override portability syntax \ unsupported ) COMPREPLY=( $( compgen -W \ '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) ) - return 0 + return ;; --prepend-include|-B|--include|-I) _filedir -d - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi if [[ $1 == autoheader ]] ; then @@ -38,4 +38,4 @@ _autoreconf() } && complete -F _autoreconf autoreconf autoheader -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/autorpm b/completions/autorpm index 616ad8b6..8c6e299a 100644 --- a/completions/autorpm +++ b/completions/autorpm @@ -11,4 +11,4 @@ _autorpm() } && complete -F _autorpm autorpm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/autoscan b/completions/autoscan index 80b051cf..054a58af 100644 --- a/completions/autoscan +++ b/completions/autoscan @@ -7,20 +7,20 @@ _autoscan() case "$prev" in --help|-h|--version|-V) - return 0 + return ;; --prepend-include|-B|--include|-I) _filedir -d - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi if [[ $1 == autoupdate ]] ; then @@ -31,4 +31,4 @@ _autoscan() } && complete -F _autoscan autoscan autoupdate -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/avctrl b/completions/avctrl index bac38cd6..acd9aeb7 100644 --- a/completions/avctrl +++ b/completions/avctrl @@ -17,4 +17,4 @@ _avctrl() } && complete -F _avctrl avctrl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/badblocks b/completions/badblocks index 2dc8eb43..d70affe2 100644 --- a/completions/badblocks +++ b/completions/badblocks @@ -7,11 +7,11 @@ _badblocks() case $prev in -b|-c|-e|-d|-p|-t) - return 0 + return ;; -i|-o) _filedir - return 0 + return ;; esac @@ -19,9 +19,9 @@ _badblocks() COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) # Filter out -w (dangerous) and -X (internal use) for i in ${!COMPREPLY[@]}; do - [[ ${COMPREPLY[i]} == -[wX] ]] && unset COMPREPLY[i] + [[ ${COMPREPLY[i]} == -[wX] ]] && unset 'COMPREPLY[i]' done - return 0 + return fi cur=${cur:=/dev/} @@ -29,4 +29,4 @@ _badblocks() } && complete -F _badblocks badblocks -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/bind b/completions/bind new file mode 100644 index 00000000..ec5d0b81 --- /dev/null +++ b/completions/bind @@ -0,0 +1,36 @@ +# bash bind completion -*- shell-script -*- + +_bind() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -l|-p|-P|-s|-S|-v|-V|-r|-x|-X) + return + ;; + -m) + COMPREPLY=( $( compgen -W "emacs emacs-standard emacs-meta + emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur" ) ) + return + ;; + -f) + _filedir + return + ;; + -q|-u) + COMPREPLY=( $( compgen -W '$( "$1" -l )' -- "$cur" ) ) + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + return + fi + + COMPREPLY=( $( compgen -A binding -- "$cur" ) ) +} && +complete -F _bind bind + +# ex: filetype=sh diff --git a/completions/bk b/completions/bk index 8be6fb76..334e25b4 100644 --- a/completions/bk +++ b/completions/bk @@ -7,13 +7,12 @@ _bk() _init_completion || return local BKCMDS="$( bk help topics 2>/dev/null | \ - awk '/^ bk/ { print $4 }' | xargs printf '%s ' )" + awk '/^ bk/ { print $2 }' | xargs printf '%s ' )" COMPREPLY=( $( compgen -W "$BKCMDS" -- "$cur" ) ) _filedir - return 0 } && complete -F _bk bk -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/brctl b/completions/brctl index 27207158..01370654 100644 --- a/completions/brctl +++ b/completions/brctl @@ -18,7 +18,7 @@ _brctl() show) ;; *) - COMPREPLY=( $( compgen -W "$(brctl show | \ + COMPREPLY=( $( compgen -W "$($1 show | \ awk 'NR>1 {print $1}' )" -- "$cur" ) ) esac ;; @@ -36,4 +36,4 @@ _brctl() } && complete -F _brctl -o default brctl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/btdownloadheadless.py b/completions/btdownloadheadless.py index dc9789a9..f0b74615 100644 --- a/completions/btdownloadheadless.py +++ b/completions/btdownloadheadless.py @@ -8,11 +8,11 @@ _btdownload() case $prev in --responsefile|--saveas) _filedir - return 0 + return ;; esac - if [[ "$cur" == -* ]]; then + if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--max_uploads --keepalive_interval --download_slice_size --request_backlog --max_message_length --ip --minport --maxport --responsefile --url --saveas --timeout @@ -29,4 +29,4 @@ _btdownload() complete -F _btdownload btdownloadheadless.py btdownloadcurses.py \ btdownloadgui.py -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/bts b/completions/bts new file mode 100644 index 00000000..ba33fd66 --- /dev/null +++ b/completions/bts @@ -0,0 +1,115 @@ +# bts completion -*- shell-script -*- + +# 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" \ + -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" )' \ + -- "$ppn" +} + + +_bts() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + show|bugs) + 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: + severity: status: tag: owner: correspondent: affects: bugs: + users: archive:' -- "$cur" ) ) + return + ;; + status) + COMPREPLY=( $( compgen -W 'file: fields: verbose' -- "$cur" ) + $( _cached_bugs ) ) + return + ;; + block|unblock) + COMPREPLY=( $( compgen -W 'by with' -- "$cur" ) ) + return + ;; + severity) + 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" ) ) + return + ;; + 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 ) ) + return + ;; + package) + 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" ) ) + return + ;; + cleancache) + COMPREPLY=( $( _xfunc apt-cache _apt_cache_packages ) + $( _src_packages_with_prefix ) + $( compgen -W 'from: tag: usertag: ALL' -- "$cur" ) ) + return + ;; + user) + # non-predicible arguments + COMPREPLY=( ) + return + ;; + :) + # Chances are that "src:<src_package>" is being completed + # COMP_WORDS would be: "bts cleancache src : <partial_pkg_name>" + pos=$((COMP_CWORD - 2)) + if [[ $pos -gt 0 && "${COMP_WORDS[$pos]}" == "src" ]]; then + COMPREPLY=( $( _xfunc apt-cache _apt_cache_src_packages ) ) + return + fi + ;; + esac + + $split && return + + 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 + --smtp-helo --bts-server --force-refresh --no-force-refresh + --only-new --include-resolved --no-include-resolved --no-ack --ack + --interactive --force-interactive --no-interactive --quiet + --no-conf --noconf + show bugs select status clone done reopen archive unarchive retitle + summary submitter reassign found notfound fixed notfixed block unblock + 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" ) ) + +} && +complete -F _bts bts + +# ex: filetype=sh diff --git a/completions/bzip2 b/completions/bzip2 index 1bc98288..8362a595 100644 --- a/completions/bzip2 +++ b/completions/bzip2 @@ -7,11 +7,11 @@ _bzip2() case $prev in -b|-h|--help|-p) - return 0 + return ;; -n) COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) - return 0 + return ;; esac @@ -19,22 +19,20 @@ _bzip2() local helpopts=$( _parse_help "$1" ) COMPREPLY=( $( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ -- "$cur" ) ) - return 0 + return fi local IFS=$'\n' xspec="*.bz2" if [[ "$prev" == --* ]]; then - [[ "$prev" == --decompress || \ - "$prev" == --list || \ - "$prev" == --test ]] && xspec="!"$xspec + [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec [[ "$prev" == --compress ]] && xspec= elif [[ "$prev" == -* ]]; then [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec [[ "$prev" == -*z* ]] && xspec= fi - _expand || return 0 + _expand || return compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ @@ -42,4 +40,4 @@ _bzip2() } && complete -F _bzip2 bzip2 pbzip2 lbzip2 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cancel b/completions/cancel index 3e9a3781..2722d2a8 100644 --- a/completions/cancel +++ b/completions/cancel @@ -9,4 +9,4 @@ _cancel() } && complete -F _cancel cancel -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cardctl b/completions/cardctl index 5b5bb5d5..273d1a90 100644 --- a/completions/cardctl +++ b/completions/cardctl @@ -12,4 +12,4 @@ _cardctl() } && complete -F _cardctl cardctl pccardctl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ccache b/completions/ccache index 63f5a1c6..7184d74e 100644 --- a/completions/ccache +++ b/completions/ccache @@ -5,15 +5,27 @@ _ccache() local cur prev words cword split _init_completion -s || return - if [[ $COMP_CWORD -eq 1 && ${COMP_WORDS[COMP_CWORD]} != -* ]]; then - _command_offset 1 - return - fi + local i + for (( i=1; i <= COMP_CWORD; i++ )); do + if [[ ${COMP_WORDS[i]} != -* ]]; then + _command_offset $i + return + fi + [[ ${COMP_WORDS[i]} == -[oFM] ]] && ((i++)) + done case $prev in -h|--help|-V|--version|-F|--max-files|-M|--max-size) return ;; + -o|--set-config) + if [[ $cur != *=* ]]; then + COMPREPLY=( $( compgen -S = -W "$( $1 -p 2>/dev/null | \ + awk '$3 = "=" { print $2 }' )" -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + fi + return + ;; esac $split && return @@ -23,4 +35,4 @@ _ccache() } && complete -F _ccache ccache -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cfagent b/completions/cfagent index f3e227a4..fbf364ed 100644 --- a/completions/cfagent +++ b/completions/cfagent @@ -8,7 +8,7 @@ _cfagent() case $prev in -f|--file) _filedir - return 0 + return ;; esac @@ -18,4 +18,4 @@ _cfagent() } && complete -F _cfagent cfagent -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cfrun b/completions/cfrun index 7dd1beff..f4d1f265 100644 --- a/completions/cfrun +++ b/completions/cfrun @@ -17,7 +17,7 @@ _cfrun() case $prev in -f) _filedir - return 0 + return ;; esac @@ -31,7 +31,7 @@ _cfrun() break fi done - [[ ! -f $hostfile ]] && return 0 + [[ ! -f $hostfile ]] && return COMPREPLY=( $(compgen -W "$( command grep -v \ -E '(=|^$|^#)' $hostfile )" -- "$cur" ) ) @@ -44,4 +44,4 @@ _cfrun() } && complete -F _cfrun cfrun -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/chage b/completions/chage index 1842bb8a..9b11f169 100644 --- a/completions/chage +++ b/completions/chage @@ -8,19 +8,19 @@ _chage() case $prev in -d|--lastday|-E|--expiredate|-h|--help|-I|--inactive|-m|--mindays|\ -M|--maxdays|-W|--warndays) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _chage chage -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/change_pw b/completions/change_pw index abc7d6b1..b0f2061f 100644 --- a/completions/change_pw +++ b/completions/change_pw @@ -8,11 +8,11 @@ _change_pw() case $prev in -l|--listname) _xfunc list_lists _mailman_lists - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--all --domain --listname --password --quiet @@ -22,4 +22,4 @@ _change_pw() } && complete -F _change_pw change_pw -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/check_db b/completions/check_db index 651b375c..6f666173 100644 --- a/completions/check_db +++ b/completions/check_db @@ -14,4 +14,4 @@ _check_db() } && complete -F _check_db check_db -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/check_perms b/completions/check_perms index 472b9266..0fb05b11 100644 --- a/completions/check_perms +++ b/completions/check_perms @@ -12,4 +12,4 @@ _check_perms() } && complete -F _check_perms check_perms -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/checksec b/completions/checksec new file mode 100644 index 00000000..4e9fb601 --- /dev/null +++ b/completions/checksec @@ -0,0 +1,37 @@ +# bash completion for checksec -*- shell-script -*- + +_checksec() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --version|--help) + return + ;; + --file|--fortify-file) + _filedir + return + ;; + --dir) + _filedir -d + return + ;; + --proc) + _pnames + return + ;; + --proc-libs|--fortify-proc) + _pids + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi +} && +complete -F _checksec checksec + +# ex: filetype=sh diff --git a/completions/chgrp b/completions/chgrp index 26220d9e..986a77a6 100644 --- a/completions/chgrp +++ b/completions/chgrp @@ -9,10 +9,10 @@ _chgrp() if [[ "$prev" == --reference ]]; then _filedir - return 0 + return fi - $split && return 0 + $split && return # options completion if [[ "$cur" == -* ]]; then @@ -23,18 +23,17 @@ _chgrp() COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference --no-dereference --silent --quiet --reference --recursive --verbose --help --version $opts' -- "$cur" ) ) - return 0 + return fi # first parameter on line or first since an option? if [[ $cword -eq 1 && "$cur" != -* || "$prev" == -* ]]; then _allowed_groups "$cur" else - _filedir || return 0 + _filedir fi - return 0 } && complete -F _chgrp chgrp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/chkconfig b/completions/chkconfig index b1dd925e..8766b3a2 100644 --- a/completions/chkconfig +++ b/completions/chkconfig @@ -9,15 +9,15 @@ _chkconfig() --level=[1-6]|[1-6]|--list|--add|--del|--override) _services _xinetd_services - return 0 + return ;; --level) COMPREPLY=( $( compgen -W '{1..6}' -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--list --add --del --override --level' \ @@ -34,4 +34,4 @@ _chkconfig() } && complete -F _chkconfig chkconfig -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/chown b/completions/chown index 54d89fb8..c4479dd2 100644 --- a/completions/chown +++ b/completions/chown @@ -9,15 +9,15 @@ _chown() case "$prev" in --from) _usergroup - return 0 + return ;; --reference) _filedir - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then # Complete -options @@ -43,4 +43,4 @@ _chown() } && complete -F _chown chown -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/chpasswd b/completions/chpasswd index 499ec93b..93e74f8c 100644 --- a/completions/chpasswd +++ b/completions/chpasswd @@ -9,18 +9,18 @@ _chpasswd() -c|--crypt) COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \ -- "$cur" ) ) - return 0 + return ;; -s|--sha-rounds) - return 0 + return ;; esac - $split && return 0 + $split && return COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _chpasswd chpasswd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/chronyc b/completions/chronyc index 3544c753..ede6bb09 100644 --- a/completions/chronyc +++ b/completions/chronyc @@ -1,5 +1,16 @@ # chronyc(1) completion -*- shell-script -*- +_chronyc_command_args() +{ + local -a args=( $( compgen -W "$( $1 help 2>/dev/null | \ + awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }' )" ) ) + case $args in + \<address\>) _known_hosts_real "$cur" ;; + \<*) ;; + *) COMPREPLY+=( $( compgen -W '${args[@]}' -- "$cur" ) ) ;; + esac +} + _chronyc() { local cur prev words cword @@ -16,7 +27,7 @@ _chronyc() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_usage "$1" ) -6' -- "$cur" ) ) return fi @@ -24,40 +35,19 @@ _chronyc() for (( i=1; i < cword; i++ )); do [[ ${words[i]} != -* && ${words[i-1]} != @(-p|-h) ]] && (( args++ )) done - + case $args in 0) COMPREPLY=( $( compgen -W "$( $1 help 2>/dev/null | \ - awk 'NR > 1 { sub("\\|", " ", $1); print $1 }' )" -- "$cur" ) ) + awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }' )" \ + -- "$cur" ) ) ;; 1) - case $prev in - accheck|cmdaccheck|delete|maxdelay|maxdelayratio|\ - maxdelaydevratio|maxpoll|minpoll|minstratum|polltarget) - _known_hosts_real "$cur" - ;; - add) - COMPREPLY=( $( compgen -W 'peer server' -- "$cur" ) ) - ;; - allow|cmdallow|cmddeny|deny) - COMPREPLY=( $( compgen -W 'all' -- "$cur" ) ) - ;; - authhash) - COMPREPLY=( $( compgen -W 'MD5 SHA1' -- "$cur" ) ) - ;; - dns) - COMPREPLY=( $( compgen -W '-n +n -4 -6 -46' -- "$cur" ) ) - ;; - local) - COMPREPLY=( $( compgen -W 'off stratum' -- "$cur" ) ) - ;; - manual) - COMPREPLY=( $( compgen -W 'list on off reset' -- "$cur" ) ) - ;; - sources|sourcestats) - COMPREPLY=( $( compgen -W '-v' -- "$cur" ) ) - ;; - esac + _chronyc_command_args "$1" + if [[ ! $COMPREPLY && $prev == sources?(tats) ]]; then + # [-v] not handled by _chronyc_command_args yet + COMPREPLY=( $( compgen -W '-v' -- "$cur" ) ) + fi ;; 2) [[ $prev == @(peer|server) ]] && _known_hosts_real "$cur" @@ -66,4 +56,4 @@ _chronyc() } && complete -F _chronyc chronyc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/chrpath b/completions/chrpath index 29a71851..13e43ad0 100644 --- a/completions/chrpath +++ b/completions/chrpath @@ -24,4 +24,4 @@ _chrpath() } && complete -F _chrpath chrpath -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cksfv b/completions/cksfv index eabe3730..dd90816e 100644 --- a/completions/cksfv +++ b/completions/cksfv @@ -7,23 +7,23 @@ _cksfv() if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi case "$prev" in -C|-g) _filedir -d - return 0 + return ;; -f) _filedir 'sfv' - return 0 + return ;; esac _filedir - return 0 + } && complete -F _cksfv cksfv -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cleanarch b/completions/cleanarch index 7fb05299..edac34f8 100644 --- a/completions/cleanarch +++ b/completions/cleanarch @@ -13,4 +13,4 @@ _cleanarch() } && complete -F _cleanarch cleanarch -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/clisp b/completions/clisp index cdbf6bd2..23b04f04 100644 --- a/completions/clisp +++ b/completions/clisp @@ -16,8 +16,7 @@ _clisp() _filedir fi - return 0 } && complete -F _clisp -o default clisp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/clone_member b/completions/clone_member index 9dd55fe8..fe45e494 100644 --- a/completions/clone_member +++ b/completions/clone_member @@ -8,11 +8,11 @@ _clone_member() case $prev in -l|--listname) _xfunc list_lists _mailman_lists - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--listname --remove --admin --quiet @@ -22,4 +22,4 @@ _clone_member() } && complete -F _clone_member clone_member -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/complete b/completions/complete index bcac435d..5de2d168 100644 --- a/completions/complete +++ b/completions/complete @@ -9,7 +9,7 @@ _complete() -o) COMPREPLY=( $( compgen -W 'bashdefault default dirnames filenames nospace plusdirs' -- "$cur" ) ) - return 0 + return ;; -A) @@ -17,21 +17,21 @@ _complete() directory disabled enabled export file function group helptopic hostname job keyword running service setopt shopt signal stopped user variable' -- "$cur" ) ) - return 0 + return ;; -C) COMPREPLY=( $( compgen -A command -- "$cur" ) ) - return 0 + return ;; -F) COMPREPLY=( $( compgen -A function -- "$cur" ) ) - return 0 + return ;; -p|-r) - COMPREPLY=( $( complete -p | sed -e 's|.* ||' ) ) + COMPREPLY=( $( complete -p | command sed -e 's|.* ||' ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) - return 0 + return ;; esac @@ -47,4 +47,4 @@ _complete() } && complete -F _complete compgen complete -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/config_list b/completions/config_list index 68ab6cb7..653c628a 100644 --- a/completions/config_list +++ b/completions/config_list @@ -8,11 +8,11 @@ _config_list() case $prev in -i|-o|--inputfile|--outputfile) _filedir - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--inputfile --outputfile --checkonly @@ -24,4 +24,4 @@ _config_list() } && complete -F _config_list config_list -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/configure b/completions/configure index 2337c497..0e37726b 100644 --- a/completions/configure +++ b/completions/configure @@ -20,16 +20,16 @@ _configure() ;; esac - $split && return 0 + $split && return # if $COMP_CONFIGURE_HINTS is not null, then completions of the form # --option=SETTING will include 'SETTING' as a contextual hint - [[ "$cur" != -* ]] && return 0 + [[ "$cur" != -* ]] && return if [[ -n $COMP_CONFIGURE_HINTS ]]; then COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \ awk '/^ --[A-Za-z]/ { print $1; \ - if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \ + if ($2 ~ /--[A-Za-z]/) print $2 }' | command sed -e 's/[[,].*//g' )" \ -- "$cur" ) ) [[ $COMPREPLY == *=* ]] && compopt -o nospace else @@ -39,4 +39,4 @@ _configure() } && complete -F _configure configure -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/convert b/completions/convert index ffb320e2..59647d59 100644 --- a/completions/convert +++ b/completions/convert @@ -6,88 +6,88 @@ _ImageMagick() -channel) COMPREPLY=( $( compgen -W 'Red Green Blue Opacity Matte Cyan Magenta Yellow Black' -- "$cur" ) ) - return 0 + return ;; -colormap) COMPREPLY=( $( compgen -W 'shared private' -- "$cur" ) ) - return 0 + return ;; -colorspace) COMPREPLY=( $( compgen -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ YPbPr YUV CMYK' -- "$cur" ) ) - return 0 + return ;; -compose) COMPREPLY=( $( compgen -W 'Over In Out Atop Xor Plus Minus Add Subtract Difference Multiply Bumpmap Copy CopyRed CopyGreen CopyBlue CopyOpacity' -- "$cur" ) ) - return 0 + return ;; -compress) COMPREPLY=( $( compgen -W 'None BZip Fax Group4 JPEG Lossless LZW RLE Zip' -- "$cur" ) ) - return 0 + return ;; -dispose) COMPREPLY=( $( compgen -W 'Undefined None Background Previous' \ -- "$cur" ) ) - return 0 + return ;; -encoding) COMPREPLY=( $( compgen -W 'AdobeCustom AdobeExpert AdobeStandard AppleRoman BIG5 GB2312 Latin2 None SJIScode Symbol Unicode Wansung' -- "$cur" ) ) - return 0 + return ;; -endian) COMPREPLY=( $( compgen -W 'MSB LSB' -- "$cur" ) ) - return 0 + return ;; -filter) COMPREPLY=( $( compgen -W 'Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc' -- "$cur" ) ) - return 0 + return ;; -format) COMPREPLY=( $( compgen -W "$( convert -list format | awk \ '/ [r-][w-][+-] / { sub("[*]$","",$1); print tolower($1) }' )" \ -- "$cur" ) ) - return 0 + return ;; -gravity) COMPREPLY=( $( compgen -W 'Northwest North NorthEast West Center East SouthWest South SouthEast' -- "$cur" ) ) - return 0 + return ;; -intent) COMPREPLY=( $( compgen -W 'Absolute Perceptual Relative Saturation' -- "$cur" ) ) - return 0 + return ;; -interlace) COMPREPLY=( $( compgen -W 'None Line Plane Partition' -- "$cur" ) ) - return 0 + return ;; -limit) COMPREPLY=( $( compgen -W 'Disk File Map Memory' -- "$cur" ) ) - return 0 + return ;; -list) COMPREPLY=( $( compgen -W 'Delegate Format Magic Module Resource Type' -- "$cur" ) ) - return 0 + return ;; -map) COMPREPLY=( $( compgen -W 'best default gray red green blue' \ -- "$cur" ) ) _filedir - return 0 + return ;; -noise) COMPREPLY=( $( compgen -W 'Uniform Gaussian Multiplicative Impulse Laplacian Poisson' -- "$cur" ) ) - return 0 + return ;; -preview) COMPREPLY=( $( compgen -W 'Rotate Shear Roll Hue Saturation @@ -95,32 +95,32 @@ _ImageMagick() ReduceNoise AddNoise Sharpen Blur Treshold EdgeDetect Spread Shade Raise Segment Solarize Swirl Implode Wave OilPaint CharcoalDrawing JPEG' -- "$cur" ) ) - return 0 + return ;; -mask|-profile|-texture|-tile|-write) _filedir - return 0 + return ;; -type) COMPREPLY=( $( compgen -W 'Bilevel Grayscale Palette PaletteMatte TrueColor TrueColorMatte ColorSeparation ColorSeparationlMatte Optimize' -- "$cur" ) ) - return 0 + return ;; -units) COMPREPLY=( $( compgen -W 'Undefined PixelsPerInch PixelsPerCentimeter' -- "$cur" ) ) - return 0 + return ;; -virtual-pixel) COMPREPLY=( $( compgen -W 'Constant Edge mirror tile' -- "$cur" ) ) - return 0 + return ;; -visual) COMPREPLY=( $( compgen -W 'StaticGray GrayScale StaticColor PseudoColor TrueColor DirectColor defaut visualid' \ -- "$cur" ) ) - return 0 + return ;; esac @@ -321,4 +321,4 @@ _stream() } && complete -F _stream stream -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cowsay b/completions/cowsay index 8e96b91e..4f4411ac 100644 --- a/completions/cowsay +++ b/completions/cowsay @@ -9,7 +9,7 @@ _cowsay() -f) COMPREPLY=( $( compgen -W \ '$( cowsay -l 2>/dev/null | tail -n +2 )' -- "$cur" ) ) - return 0 + return ;; esac @@ -20,4 +20,4 @@ _cowsay() } && complete -F _cowsay -o default cowsay cowthink -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cpan2dist b/completions/cpan2dist index f6a67ac6..9704782d 100644 --- a/completions/cpan2dist +++ b/completions/cpan2dist @@ -11,11 +11,11 @@ _cpan2dist() COMPREPLY=( $( compgen -W '$(perl -MCPANPLUS::Dist -e \ "print map { \"\$_\n\" } CPANPLUS::Dist->dist_types")' \ -- "$cur" ) ) - return 0 + return ;; --banlist|--ignorelist|--modulelist|--logfile) _filedir - return 0 + return ;; esac @@ -29,9 +29,9 @@ _cpan2dist() packagelist="$dir/02packages.details.txt.gz" done [[ $packagelist ]] && COMPREPLY=( $( zgrep "^${cur//-/::}" \ - $packagelist 2>/dev/null | awk '{print $1}' | sed -e 's/::/-/g' ) ) + $packagelist 2>/dev/null | awk '{print $1}' | command sed -e 's/::/-/g' ) ) fi } && complete -F _cpan2dist -o default cpan2dist -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cpio b/completions/cpio index d63d15a9..36e3fe90 100644 --- a/completions/cpio +++ b/completions/cpio @@ -10,24 +10,24 @@ _cpio() -H|--format) COMPREPLY=( $( compgen -W \ 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur" ) ) - return 0 + return ;; -E|-F|-I|--file|--pattern-file) _filedir - return 0 + return ;; -R|--owner) _usergroup - return 0 + return ;; --rsh-command) compopt -o filenames COMPREPLY=( $( compgen -c -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through @@ -75,4 +75,4 @@ _cpio() } && complete -F _cpio cpio -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cppcheck b/completions/cppcheck index 64bb9b02..86990dd5 100644 --- a/completions/cppcheck +++ b/completions/cppcheck @@ -6,12 +6,13 @@ _cppcheck() _init_completion -s || return case $prev in - --append|--exitcode-suppressions|--file-list|--rule-file|\ + --append|--exitcode-suppressions|--rule-file|--config-excludes-file|\ --suppressions-list|--includes-file|--include|-i) _filedir return ;; - -D|-U|--rule|--suppress|--template|--max-configs) + -D|-U|--rule|--suppress|--template|--max-configs|-h|--help|--version|\ + --errorlist|--config-exclude|-l) return ;; --enable) @@ -22,8 +23,9 @@ _cppcheck() cur="${cur##*,}" split=true fi - COMPREPLY=( $( compgen -W 'all style performance portability - information unusedFunction missingInclude' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'all warning style performance + portability information unusedFunction missingInclude' \ + -- "$cur" ) ) $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) return ;; @@ -31,6 +33,11 @@ _cppcheck() COMPREPLY=( $( compgen -W '{0..255}' -- "$cur" ) ) return ;; + --file-list) + _filedir + [[ -z $cur || $cur == - ]] && COMPREPLY+=( - ) + return + ;; -I) _filedir -d return @@ -49,8 +56,9 @@ _cppcheck() return ;; --platform) - COMPREPLY=( $( compgen -W 'unix32 unix64 win32A win32W win64' \ - -- "$cur" ) ) + _filedir + COMPREPLY+=( $( compgen -W 'unix32 unix64 win32A win32W win64 + native' -- "$cur" ) ) return ;; -rp|--relative-paths) @@ -59,6 +67,10 @@ _cppcheck() return fi ;; + --library) + _filedir cfg + return + ;; --xml-version) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) return @@ -71,9 +83,9 @@ _cppcheck() COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace else - _filedir @(cpp|cxx|cc|c++|c|h|hpp|hxx|h++|tpp|txx) + _filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])' fi } && complete -F _cppcheck cppcheck -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/crontab b/completions/crontab index ddd0066c..bb8d0e24 100644 --- a/completions/crontab +++ b/completions/crontab @@ -8,7 +8,7 @@ _crontab() case $prev in -u) _allowed_users - return 0 + return ;; esac @@ -18,31 +18,31 @@ _crontab() local i for (( i=0; i < ${#words[@]}-1; i++ )); do - [[ ${words[i]} ]] && unset opts[${words[i]}] + [[ ${words[i]} ]] && unset "opts[${words[i]}]" case "${words[i]}" in -l) - unset opts[-r] opts[-e] opts[-i] opts[-s] + unset 'opts[-r]' 'opts[-e]' 'opts[-i]' 'opts[-s]' ;; -e) - unset opts[-l] opts[-r] opts[-i] + unset 'opts[-l]' 'opts[-r]' 'opts[-i]' ;; -r) - unset opts[-l] opts[-e] + unset 'opts[-l]' 'opts[-e]' ;; -u) - unset opts[-i] + unset 'opts[-i]' ;; esac done if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '${!opts[@]}' -- "$cur" ) ) - return 0 + return fi # do filenames only if we did not have -l, -r, or -e - [[ "${words[@]}" == *\ -@(l|r|e)* ]] || _filedir + [[ "${words[@]}" == *\ -[lre]* ]] || _filedir } && complete -F _crontab crontab -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cryptsetup b/completions/cryptsetup index a295a147..9411ad7a 100644 --- a/completions/cryptsetup +++ b/completions/cryptsetup @@ -20,7 +20,7 @@ _cryptsetup() case $prev in --key-file|--master-key-file|--header-backup-file|-d) _filedir - return 0 + return ;; esac @@ -99,8 +99,7 @@ _cryptsetup() esac fi - return 0 } && complete -F _cryptsetup cryptsetup -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/curl b/completions/curl index 6b56aa57..8251674c 100644 --- a/completions/curl +++ b/completions/curl @@ -92,4 +92,4 @@ _curl() } && complete -F _curl curl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cvs b/completions/cvs index 71277556..fee256f2 100644 --- a/completions/cvs +++ b/completions/cvs @@ -51,7 +51,7 @@ _cvs() _init_completion -n : || return local count mode i cvsroot cvsroots pwd - local -a flags miss files entries changed newremoved + local -a flags files entries changed newremoved count=0 for i in "${words[@]}"; do @@ -64,7 +64,7 @@ _cvs() case $i in -H|--help) COMPREPLY=( $( compgen -W "$( _cvs_commands )" -- "$cur" ) ) - return 0 + return ;; -d) mode=cvsroot @@ -131,7 +131,7 @@ _cvs() mode=version ;; esac - elif [[ "$i" = -* ]]; then + elif [[ "$i" == -* ]]; then flags+=( $i ) fi count=$((++count)) @@ -141,11 +141,11 @@ _cvs() add) case $prev in -m) - return 0 + return ;; -k) _cvs_kflags - return 0 + return ;; esac @@ -156,11 +156,11 @@ _cvs() local f for i in ${!files[@]}; do if [[ ${files[i]} == ?(*/)CVS ]]; then - unset files[i] + unset 'files[i]' else for f in "${entries[@]}"; do if [[ ${files[i]} == $f && ! -d $f ]]; then - unset files[i] + unset 'files[i]' break fi done @@ -175,19 +175,19 @@ _cvs() admin) case $prev in -a|-A|-b|-c|-e|-l|-m|-n|-N|-o|-s|-t-|-u) - return 0 + return ;; -t) _filedir - return 0 + return ;; -k) _cvs_kflags - return 0 + return ;; esac - if [[ "$cur" = -* ]]; then + if [[ "$cur" == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries @@ -195,9 +195,9 @@ _cvs() fi ;; annotate) - [[ "$prev" == -@(r|D) ]] && return 0 + [[ "$prev" == -[rD] ]] && return - if [[ "$cur" = -* ]]; then + if [[ "$cur" == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries @@ -206,16 +206,16 @@ _cvs() ;; checkout) case $prev in - -r|-D|j) - return 0 + -r|-D|-j) + return ;; -d) _filedir -d - return 0 + return ;; -k) _cvs_kflags - return 0 + return ;; esac @@ -231,11 +231,11 @@ _cvs() commit) case $prev in -m|-r) - return 0 + return ;; -F) _filedir - return 0 + return ;; esac @@ -248,9 +248,9 @@ _cvs() # far, but other changes (something other than # changed/removed/new) may be missing changed=( $( cvs -q diff --brief 2>&1 | \ - sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) ) + command sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) ) newremoved=( $( cvs -q diff --brief 2>&1 | \ - sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) ) + command sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) ) COMPREPLY=( $( compgen -W '${changed[@]:-} \ ${newremoved[@]:-}' -- "$cur" ) ) else @@ -274,7 +274,7 @@ _cvs() fi ;; editors|watchers) - if [[ "$cur" = -* ]]; then + if [[ "$cur" == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries @@ -284,15 +284,15 @@ _cvs() export) case $prev in -r|-D) - return 0 + return ;; -d) _filedir -d - return 0 + return ;; -k) _cvs_kflags - return 0 + return ;; esac @@ -307,11 +307,11 @@ _cvs() import) case $prev in -I|-b|-m|-W) - return 0 + return ;; -k) _cvs_kflags - return 0 + return ;; esac @@ -334,11 +334,13 @@ _cvs() remove) if [[ "$cur" != -* ]]; then _cvs_entries - # find out what files are missing - for i in "${entries[@]}"; do - [[ ! -r $i ]] && miss+=( $i ) - done - COMPREPLY=( $( compgen -W '${miss[@]:-}' -- "$cur" ) ) + if [[ "$prev" != -f ]]; then + # find out what files are missing + for i in ${!entries[@]}; do + [[ -r "${entries[i]}" ]] && unset 'entries[i]' + done + fi + COMPREPLY=( $( compgen -W '${entries[@]:-}' -- "$cur" ) ) else _cvs_command_options "$1" $mode fi @@ -346,15 +348,15 @@ _cvs() update) case $prev in -r|-D|-j|-I|-W) - return 0 + return ;; -k) _cvs_kflags - return 0 + return ;; esac - if [[ "$cur" = -* ]]; then + if [[ "$cur" == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries @@ -365,14 +367,14 @@ _cvs() case $prev in -T) _filedir -d - return 0 + return ;; -e|-s) - return 0 + return ;; -z) COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) - return 0 + return ;; esac @@ -382,8 +384,7 @@ _cvs() ;; esac - return 0 } && complete -F _cvs cvs -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/cvsps b/completions/cvsps index 8b986f57..64dab54f 100644 --- a/completions/cvsps +++ b/completions/cvsps @@ -7,43 +7,43 @@ _cvsps() case $prev in -h|-z|-f|-d|-l|--diff-opts|--debuglvl) - return 0 + return ;; -s) - COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null | + COMPREPLY=( $( compgen -W "$( $1 2>/dev/null | awk '/^PatchSet:?[ \t]/ { print $2 }' )" -- "$cur" ) ) - return 0 + return ;; -a) - COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null | + COMPREPLY=( $( compgen -W "$( $1 2>/dev/null | awk '/^Author:[ \t]/ { print $2 }' )" -- "$cur" ) ) - return 0 + return ;; -b) - COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null | + COMPREPLY=( $( compgen -W "$( $1 2>/dev/null | awk '/^Branch:[ \t]/ { print $2 }' )" -- "$cur" ) ) - return 0 + return ;; -r) - COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null | + COMPREPLY=( $( compgen -W "$( $1 2>/dev/null | awk '/^Tag:[ \t]+[^(]/ { print $2 }' )" -- "$cur" ) ) - return 0 + return ;; -p) _filedir -d - return 0 + return ;; --test-log) _filedir - return 0 + return ;; -Z) COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) - return 0 + return ;; --root) _xfunc cvs _cvs_roots - return 0 + return ;; esac @@ -55,4 +55,4 @@ _cvsps() } && complete -F _cvsps cvsps -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dd b/completions/dd index 53132dcc..daaebbe1 100644 --- a/completions/dd +++ b/completions/dd @@ -9,22 +9,35 @@ _dd() if=*|of=*) cur=${cur#*=} _filedir - return 0 + return ;; conv=*) cur=${cur#*=} COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock lcase - notrunc ucase swab noerror sync' -- "$cur" ) ) - return 0 + ucase sparse swab sync excl nocreat notrunc noerror fdatasync + fsync' -- "$cur" ) ) + return + ;; + iflag=*|oflag=*) + cur=${cur#*=} + COMPREPLY=( $( compgen -W 'append direct directory dsync sync + fullblock nonblock noatime nocache noctty nofollow count_bytes + skip_bytes seek_bytes' -- "$cur" ) ) + return + ;; + status=*) + cur=${cur#*=} + COMPREPLY=( $( compgen -W 'none noxfer progress' -- "$cur" ) ) + return ;; esac - _expand || return 0 + _expand || return COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) \ - $( compgen -W 'bs cbs conv count ibs if obs of seek skip' \ - -S '=' -- "$cur" ) ) + $( compgen -W 'bs cbs conv count ibs if iflag obs of oflag + seek skip status' -S '=' -- "$cur" ) ) } && complete -F _dd -o nospace dd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/deja-dup b/completions/deja-dup new file mode 100644 index 00000000..a508bb1e --- /dev/null +++ b/completions/deja-dup @@ -0,0 +1,33 @@ +# bash completion for deja-dup(1) -*- shell-script -*- + +_deja_dup() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -'?'|--help|--help-*) + return + ;; + --restore) + _filedir + return + ;; + --restore-missing) + _filedir -d + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ + -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi +} && +complete -F _deja_dup deja-dup + +# ex: filetype=sh diff --git a/completions/desktop-file-validate b/completions/desktop-file-validate index faae6c37..93f21061 100644 --- a/completions/desktop-file-validate +++ b/completions/desktop-file-validate @@ -20,4 +20,4 @@ _desktop_file_validate() } && complete -F _desktop_file_validate desktop-file-validate -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dhclient b/completions/dhclient index 54d89d31..8b44f6c3 100644 --- a/completions/dhclient +++ b/completions/dhclient @@ -8,11 +8,11 @@ _dhclient() case $prev in -cf|-lf|-pf|-sf) _filedir - return 0 + return ;; -s) _known_hosts_real "$cur" - return 0 + return ;; esac @@ -25,4 +25,4 @@ _dhclient() } && complete -F _dhclient dhclient -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dict b/completions/dict index a2ecd9b1..ac7df3fc 100644 --- a/completions/dict +++ b/completions/dict @@ -2,8 +2,8 @@ _dictdata() { - dict $host $port $1 2>/dev/null | sed -ne \ - 's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p' + dict $host $port $1 2>/dev/null | command sed -ne \ + 's/^[[:blank:]]\{1,\}\([^[:blank:]]*\).*$/\1/p' } _dict() @@ -30,26 +30,22 @@ _dict() [[ -n $db ]] && host="-d $db" i=$((++i)) ;; - *) - ;; esac done - if [[ "$cur" = -* ]]; then + if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi case $prev in -d|--database|-i|-info) COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) ) - return 0 + return ;; -s|--strategy) COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) ) - return 0 - ;; - *) + return ;; esac @@ -68,4 +64,4 @@ _dict() } && complete -F _dict -o default dict rdict -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dnsspoof b/completions/dnsspoof index 2518af69..d6b7872b 100644 --- a/completions/dnsspoof +++ b/completions/dnsspoof @@ -8,11 +8,11 @@ _dnsspoof() case $prev in -i) _available_interfaces -a - return 0 + return ;; -f) _filedir - return 0 + return ;; esac @@ -23,4 +23,4 @@ _dnsspoof() } && complete -F _dnsspoof dnsspoof -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dot b/completions/dot index ef946e4b..bc3531bb 100644 --- a/completions/dot +++ b/completions/dot @@ -5,7 +5,7 @@ _dot() local cur prev words cword _init_completion -n := || return - [[ $prev == -@(V|\?) ]] && return + [[ $prev == -[V?] ]] && return case $cur in -G*|-N*|-E*|-l?*|-q?*|-s?*|-Ln*|-LU*|-LC*|-LT*) @@ -13,13 +13,13 @@ _dot() ;; -T*) local langs=( $( "$1" -TNON_EXISTENT 2>&1 | \ - sed -ne 's/.*one of://p' ) ) + command sed -ne 's/.*one of://p' ) ) COMPREPLY=( $( compgen -P -T -W '${langs[@]}' -- "${cur#-T}" ) ) return ;; -K*) local layouts=( $( "$1" -KNON_EXISTENT 2>&1 | \ - sed -ne 's/.*one of://p' ) ) + command sed -ne 's/.*one of://p' ) ) COMPREPLY=( $( compgen -P -K -W '${layouts[@]}' -- "${cur#-K}" ) ) return ;; @@ -34,7 +34,7 @@ _dot() 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 == -@(G|N|E|T|K|o|L[nUCT]) ]] && compopt -o nospace + [[ $COMPREPLY == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace return fi @@ -42,4 +42,4 @@ _dot() } && complete -F _dot dot -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dpkg b/completions/dpkg index d14e5e3e..725542a7 100644 --- a/completions/dpkg +++ b/completions/dpkg @@ -8,11 +8,11 @@ _comp_dpkg_installed_packages() } || { _comp_dpkg_installed_packages() { - command grep -A 1 "Package: $1" /var/lib/dpkg/status | \ + command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \ command grep -B 1 -Ee "ok installed|half-installed|unpacked| \ half-configured" \ -Ee "^Essential: yes" | \ - command grep "Package: $1" | cut -d\ -f2 + awk "/Package: $1/ { print \$2 }" 2>/dev/null } } @@ -24,11 +24,11 @@ _comp_dpkg_purgeable_packages() } || { _comp_dpkg_purgeable_packages() { - command grep -A 1 "Package: $1" /var/lib/dpkg/status | \ + command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \ command grep -B 1 -Ee "ok installed|half-installed|unpacked| \ half-configured|config-files" \ -Ee "^Essential: yes" | \ - command grep "Package: $1" | cut -d\ -f2 + awk "/Package: $1/ { print \$2 }" 2>/dev/null } } @@ -39,8 +39,6 @@ _dpkg() local cur prev words cword split _init_completion -s || return - _expand || return 0 - local i=$cword # find the last option flag @@ -55,28 +53,28 @@ _dpkg() -c|-i|-A|-I|-f|-e|-x|-X|-W|--install|--unpack|--record-avail| \ --contents|--info|--fsys-tarfile|--field|--control|--extract| \ --show) - _filedir '?(u)deb' - return 0 + _filedir '?(u|d)deb' + return ;; -b|--build) _filedir -d - return 0 + return ;; -s|-p|-l|--status|--print-avail|--list) COMPREPLY=( $( apt-cache pkgnames "$cur" 2>/dev/null ) ) - return 0 + return ;; -S|--search) _filedir - return 0 + return ;; -r|--remove) COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) ) - return 0 + return ;; -L|-P|--listfiles|--purge) COMPREPLY=( $( _comp_dpkg_purgeable_packages "$cur" ) ) - return 0 + return ;; esac @@ -98,25 +96,25 @@ _dpkg_reconfigure() case $prev in -f|--frontend) - opt=( $( printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/* ) ) - opt=( ${opt[@]##*/} ) - opt=( ${opt[@]%.pm} ) - COMPREPLY=( $( compgen -W '${opt[@]}' -- "$cur" ) ) - return 0 - ;; + opt=( $( printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/* ) ) + opt=( ${opt[@]##*/} ) + opt=( ${opt[@]%.pm} ) + COMPREPLY=( $( compgen -W '${opt[@]}' -- "$cur" ) ) + return + ;; -p|--priority) - COMPREPLY=( $( compgen -W 'low medium high critical' -- "$cur" ) ) - return 0 - ;; + COMPREPLY=( $( compgen -W 'low medium high critical' -- "$cur" ) ) + return + ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $(compgen -W '--frontend --priority --all --unseen-only - --help --showold --force --terse' -- "$cur" ) ) + --help --showold --force --terse' -- "$cur" ) ) else COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) ) fi } && complete -F _dpkg_reconfigure -o default dpkg-reconfigure -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dpkg-source b/completions/dpkg-source index 6cd9bde3..54403851 100644 --- a/completions/dpkg-source +++ b/completions/dpkg-source @@ -8,7 +8,7 @@ _dpkg_source() local options work i action packopts unpackopts fields packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sr -ss -sA -sK -sP \ - -sU -sR" + -sU -sR" unpackopts="-sp -sn -su" options="-x -b $packopts $unpackopts" fields="Format Source Version Binary Maintainer Uploader Architecture \ @@ -31,22 +31,19 @@ _dpkg_source() -x) _filedir -d _filedir 'dsc' - return 0 ;; *) COMPREPLY=( $( compgen -W "$unpackopts" -- "$cur" ) ) _filedir -d _filedir - return 0 ;; esac - return 0 + return ;; pack) case $prev in -b) _filedir -d - return 0 ;; -c|-l|-T|-i|-I) # -c: get controlfile @@ -57,19 +54,16 @@ _dpkg_source() # return directory names and file names _filedir -d _filedir - return 0 ;; -F) # -F: force change log format COMPREPLY=( $( command ls /usr/lib/dpkg/parsechangelog ) ) - return 0 ;; -V|-D) # -V: set a substitution variable # we don't know anything about possible variables or values # so we don't try to suggest any completion. COMPREPLY=() - return 0 ;; -D) # -D: override or add a .dsc field and value @@ -77,31 +71,28 @@ _dpkg_source() if [[ "$cur" == *=* ]]; then # $cur contains a "=" COMPREPLY=() - return 0 else COMPREPLY=( $( compgen -W "$fields" -- "$cur" ) ) - return 0 fi ;; -U) # -U: remove a field # Suggest possible fieldnames COMPREPLY=( $( compgen -W "$fields" -- "$cur" ) ) - return 0 ;; *) - COMPREPLY=( $( compgen -W "$packopts $unpackopts" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "$packopts $unpackopts" \ + -- "$cur" ) ) ;; esac - return 0 + return ;; *) COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) - return 0 + return ;; esac } && complete -F _dpkg_source dpkg-source -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dselect b/completions/dselect index ee3cb2a7..e5f148cb 100644 --- a/completions/dselect +++ b/completions/dselect @@ -8,11 +8,11 @@ _dselect() case $prev in --admindir) _filedir -d - return 0 + return ;; -D|-debug) _filedir - return 0 + return ;; esac @@ -24,8 +24,7 @@ _dselect() quit' -- "$cur" ) ) fi - return 0 } && complete -F _dselect dselect -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dsniff b/completions/dsniff index db9b02ac..165ab74b 100644 --- a/completions/dsniff +++ b/completions/dsniff @@ -8,11 +8,11 @@ _dsniff() case $prev in -r|-w|-f|-p) _filedir - return 0 + return ;; -i) _available_interfaces -a - return 0 + return ;; esac @@ -23,4 +23,4 @@ _dsniff() } && complete -F _dsniff dsniff -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dumpdb b/completions/dumpdb index f097f895..ced754f5 100644 --- a/completions/dumpdb +++ b/completions/dumpdb @@ -15,4 +15,4 @@ _dumpdb() } && complete -F _dumpdb dumpdb -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/dumpe2fs b/completions/dumpe2fs index 127b46fc..90f84791 100644 --- a/completions/dumpe2fs +++ b/completions/dumpe2fs @@ -7,17 +7,17 @@ _dumpe2fs() case $prev in -o|-V) - return 0 + return ;; -i) _filedir - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi cur=${cur:=/dev/} @@ -25,4 +25,4 @@ _dumpe2fs() } && complete -F _dumpe2fs dumpe2fs -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/e2freefrag b/completions/e2freefrag index 6a971156..bee4a169 100644 --- a/completions/e2freefrag +++ b/completions/e2freefrag @@ -7,13 +7,13 @@ _e2freefrag() case $prev in -c|-h) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" -h )' -- "$cur" ) ) - return 0 + return fi cur=${cur:=/dev/} @@ -21,4 +21,4 @@ _e2freefrag() } && complete -F _e2freefrag e2freefrag -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/e2label b/completions/e2label index 94bcc1c8..c145c3a0 100644 --- a/completions/e2label +++ b/completions/e2label @@ -12,4 +12,4 @@ _e2label() } && complete -F _e2label e2label -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/eog b/completions/eog index 6da35e15..d5621119 100644 --- a/completions/eog +++ b/completions/eog @@ -20,8 +20,8 @@ _eog() return fi - _filedir '@(ani|?(w)bmp|gif|ico|j2k|jp[cefgx2]|jpeg|pcx|pn[gm]|ras|svg?(z)|tga|tif?(f)|x[bp]m)' + _filedir '@(ani|?(w)bmp|gif|ico|j2[ck]|jp[cefgx2]|jpeg|jpg2|pcx|p[gp]m|pn[gm]|ras|svg?(z)|tga|tif?(f)|x[bp]m)' } && complete -F _eog eog -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ether-wake b/completions/ether-wake index 4957e055..387b2d64 100644 --- a/completions/ether-wake +++ b/completions/ether-wake @@ -8,20 +8,20 @@ _ether_wake() case $prev in -i) _available_interfaces -a - return 0 + return ;; -p) - return 0 + return ;; esac if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" -u ) -V' -- "$cur" ) ) - return 0 + return fi _mac_addresses } && complete -F _ether_wake ether-wake -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/evince b/completions/evince index 8ef75160..eb6c7305 100644 --- a/completions/evince +++ b/completions/evince @@ -17,7 +17,7 @@ _evince() ;; esac - $split && return 0 + $split && return if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ @@ -30,4 +30,4 @@ _evince() } && complete -F _evince evince -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/explodepkg b/completions/explodepkg index b6914750..a281f81e 100644 --- a/completions/explodepkg +++ b/completions/explodepkg @@ -2,4 +2,4 @@ complete -o plusdirs -f -X '!*.t[bglx]z' explodepkg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/export b/completions/export index 42273a9e..31715f9a 100644 --- a/completions/export +++ b/completions/export @@ -24,7 +24,12 @@ _export() break done - [[ $cur == *=\$* ]] && { cur=${cur#*=}; _variables; } && return + if [[ $cur == *=* ]]; then + local ocur=$cur oprev=$prev + prev=${cur%%=*} cur=${cur#*=} + _variables && return + cur=$ocur prev=$oprev + fi case $cur in *=) @@ -58,4 +63,4 @@ _export() } && complete -F _export export -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/faillog b/completions/faillog index 77ca9c72..3b4a23d0 100644 --- a/completions/faillog +++ b/completions/faillog @@ -7,22 +7,21 @@ _faillog() case $prev in -h|--help|-l|--lock-time|-m|--maximum|-t|--time) - return 0 + return ;; -u|--user) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 fi } && complete -F _faillog faillog -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/fbgs b/completions/fbgs index 8058e01a..c58a7af9 100644 --- a/completions/fbgs +++ b/completions/fbgs @@ -12,7 +12,7 @@ _fbgs() return ;; -m|--mode) - COMPREPLY=( $( compgen -W '$( sed \ + COMPREPLY=( $( compgen -W '$( command sed \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ /etc/fb.modes 2> /dev/null )' -- "$cur" ) ) return @@ -44,6 +44,7 @@ _fbgs() fi _filedir '?(e)ps|pdf' -} && complete -F _fbgs fbgs +} && +complete -F _fbgs fbgs -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/fbi b/completions/fbi index 5073607a..75b46b61 100644 --- a/completions/fbi +++ b/completions/fbi @@ -20,7 +20,7 @@ _fbi() return ;; -m|--mode) - COMPREPLY=( $( compgen -W '$( sed \ + COMPREPLY=( $( compgen -W '$( command sed \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ /etc/fb.modes 2> /dev/null )' -- "$cur" ) ) return @@ -48,6 +48,7 @@ _fbi() # FIXME: It is hard to determine correct supported extensions. # fbi can handle any format that imagemagick can plus some others _filedir 'bmp|gif|jp?(e)g|pcd|png|p[pgb]m|tif?(f)|webp|xpm|xwd|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf' -} && complete -F _fbi fbi +} && +complete -F _fbi fbi -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/feh b/completions/feh index e53ca2b1..1cd75420 100644 --- a/completions/feh +++ b/completions/feh @@ -52,8 +52,8 @@ _feh() return ;; -S|--sort) - COMPREPLY=( $( compgen -W 'name filename width height pixels size - format' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'name filename mtime width height + pixels size format' -- "$cur" ) ) return ;; -R|--reload|-H|--limit-height|-W|--limit-width|-E|--thumb-height|\ @@ -100,6 +100,7 @@ _feh() $split && return if [[ "$cur" == -* ]]; then + # Some versions of feh just output "See 'man feh'" for --help :( COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY ]] && return @@ -108,6 +109,7 @@ _feh() # FIXME: It is hard to determine correct supported extensions. # feh can handle any format that imagemagick can plus some others _filedir 'xpm|tif?(f)|png|p[npgba]m|iff|?(i)lbm|jp?(e)g|jfi?(f)|gif|bmp|arg?(b)|tga|xcf|ani|ico|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf' -} && complete -F _feh feh +} && +complete -F _feh feh -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/file b/completions/file index 172fd5e0..f3f6df88 100644 --- a/completions/file +++ b/completions/file @@ -29,4 +29,4 @@ _file() } && complete -F _file file -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/file-roller b/completions/file-roller index c05565d9..3c627585 100644 --- a/completions/file-roller +++ b/completions/file-roller @@ -5,7 +5,7 @@ _file_roller() local cur prev words cword split _init_completion -s || return - local exts='@(7z|ace|alz|ar|arj|[bglx]z|bz2|tb?(z)2|cab|cb[rz]|iso?(9660)|Z|t[abglx]z|cpio|deb|[ejrw]ar|exe|?(g)tar|gem|lh[az]|lzh|?(t)lrz|lzma|lzo|wim|swm|rpm|sit|zip|zoo)' + 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]|lzh|?(t)lrz|lzma|lzo|wim|swm|rpm|sit|zoo)' case $prev in -'?'|--help|--help-all|--help-gtk|--help-sm-client) @@ -16,6 +16,7 @@ _file_roller() return ;; -a|--add-to) + _filedir_xspec unzip _filedir "$exts" return ;; @@ -34,8 +35,9 @@ _file_roller() return fi + _filedir_xspec unzip _filedir "$exts" } && complete -F _file_roller file-roller -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/filefrag b/completions/filefrag index ee9d0d81..b4866dc0 100644 --- a/completions/filefrag +++ b/completions/filefrag @@ -7,11 +7,11 @@ _filefrag() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi _filedir } && complete -F _filefrag filefrag -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/filesnarf b/completions/filesnarf index dbadd434..0cdcfe27 100644 --- a/completions/filesnarf +++ b/completions/filesnarf @@ -8,7 +8,7 @@ _snarf() case $prev in -i) _available_interfaces -a - return 0 + return ;; esac @@ -19,4 +19,4 @@ _snarf() } && complete -F _snarf filesnarf mailsnarf msgsnarf -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/find b/completions/find index 1896fc22..39029345 100644 --- a/completions/find +++ b/completions/find @@ -10,70 +10,70 @@ _find() case $prev in -maxdepth|-mindepth) COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) ) - return 0 + return ;; -newer|-anewer|-cnewer|-fls|-fprint|-fprint0|-fprintf|-name|-iname|\ -lname|-ilname|-wholename|-iwholename|-samefile) _filedir - return 0 + return ;; -fstype) _fstypes [[ $OSTYPE == *bsd* ]] && \ COMPREPLY+=( $( compgen -W 'local rdonly' -- "$cur" ) ) - return 0 + return ;; -gid) _gids - return 0 + return ;; -group) COMPREPLY=( $( compgen -g -- "$cur" 2>/dev/null) ) - return 0 + return ;; -xtype|-type) COMPREPLY=( $( compgen -W 'b c d p f l s' -- "$cur" ) ) - return 0 + return ;; -uid) _uids - return 0 + return ;; -user) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; -exec|-execdir|-ok|-okdir) words=(words[0] "$cur") cword=1 _command - return 0 + return ;; -[acm]min|-[acm]time|-iname|-lname|-wholename|-iwholename|-lwholename|\ -ilwholename|-inum|-path|-ipath|-regex|-iregex|-links|-perm|-size|\ -used|-printf|-context) # do nothing, just wait for a parameter to be given - return 0 + return ;; -regextype) COMPREPLY=( $( compgen -W 'emacs posix-awk posix-basic posix-egrep posix-extended' -- "$cur" ) ) - return 0 + return ;; esac - _expand || return 0 + _expand || return local i exprfound=false # set exprfound to true if there is already an expression present for i in ${words[@]}; do - [[ "$i" = [-\(\),\!]* ]] && exprfound=true && break + [[ "$i" == [-\(\),\!]* ]] && exprfound=true && break done # handle case where first parameter is not a dash option if ! $exprfound && [[ "$cur" != [-\(\),\!]* ]]; then _filedir -d - return 0 + return fi # complete using basic options @@ -101,15 +101,14 @@ _find() for i in "${words[@]}"; do [[ $i && ${onlyonce[$i]} ]] || continue for j in ${!COMPREPLY[@]}; do - [[ ${COMPREPLY[j]} == $i ]] && unset COMPREPLY[j] + [[ ${COMPREPLY[j]} == $i ]] && unset 'COMPREPLY[j]' done done fi _filedir - return 0 } && complete -F _find find -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/find_member b/completions/find_member index b1fcaf62..df1a24f9 100644 --- a/completions/find_member +++ b/completions/find_member @@ -8,11 +8,11 @@ _find_member() case $prev in -l|-x|--listname|--exclude) _xfunc list_lists _mailman_lists - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--listname --exclude --owners --help' \ @@ -22,4 +22,4 @@ _find_member() } && complete -F _find_member find_member -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/flake8 b/completions/flake8 new file mode 100644 index 00000000..60ad9e2b --- /dev/null +++ b/completions/flake8 @@ -0,0 +1,35 @@ +# flake8 completion -*- shell-script -*- + +_flake8() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help|--version|--exclude|--filename|--select|--ignore|\ + --max-line-length|--max-complexity|--builtins) + return + ;; + --format) + COMPREPLY=( $( compgen -W 'default pylint' -- "$cur" ) ) + return + ;; + --config) + _filedir + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir py +} && +complete -F _flake8 flake8 + +# ex: filetype=sh diff --git a/completions/freebsd-update b/completions/freebsd-update new file mode 100644 index 00000000..6ee2438b --- /dev/null +++ b/completions/freebsd-update @@ -0,0 +1,29 @@ +# bash completion for FreeBSD update tool - freebsd-update -*- shell-script -*- + +[[ $OSTYPE == *freebsd* ]] || return 1 + +_freebsd_update() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -b|-d) + _filedir -d + return + ;; + -f) + _filedir + return + ;; + -k|-r|-s|-t) + return + ;; + esac + + COMPREPLY=( $(compgen -W "fetch cron upgrade install rollback IDS" -- \ + $cur) ) +} && +complete -F _freebsd_update freebsd-update + +# ex: filetype=sh diff --git a/completions/freeciv-gtk2 b/completions/freeciv-gtk2 index c818433d..246d4f20 100644 --- a/completions/freeciv-gtk2 +++ b/completions/freeciv-gtk2 @@ -8,15 +8,15 @@ _civclient() case $prev in -l|-S|-t|--log|--Sound|--tiles) _filedir - return 0 + return ;; -P|--Plugin) COMPREPLY=( $( compgen -W 'none esd sdl' -- "$cur" ) ) - return 0 + return ;; -s|--server) _known_hosts_real "$cur" - return 0 + return ;; esac @@ -27,4 +27,4 @@ _civclient() } && complete -F _civclient civclient freeciv-gtk2 freeciv-sdl freeciv-xaw -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/freeciv-server b/completions/freeciv-server index 7daa30ce..78f57afa 100644 --- a/completions/freeciv-server +++ b/completions/freeciv-server @@ -8,7 +8,7 @@ _civserver() case $prev in -f|-g|-l|-r|--file|--log|--gamelog|--read) _filedir - return 0 + return ;; esac @@ -19,4 +19,4 @@ _civserver() } && complete -F _civserver civserver freeciv-server -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/function b/completions/function index e8e4d751..fbcf10d2 100644 --- a/completions/function +++ b/completions/function @@ -6,17 +6,32 @@ _function() _init_completion || return if [[ $1 == @(declare|typeset) ]]; then - if [[ $prev == -f ]]; then - COMPREPLY=( $( compgen -A function -- "$cur" ) ) - elif [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + if [[ $cur == [-+]* ]]; then + local opts + 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" ) ) + else + local i=1 + while [[ ${words[i]} == [-+]* ]]; do + if [[ ${words[i]} == -*[fF]* ]]; then + 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" ) ) + fi fi elif [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -A function -- "$cur" ) ) else - COMPREPLY=( "() $( type -- ${words[1]} | sed -e 1,2d )" ) + COMPREPLY=( "() $( type -- ${words[1]} | command sed -e 1,2d )" ) fi } && complete -F _function function declare typeset -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/fusermount b/completions/fusermount index e711e791..23671bd6 100644 --- a/completions/fusermount +++ b/completions/fusermount @@ -7,13 +7,13 @@ _fusermount() case $prev in -h|-V|-o) - return 0 + return ;; -u) COMPREPLY=( $( compgen -W "$( awk \ '{ if ($3 ~ /^fuse(\.|$)/) print $2 }' /etc/mtab \ 2>/dev/null )" -- "$cur" ) ) - return 0 + return ;; esac @@ -25,4 +25,4 @@ _fusermount() } && complete -F _fusermount fusermount -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gcc b/completions/gcc index c86fd7e6..174e0718 100644 --- a/completions/gcc +++ b/completions/gcc @@ -13,7 +13,7 @@ _gcc() local cur prev words cword _init_completion || return - _expand || return 0 + _expand || return local cc backend @@ -27,6 +27,9 @@ _gcc() *77) backend=f771 ;; + *95) + backend=f951 + ;; *) backend=cc1 # (near-)universal backend ;; @@ -39,16 +42,26 @@ _gcc() # for C/C++/ObjectiveC it's useless # for FORTRAN/Java it's an error COMPREPLY=( $( compgen -W "$( $cc --help 2>/dev/null | tr '\t' ' ' |\ - sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/' )" -- "$cur" ) ) + command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/' )" -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _filedir fi } && -complete -F _gcc gcc g++ g77 gcj gpc && +complete -F _gcc gcc g++ gfortran g77 g95 gcj gpc && { - cc --version 2>/dev/null | grep -q GCC && complete -F _gcc cc || : - c++ --version 2>/dev/null | grep -q GCC && complete -F _gcc c++ || : + cc --version 2>/dev/null | command grep -q GCC || \ + [[ $( _realcommand cc ) == *gcc* ]] && \ + complete -F _gcc cc || complete -F _minimal cc + c++ --version 2>/dev/null | command grep -q GCC || \ + [[ $( _realcommand c++ ) == *g++* ]] && \ + complete -F _gcc c++ || complete -F _minimal c++ + f77 --version 2>/dev/null | command grep -q GCC || \ + [[ $( _realcommand f77 ) == *gfortran* ]] && \ + complete -F _gcc f77 || complete -F _minimal f77 + f95 --version 2>/dev/null | command grep -q GCC || \ + [[ $( _realcommand f95 ) == *gfortran* ]] && \ + complete -F _gcc f95 || complete -F _minimal f95 } -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gcl b/completions/gcl index 385a2e06..5d1ca5f3 100644 --- a/completions/gcl +++ b/completions/gcl @@ -15,8 +15,7 @@ _gcl() _filedir fi - return 0 } && complete -F _gcl -o default gcl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gdb b/completions/gdb index 125d0b15..75414782 100644 --- a/completions/gdb +++ b/completions/gdb @@ -2,9 +2,18 @@ _gdb() { - local cur prev words cword + local cur prev words cword i _init_completion || return + # gdb [options] --args executable-file [inferior-arguments ...] + for (( i=1; i < cword; i++ )); do + if [[ "${words[i]}" == --args ]]; then + _command_offset $((i+1)) + return $? + fi + done + + # gdb [options] [executable-file [core-file or process-id]] if [[ $cword -eq 1 ]]; then local IFS compopt -o filenames @@ -18,7 +27,7 @@ _gdb() # names manually. IFS=":" local path_array=( $( \ - sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" ) ) + command sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" ) ) IFS=$'\n' COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \ -mindepth 1 -maxdepth 1 -not -type d -executable \ @@ -34,4 +43,4 @@ _gdb() } && complete -F _gdb gdb -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/genaliases b/completions/genaliases index 32f5919a..f9a9890a 100644 --- a/completions/genaliases +++ b/completions/genaliases @@ -12,4 +12,4 @@ _genaliases() } && complete -F _genaliases genaliases -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gendiff b/completions/gendiff index 38c0828e..cb9bab39 100644 --- a/completions/gendiff +++ b/completions/gendiff @@ -3,10 +3,10 @@ _gendiff() { local cur prev words cword - _init_completion -o @(diff|patch) || return + _init_completion -o '@(diff|patch)' || return [[ $cword -eq 1 ]] && _filedir -d } && complete -F _gendiff gendiff -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/genisoimage b/completions/genisoimage index 1d8f0401..caf6d457 100644 --- a/completions/genisoimage +++ b/completions/genisoimage @@ -9,20 +9,20 @@ _mkisofs() -o|-abstract|-biblio|-check-session|-copyright|-log-file| \ -root-info|-prep-boot|-*-list) _filedir - return 0 + return ;; -*-charset) COMPREPLY=( $( compgen -W '$( mkisofs -input-charset \ help 2>&1 | tail -n +3 )' -- "$cur" ) ) - return 0 + return ;; -uid) _uids - return 0 + return ;; -gid) _gids - return 0 + return ;; esac @@ -35,4 +35,4 @@ _mkisofs() } && complete -F _mkisofs mkisofs genisoimage -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/getent b/completions/getent index 2e99f524..0658b0bb 100644 --- a/completions/getent +++ b/completions/getent @@ -26,30 +26,30 @@ _getent() case $db in passwd) - COMPREPLY=( $( compgen -u "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -u -- "$cur" ) ) + return ;; group) - COMPREPLY=( $( compgen -g "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -g -- "$cur" ) ) + return ;; services) - COMPREPLY=( $( compgen -s "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -s -- "$cur" ) ) + return ;; hosts) - COMPREPLY=( $( compgen -A hostname "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -A hostname -- "$cur" ) ) + return ;; protocols|networks|ahosts|ahostsv4|ahostsv6|rpc) - COMPREPLY=( $( compgen -W "$( getent $db | \ + COMPREPLY=( $( compgen -W "$( $1 $db | \ awk '{ print $1 }' )" -- "$cur" ) ) - return 0 + return ;; aliases|shadow|gshadow) - COMPREPLY=( $( compgen -W "$( getent $db | cut -d: -f1 )" \ + COMPREPLY=( $( compgen -W "$( $1 $db | cut -d: -f1 )" \ -- "$cur" ) ) - return 0 + return ;; ethers|netgroup) return @@ -75,4 +75,4 @@ _getent() } && complete -F _getent getent -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gkrellm b/completions/gkrellm index db439ebd..cfe65429 100644 --- a/completions/gkrellm +++ b/completions/gkrellm @@ -8,27 +8,27 @@ _gkrellm() case $prev in -t|--theme) _filedir -d - return 0 + return ;; -p|--plugin) _filedir so - return 0 + return ;; -s|--server) _known_hosts_real "$cur" - return 0 + return ;; -l|--logfile) _filedir - return 0 + return ;; -g|--geometry|-c|--config|-P|--port|-d|--debug-level) # Argument required but no completions available - return 0 + return ;; -h|--help|-v|--version) # All other options are noop with these - return 0 + return ;; esac @@ -36,4 +36,4 @@ _gkrellm() } && complete -F _gkrellm gkrellm gkrellm2 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gm b/completions/gm new file mode 100644 index 00000000..88c233c6 --- /dev/null +++ b/completions/gm @@ -0,0 +1,40 @@ +# bash completion for gm(1) -*- shell-script -*- + +_gm_commands() +{ + COMPREPLY+=( $( compgen -W '$( "$1" help | + awk "/^ +[^ ]+ +- / { print \$1 }" )' -- "$cur" ) ) +} + +_gm() +{ + local cur prev words cword + _init_completion || return + + if [[ $cword -eq 1 ]]; then + _gm_commands "$1" + return + elif [[ $cword -eq 2 && ${words[1]} == time ]]; then + _gm_commands "$1" + return + fi + + local gmcmd=${words[1]} + [[ $gmcmd == time ]] && gmcmd=${words[2]} + + case $gmcmd in + help) + [[ $prev == help ]] && _gm_commands "$1" + return + ;; + version) + return + ;; + esac + + # TODO... defer some commnds to the imagemagick "gm"less completions etc? + compopt -o default +} && +complete -F _gm gm + +# ex: filetype=sh diff --git a/completions/gnatmake b/completions/gnatmake index 458ad070..4cd24d2e 100644 --- a/completions/gnatmake +++ b/completions/gnatmake @@ -9,13 +9,13 @@ _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 - -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" ) ) + -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" ) ) else # source file completion _filedir '@(adb|ads)' @@ -23,4 +23,4 @@ _gnatmake() } && complete -F _gnatmake gnatmake -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gnokii b/completions/gnokii new file mode 100644 index 00000000..95ccaeae --- /dev/null +++ b/completions/gnokii @@ -0,0 +1,235 @@ +# gnokii(1) completion -*- shell-script -*- + +_gnokii_memory_type() +{ + # TODO: reduce the number of choices + COMPREPLY=( $( compgen -W "IN OU SM ME MT" -- "$cur" ) ) +} + +_gnokii() +{ + local cur prev words cword pprev tprev fprev + _init_completion || return + + case $prev in + --config) + _filedir + return + ;; + --phone) + local config_file + for config_file in "$XDG_CONFIG_HOME/gnokii/config" \ + "$HOME/.config/gnokii/config" "$HOME/.gnokiirc" \ + "$XDG_CONFIG_DIRS/gnokii/config" /etc/gnokiirc ; do + [[ -f $config_file ]] && break + done + [[ ! -f $config_file ]] && return + COMPREPLY=( $( compgen -W \ + "$( command sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file )" \ + -- "$cur" ) ) + return + ;; + --help) + COMPREPLY=( $( compgen -W 'all monitor sms mms phonebook calendar + todo dial profile settings wap logo ringtone security file + other' -- "$cur" ) ) + return + ;; + --version|--shell|ping) + return + ;; + + # MONITOR + --monitor) + COMPREPLY=( $( compgen -W 'delay once' -- "$cur" ) ) + return + ;; + --getdisplaystatus|--displayoutput) + return + ;; + --netmonitor) + COMPREPLY=( $( compgen -W 'reset off field devel next nr' \ + -- "$cur" ) ) + return + ;; + + # SMS + --sendsms) + # (how)TODO ? + return + ;; + --savesms) + COMPREPLY=( $( compgen -W '--sender --smsc --smscno --folder + --location --sent --read --deliver --datetime' -- "$cur" ) ) + return + ;; + --memory-type|--memory|--getsms|--deletesms|--getmms|--deletemms|\ + --getphonebook|--deletephonebook) + _gnokii_memory_type + return + ;; + --getsmsc|--getcalendarnote|--deletecalendarnote|--gettodo|\ + --getspeeddial) + # TODO: grab a specific entry ID + return + ;; + --setsmsc|--smsreader|--createsmsfolder|--deletealltodos|\ + --showsmsfolderstatus) + return + ;; + --deletesmsfolder|--folder) + # TODO: folderid + return + ;; + --writephonebook) + COMPREPLY=( $( compgen -W '--overwrite --find-free --memory-type + --location --vcard --ldif' -- "$cur" ) ) + return + ;; + --writecalendarnote|--writetodo) + _filedir vcf + return + ;; + + # DIAL + --setspeeddial|--dialvoice|--senddtmf|--answercall|--hangup) + # TODO + return + ;; + --divert) + COMPREPLY=( $( compgen -W '--op' -- "$cur" ) ) + return + ;; + + # PROFILE + --getprofile|--setactiveprofile) + # TODO + return + ;; + --setprofile|--getactiveprofile) + return + ;; + + # SETTINGS + --reset) + COMPREPLY=( $( compgen -W 'soft hard' -- "$cur" ) ) + return + ;; + --setdatetime|--setalarm) + # TODO + return + ;; + --getdatetime|--getalarm) + return + ;; + + # WAP + --getwapbookmark|--writewapbookmark|--deletewapbookmark|\ + --getwapsetting|--writewapsetting|--activatewapsetting) + return + ;; + + # LOGOS + --sendlogo) + COMPREPLY=( $( compgen -W 'caller op picture' -- "$cur" ) ) + return + ;; + --setlogo|--getlogo) + COMPREPLY=( $( compgen -W 'op startup caller dealer text' \ + -- "$cur" ) ) + return + ;; + --viewlogo) + # TODO: logofile + return + ;; + + --entersecuritycode) + COMPREPLY=( $( compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur" ) ) + return + ;; + + # TODO: RINGTONES + esac + + # second level completion + if [[ $((cword-2)) -ge 1 && ${words[cword-2]} =~ --* ]]; then + pprev=${words[cword-2]} + case $pprev in + --setspeeddial) + _gnokii_memory_type + return + ;; + --getsms|--deletesms|--getmms|--deletemms|--getphonebook|\ + --writetodo|--writecalendarnote) + # TODO: start number + return + ;; + --gettodo|--getcalendarnote) + COMPREPLY=( $( compgen -W '{1..9} end --vCal' -- "$cur" ) ) + return + ;; + --deletecalendarnote) + COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) ) + return + ;; + --divert) + COMPREPLY=( $( compgen -W 'register enable query disable + erasure' -- "$cur" ) ) + return + ;; + esac + fi + + # third level completion + if [[ $((cword-3)) -ge 1 && ${words[cword-3]} =~ --* ]]; then + tprev=${words[cword-3]} + case $tprev in + --deletesms|--deletemms) + COMPREPLY=( $( compgen -W 'end' -- "$cur" ) ) + return + ;; + --getphonebook|--writetodo|--writecalendarnote) + COMPREPLY=( $( compgen -W '{1..9} end' -- "$cur" ) ) + return + ;; + --gettodo|--getcalendarnote) + [[ ${words[cword-1]} == end ]] && \ + COMPREPLY=( $( compgen -W '--vCal' -- "$cur" ) ) + return + ;; + --divert) + COMPREPLY=( $( compgen -W '--type' -- "$cur" ) ) + return + esac + fi + + # fourth level completion + if [[ $((cword-4)) -ge 1 && ${words[cword-4]} =~ --* ]]; then + fprev=${words[cword-4]} + case $fprev in + --getphonebook) + COMPREPLY=( $( compgen -W '--raw --vcard --ldif' -- "$cur" ) ) + return + ;; + --divert) + 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" )" + # these 2 below are allowed in combination with others + 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 + + COMPREPLY=( $( compgen -W "$all_cmd" -- "$cur" ) ) +} && +complete -F _gnokii gnokii + +# ex: filetype=sh diff --git a/completions/gnome-mplayer b/completions/gnome-mplayer index 00701702..9a250419 100644 --- a/completions/gnome-mplayer +++ b/completions/gnome-mplayer @@ -36,4 +36,4 @@ _gnome_mplayer() } && complete -F _gnome_mplayer gnome-mplayer -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gpasswd b/completions/gpasswd index eb5a7e48..ada12b8d 100644 --- a/completions/gpasswd +++ b/completions/gpasswd @@ -8,18 +8,18 @@ _gpasswd() case $prev in -a|--add|-d|--delete|-A|--administrators|-M|--members) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then # TODO: only -A and -M can be combined COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi COMPREPLY=( $( compgen -g -- "$cur" ) ) } && complete -F _gpasswd gpasswd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gpg b/completions/gpg index 91436f7a..3fee3df3 100644 --- a/completions/gpg +++ b/completions/gpg @@ -8,31 +8,31 @@ _gpg() case $prev in -s|--sign|--clearsign|--decrypt-files|--load-extension) _filedir - return 0 + return ;; --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key) # return list of public keys - COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \ - sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p' \ - -ne 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | command sed -ne \ + 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ + 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) ) + return ;; -r|--recipient) - COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \ - sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ) ) + 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 "$( sed -ne \ + COMPREPLY+=( $( compgen -W "$( command sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ ~/.gnupg/gpg.conf )" -- "$cur" ) ) fi - return 0 + return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$(gpg --dump-options)' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$($1 --dump-options)' -- "$cur" ) ) fi } && complete -F _gpg -o default gpg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gpg2 b/completions/gpg2 index 3efc2dbb..66630590 100644 --- a/completions/gpg2 +++ b/completions/gpg2 @@ -8,35 +8,35 @@ _gpg2() case $prev in --homedir) _filedir -d - return 0 + return ;; -s|--sign|--clearsign|--options|--decrypt) _filedir - return 0 + return ;; --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key) # return list of public keys - COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \ - sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p' \ - -ne 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "$( $1 --list-keys 2>/dev/null | command sed -ne \ + 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ + 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) ) + return ;; -r|--recipient) - COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \ - sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ) ) + 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 "$( sed -ne \ + COMPREPLY+=( $( compgen -W "$( command sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ ~/.gnupg/gpg.conf)" -- "$cur" ) ) fi - return 0 + return ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$(gpg2 --dump-options)' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$($1 --dump-options)' -- "$cur" ) ) fi } && complete -F _gpg2 -o default gpg2 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gphoto2 b/completions/gphoto2 index 02ddf785..94bf0634 100644 --- a/completions/gphoto2 +++ b/completions/gphoto2 @@ -3,49 +3,52 @@ _gphoto2() { local cur prev words cword split - _init_completion -s || return + _init_completion -s -n : || return case $prev in --debug-logfile) _filedir - return 0 + return ;; --hook-script) _filedir - return 0 + return ;; --filename) _filedir - return 0 + return ;; -u|--upload-file) _filedir - return 0 + return ;; --port) - COMPREPLY=( $(compgen -W "$( gphoto2 --list-ports 2>/dev/null | \ - tail -n +4 | awk '{ print $1 }' )" -- "$cur") ) - return 0 + 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 "$( gphoto2 --list-cameras 2>/dev/null | \ - tail -n +3 | awk -F'"' '{ print $2 }' )" -- "$cur") ) - return 0 + 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 "$( gphoto2 --list-config 2>/dev/null \ + COMPREPLY=( $(compgen -W "$( $1 --list-config 2>/dev/null \ )" -- "$cur") ) - return 0 + return ;; esac + $split && return + if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && complete -F _gphoto2 gphoto2 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gprof b/completions/gprof index 810255a4..b9692bad 100644 --- a/completions/gprof +++ b/completions/gprof @@ -62,4 +62,4 @@ _gprof() } && complete -F _gprof gprof -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/groupadd b/completions/groupadd index db5ff872..c5a74b7a 100644 --- a/completions/groupadd +++ b/completions/groupadd @@ -10,18 +10,17 @@ _groupadd() case $prev in -g|--gid|-K|--key|-p|--password) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 fi } && complete -F _groupadd groupadd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/groupdel b/completions/groupdel index bf6e5c6a..91ba3583 100644 --- a/completions/groupdel +++ b/completions/groupdel @@ -2,4 +2,4 @@ complete -g groupdel -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/groupmems b/completions/groupmems index 9c993eb7..3bb5d820 100644 --- a/completions/groupmems +++ b/completions/groupmems @@ -8,15 +8,15 @@ _groupmems() case $prev in -a|--add|-d|--delete) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; -g|--group) COMPREPLY=( $( compgen -g -- "$cur" ) ) - return 0 + return ;; -R|--root) _filedir -d - return 0 + return ;; esac @@ -24,4 +24,4 @@ _groupmems() } && complete -F _groupmems groupmems -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/groupmod b/completions/groupmod index 1a0241a7..51e23b5c 100644 --- a/completions/groupmod +++ b/completions/groupmod @@ -10,20 +10,20 @@ _groupmod() case $prev in -g|--gid|-h|--help|-n|--new-name|-p|--password) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi COMPREPLY=( $( compgen -g -- "$cur" ) ) } && complete -F _groupmod groupmod -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/growisofs b/completions/growisofs index c4cb7162..04b29a55 100644 --- a/completions/growisofs +++ b/completions/growisofs @@ -7,19 +7,19 @@ _growisofs() case $prev in -version|-speed) - return 0 + return ;; -Z|-M) compopt -o nospace _dvd_devices - return 0 + return ;; /?(r)dev/*) if [[ $cur == =* ]] ; then # e.g. /dev/dvd=foo.iso, /dev/dvdrw=/dev/zero cur="${cur#=}" _filedir - return 0 + return fi ;; esac @@ -29,11 +29,11 @@ _growisofs() COMPREPLY=( $( compgen -W '-dvd-compat -overburn -speed= -Z -M' \ -- "$cur" ) ) [[ ${COMPREPLY[@]} == *= ]] && compopt -o nospace - return 0 + return fi _filedir } && complete -F _growisofs growisofs -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/grpck b/completions/grpck index 0aff1439..18a53920 100644 --- a/completions/grpck +++ b/completions/grpck @@ -7,11 +7,11 @@ _grpck() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi _filedir } && complete -F _grpck grpck -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/gzip b/completions/gzip index 35e5f231..8093e41e 100644 --- a/completions/gzip +++ b/completions/gzip @@ -7,11 +7,11 @@ _gzip() case $prev in -b|--blocksize|-S|--suffix|-h|--help|-V|--version) - return 0 + return ;; -p|--processes) COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) - return 0 + return ;; esac @@ -19,22 +19,21 @@ _gzip() COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) {-1..-9}' \ -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi local IFS=$'\n' xspec="*.@(gz|t[ag]z)" + [[ ${1##*/} == pigz ]] && xspec="*.@([gz]z|t[ag]z)" if [[ "$prev" == --* ]]; then - [[ "$prev" == --decompress || \ - "$prev" == --list || \ - "$prev" == --test ]] && xspec="!"$xspec + [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec [[ "$prev" == --force ]] && xspec= elif [[ "$prev" == -* ]]; then [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec [[ "$prev" == -*f* ]] && xspec= fi - _expand || return 0 + _expand || return compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ @@ -42,4 +41,4 @@ _gzip() } && complete -F _gzip gzip pigz -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/hcitool b/completions/hcitool index b650e205..38d66427 100644 --- a/completions/hcitool +++ b/completions/hcitool @@ -1,6 +1,6 @@ # bash completion for bluez utils -*- shell-script -*- -_bluetooth_adresses() +_bluetooth_addresses() { if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then COMPREPLY+=( $( compgen -W "$( hcitool scan | \ @@ -35,19 +35,19 @@ _hcitool() case $prev in -i) _bluetooth_devices - return 0 + return ;; --role) COMPREPLY=( $( compgen -W 'm s' -- "$cur" ) ) - return 0 + return ;; --pkt-type) _bluetooth_packet_types - return 0 + return ;; esac - $split && return 0 + $split && return local arg _get_first_arg @@ -60,11 +60,12 @@ _hcitool() clock' -- "$cur" ) ) fi else + local args case $arg in name|info|dc|rssi|lq|afh|auth|key|clkoff|lst) _count_args if [[ $args -eq 2 ]]; then - _bluetooth_adresses + _bluetooth_addresses fi ;; cc) @@ -73,14 +74,14 @@ _hcitool() else _count_args if [[ $args -eq 2 ]]; then - _bluetooth_adresses + _bluetooth_addresses fi fi ;; sr) _count_args if [[ $args -eq 2 ]]; then - _bluetooth_adresses + _bluetooth_addresses else COMPREPLY=( $( compgen -W 'master slave' -- "$cur" ) ) fi @@ -88,7 +89,7 @@ _hcitool() cpt) _count_args if [[ $args -eq 2 ]]; then - _bluetooth_adresses + _bluetooth_addresses else _bluetooth_packet_types fi @@ -96,7 +97,7 @@ _hcitool() tpl|enc|clock) _count_args if [[ $args -eq 2 ]]; then - _bluetooth_adresses + _bluetooth_addresses else COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) ) fi @@ -113,12 +114,12 @@ _sdptool() case $prev in --bdaddr) - _bluetooth_adresses - return 0 + _bluetooth_addresses + return ;; esac - $split && return 0 + $split && return local arg _get_first_arg @@ -143,7 +144,7 @@ _sdptool() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--tree --raw --xml' -- "$cur" ) ) else - _bluetooth_adresses + _bluetooth_addresses fi ;; add) @@ -172,17 +173,17 @@ _l2ping() case $prev in -i) _bluetooth_devices - return 0 + return ;; -s|-c|-t|-d) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - _bluetooth_adresses + _bluetooth_addresses fi } && complete -F _l2ping l2ping @@ -195,12 +196,12 @@ _rfcomm() case $prev in -f|--config) _filedir - return 0 + return ;; -i) _bluetooth_devices - _bluetooth_adresses - return 0 + _bluetooth_addresses + return ;; esac @@ -214,6 +215,7 @@ _rfcomm() release' -- "$cur" ) ) fi else + local args _count_args if [[ $args -eq 2 ]]; then _bluetooth_devices @@ -221,7 +223,7 @@ _rfcomm() case $arg in connect|bind) if [[ $args -eq 3 ]]; then - _bluetooth_adresses + _bluetooth_addresses fi ;; esac @@ -238,8 +240,8 @@ _ciptool() case $prev in -i) _bluetooth_devices - _bluetooth_adresses - return 0 + _bluetooth_addresses + return ;; esac @@ -253,11 +255,12 @@ _ciptool() -- "$cur" ) ) fi else + local args case $arg in connect|release|loopback) _count_args if [[ $args -eq 2 ]]; then - _bluetooth_adresses + _bluetooth_addresses fi ;; esac @@ -273,7 +276,7 @@ _dfutool() case $prev in -d|--device) _bluetooth_devices - return 0 + return ;; esac @@ -313,11 +316,12 @@ _hciconfig() version revision lm' -- "$cur" ) ) fi else + local args case $arg in putkey|delkey) _count_args if [[ $args -eq 2 ]]; then - _bluetooth_adresses + _bluetooth_addresses fi ;; lm) @@ -366,11 +370,11 @@ _hciattach() COMPREPLY=( $( compgen -W 'flow noflow' -- "$cur" ) ) ;; 5) - _bluetooth_adresses + _bluetooth_addresses ;; esac fi } && complete -F _hciattach hciattach -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/hddtemp b/completions/hddtemp index 75641045..123b74a1 100644 --- a/completions/hddtemp +++ b/completions/hddtemp @@ -35,4 +35,4 @@ _hddtemp() } && complete -F _hddtemp hddtemp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/hid2hci b/completions/hid2hci index d840166a..9221c4d0 100644 --- a/completions/hid2hci +++ b/completions/hid2hci @@ -12,4 +12,4 @@ _hid2hci() } && complete -F _hid2hci hid2hci -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/hostname b/completions/hostname new file mode 100644 index 00000000..48f4222f --- /dev/null +++ b/completions/hostname @@ -0,0 +1,23 @@ +# hostname(1) completion -*- shell-script -*- + +_hostname() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|--help|-V|--version) + return + ;; + -F|--file) + _filedir + return + ;; + esac + + [[ $cur == -* ]] && \ + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) +} && +complete -F _hostname hostname + +# ex: filetype=sh diff --git a/completions/hping2 b/completions/hping2 index 45c2c4c6..9d454622 100644 --- a/completions/hping2 +++ b/completions/hping2 @@ -8,19 +8,19 @@ _hping2() case $prev in -I|--interface) _available_interfaces - return 0 + return ;; -a|--spoof) _known_hosts_real "$cur" - return 0 + return ;; -o|--tos) COMPREPLY=( $( compgen -W '02 04 08 10' ) ) - return 0 + return ;; -E|--file) _filedir - return 0 + return ;; esac @@ -32,4 +32,4 @@ _hping2() } && complete -F _hping2 hping hping2 hping3 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/htop b/completions/htop index 7735f9b5..13c06b15 100644 --- a/completions/htop +++ b/completions/htop @@ -27,6 +27,7 @@ _htop() [[ $COMPREPLY == *= ]] && compopt -o nospace return fi -} && complete -F _htop htop +} && +complete -F _htop htop -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/htpasswd b/completions/htpasswd index b0990fe1..bf3acb22 100644 --- a/completions/htpasswd +++ b/completions/htpasswd @@ -30,4 +30,4 @@ _htpasswd() } && complete -F _htpasswd htpasswd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iconv b/completions/iconv index b33cc704..50edb4c5 100644 --- a/completions/iconv +++ b/completions/iconv @@ -8,27 +8,26 @@ _iconv() case $prev in -'?'|--help|--usage|-V|--version|--unicode-subst|--byte-subst|\ --widechar-subst) - return 0 + return ;; -f|--from-code|-t|--to-code) COMPREPLY=( $( compgen -W '$( iconv -l | \ - sed -e "s@/*\$@@" -e "s/[,()]//g" )' -- "$cur" ) ) - return 0 + command sed -e "s@/*\$@@" -e "s/[,()]//g" )' -- "$cur" ) ) + return ;; -o|--output) _filedir - return 0 + return ;; esac - $split && return 0 + $split && return - if [[ "$cur" = -* ]]; then + if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 fi } && complete -F _iconv -o default iconv -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/id b/completions/id index c985c9eb..137a5f7e 100644 --- a/completions/id +++ b/completions/id @@ -15,4 +15,4 @@ _id() } && complete -F _id id -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/idn b/completions/idn index 14e4cc1a..12f4bdd1 100644 --- a/completions/idn +++ b/completions/idn @@ -23,4 +23,4 @@ _idn() } && complete -F _idn idn -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iftop b/completions/iftop index 8c606172..831e327b 100644 --- a/completions/iftop +++ b/completions/iftop @@ -7,15 +7,15 @@ _iftop() case $prev in -h|-f|-F|-m) - return 0 + return ;; -i) _available_interfaces -a - return 0 + return ;; -c) _filedir - return 0 + return ;; esac @@ -23,4 +23,4 @@ _iftop() } && complete -F _iftop iftop -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ifup b/completions/ifup index fcd34994..42cb8f80 100644 --- a/completions/ifup +++ b/completions/ifup @@ -12,8 +12,7 @@ _ifupdown() COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) fi - return 0 } && complete -F _ifupdown ifup ifdown ifstatus -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/info b/completions/info index 36550449..f71cbf5b 100644 --- a/completions/info +++ b/completions/info @@ -5,12 +5,12 @@ _info() local cur prev words cword split _init_completion -s || return - _expand || return 0 + _expand || return # default completion if parameter looks like a path if [[ "$cur" == @(*/|[.~])* ]]; then _filedir - return 0 + return fi case $prev in @@ -62,14 +62,13 @@ _info() COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) # weed out info dir file for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do - [[ ${COMPREPLY[$i]} == dir ]] && unset COMPREPLY[$i] + [[ ${COMPREPLY[$i]} == dir ]] && unset "COMPREPLY[$i]" done # strip suffix from info pages COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) ) - return 0 } && complete -F _info info pinfo -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/inject b/completions/inject index da2d9a9e..20ea9b7f 100644 --- a/completions/inject +++ b/completions/inject @@ -8,11 +8,11 @@ _inject() case $prev in -l|--listname) _xfunc list_lists _mailman_lists - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--listname --queue --help' -- "$cur" ) ) @@ -23,4 +23,4 @@ _inject() } && complete -F _inject inject -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/insmod b/completions/insmod index 545f8bc5..ec81c93e 100644 --- a/completions/insmod +++ b/completions/insmod @@ -15,4 +15,4 @@ _insmod() } && complete -F _insmod insmod insmod.static -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/installpkg b/completions/installpkg index cdaf816c..f002f775 100644 --- a/completions/installpkg +++ b/completions/installpkg @@ -8,25 +8,26 @@ _installpkg() case "$prev" in --root) _filedir -d - return 0 + return ;; --priority) COMPREPLY=( $( compgen -W 'ADD REC OPT SKP' -- "$cur" ) ) - return 0 + return ;; --tagfile) _filedir - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--warn --md5sum --root --infobox --terse --menu --ask --priority --tagfile' -- "$cur" ) ) - return 0 + return fi - _filedir "t[bglx]z" -} && complete -F _installpkg installpkg + _filedir 't[bglx]z' +} && +complete -F _installpkg installpkg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/interdiff b/completions/interdiff index 8b07572f..cf71002e 100644 --- a/completions/interdiff +++ b/completions/interdiff @@ -30,4 +30,4 @@ _interdiff() } && complete -F _interdiff interdiff -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/invoke-rc.d b/completions/invoke-rc.d index d4e0d245..777f6ace 100644 --- a/completions/invoke-rc.d +++ b/completions/invoke-rc.d @@ -20,20 +20,19 @@ _invoke_rc_d() if [[ ($cword -eq 1) || ("$prev" == --* ) ]]; then valid_options=( $( \ tr " " "\n" <<<"${words[@]} ${options[@]}" \ - | sed -ne "/$( sed "s/ /\\\\|/g" <<<"${options[@]}" )/p" \ + | command sed -ne "/$( command sed "s/ /\\\\|/g" <<<"${options[@]}" )/p" \ | sort | uniq -u \ ) ) COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) ) elif [[ -x $sysvdir/$prev ]]; then - COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \ + COMPREPLY=( $( compgen -W '`command sed -e "y/|/ /" \ -ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \ $sysvdir/$prev`' -- "$cur" ) ) else COMPREPLY=() fi - return 0 } && complete -F _invoke_rc_d invoke-rc.d -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ip b/completions/ip index b073c36f..00dd839d 100644 --- a/completions/ip +++ b/completions/ip @@ -14,25 +14,25 @@ _ip() case $prev in -V|-Version|-rc|-rcvbuf) - return 0 + return ;; -f|-family) COMPREPLY=( $( compgen -W 'inet inet6 ipx dnet link' -- "$cur" ) ) - return 0 + return ;; -b|-batch) _filedir - return 0 + return ;; -force) COMPREPLY=( $( compgen -W '-batch' -- "$cur" ) ) - return 0 + return ;; esac local subcword cmd subcmd for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do - [[ ${words[subcword]} == -b?(atch) ]] && return 0 + [[ ${words[subcword]} == -b?(atch) ]] && return [[ -n $cmd ]] && subcmd=${words[subcword]} && break [[ ${words[subcword]} != -* && \ ${words[subcword-1]} != -@(f?(amily)|rc?(vbuf)) ]] && \ @@ -46,21 +46,23 @@ _ip() -oneline -timestamp -batch -rcvbuf" [[ $cword -eq 1 ]] && c+=" -force" COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - return 0 + return ;; *) - COMPREPLY=( $( compgen -W "help $( ip help 2>&1 | \ - sed -e '/OBJECT := /,/}/!d' \ - -e 's/.*{//' -e 's/}.*//' -e 's/|//g' )" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "help $( ip help 2>&1 | command sed -e \ + '/OBJECT := /,/}/!d' -e \ + 's/.*{//' -e \ + 's/}.*//' -e \ + 's/|//g' )" -- "$cur" ) ) + return ;; esac fi - [[ $subcmd == help ]] && return 0 + [[ $subcmd == help ]] && return case $cmd in - link) + l|link) case $subcmd in add) # TODO @@ -120,13 +122,25 @@ _ip() esac ;; - addr) + a|addr|address) case $subcmd in add|change|replace) - # TODO + if [[ $prev == dev ]]; then + _available_interfaces + elif [[ $prev == scope ]]; then + _iproute2_etc rt_scopes + else + : # TODO + fi ;; del) - # TODO + if [[ $prev == dev ]]; then + _available_interfaces + elif [[ $prev == scope ]]; then + _iproute2_etc rt_scopes + else + : # TODO + fi ;; show|flush) if [[ $cword -eq $subcword+1 ]]; then @@ -151,7 +165,11 @@ _ip() addrlabel) case $subcmd in list|add|del|flush) - # TODO + if [[ $prev == dev ]]; then + _available_interfaces + else + : # TODO + fi ;; *) [[ $cword -eq $subcword ]] && \ @@ -164,7 +182,11 @@ _ip() route) case $subcmd in list|flush) - # TODO + if [[ $prev == proto ]]; then + _iproute2_etc rt_protos + else + : # TODO + fi ;; get) # TODO @@ -275,7 +297,7 @@ _ip() esac ;; - monitor) + monitor) case $subcmd in all) ;; *) @@ -285,7 +307,7 @@ _ip() esac ;; - xfrm) + xfrm) case $subcmd in state|policy|monitor) # TODO @@ -301,4 +323,4 @@ _ip() } && complete -F _ip ip -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iperf b/completions/iperf index 721825e2..4652879c 100644 --- a/completions/iperf +++ b/completions/iperf @@ -45,10 +45,10 @@ _iperf() for i in ${words[@]}; do case $i in -s|--server) - filter='sed -e /^Client.specific/,/^$/d' + filter='command sed -e /^Client.specific/,/^$/d' ;; -c|--client) - filter='sed -e /^Server.specific/,/^$/d' + filter='command sed -e /^Server.specific/,/^$/d' ;; esac done @@ -60,4 +60,4 @@ _iperf() } && complete -F _iperf iperf -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ipmitool b/completions/ipmitool index 281d9eac..8e2637c7 100644 --- a/completions/ipmitool +++ b/completions/ipmitool @@ -3,7 +3,7 @@ _ipmitool_singleline_help() { COMPREPLY=( $( compgen -W "$( $1 $2 2>&1 | \ - sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p' )" -- "$cur" ) ) + command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p' )" -- "$cur" ) ) } _ipmitool() @@ -13,53 +13,53 @@ _ipmitool() case $prev in -h|-V|-p|-U|-e|-k|-y|-P|-m|-b|-t|-B|-T|-l) - return 0 + return ;; -d) COMPREPLY=( $( compgen -W "$( \ command ls -d /dev/ipmi* /dev/ipmi/* /dev/ipmidev/* \ - 2>/dev/null | sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p' )" \ + 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p' )" \ -- "$cur" ) ) - return 0 + return ;; -I) COMPREPLY=( $( compgen -W "$( $1 -h 2>&1 | \ - sed -e '/^Interfaces:/,/^[[:space:]]*$/!d' \ + command sed -e '/^Interfaces:/,/^[[:space:]]*$/!d' \ -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p' )" \ -- "$cur" ) ) - return 0 + return ;; -H) _known_hosts_real "$cur" - return 0 + return ;; -f|-S|-O) _filedir - return 0 + return ;; -C) COMPREPLY=( $( compgen -W '{0..14}' -- "$cur" ) ) - return 0 + return ;; -L) COMPREPLY=( $( compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \ -- "$cur" ) ) - return 0 + return ;; -A) COMPREPLY=( $( compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur" ) ) - return 0 + return ;; -o) COMPREPLY=( $( compgen -W "$( $1 -o list 2>&1 | \ awk '/^[ \t]+/ { print $1 }' ) list" -- "$cur" ) ) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h)' -- "$cur" ) ) - return 0 + return fi # Find out command and subcommand @@ -77,7 +77,7 @@ _ipmitool() if [[ -z $cmd ]]; then COMPREPLY=( $( compgen -W '${cmds[@]}' -- "$cur" ) ) - return 0 + return fi # Command/subcommand completions @@ -197,4 +197,4 @@ _ipmitool() } && complete -F _ipmitool ipmitool -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ipsec b/completions/ipsec index b1161b0a..357d5055 100644 --- a/completions/ipsec +++ b/completions/ipsec @@ -7,7 +7,7 @@ _ipsec_connections() { local keyword name while read -r keyword name; do - if [[ $keyword = [#]* ]]; then continue; fi + if [[ $keyword == [#]* ]]; then continue; fi [[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=( "$name" ) done COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) @@ -22,7 +22,7 @@ _ipsec_freeswan() COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp tncfg whack' -- "$cur" ) ) - return 0 + return fi case ${words[1]} in @@ -45,8 +45,6 @@ _ipsec_freeswan() *) ;; esac - - return 0 } _ipsec_strongswan() @@ -64,7 +62,7 @@ _ipsec_strongswan() scencrypt scepclient secrets start starter status statusall stop stroke unroute uci up update version whack --confdir --copyright --directory --help --version --versioncode' -- "$cur" ) ) - return 0 + return fi case ${words[1]} in @@ -91,8 +89,6 @@ _ipsec_strongswan() *) ;; esac - - return 0 } case "$( ipsec --version 2>/dev/null )" in @@ -104,4 +100,4 @@ case "$( ipsec --version 2>/dev/null )" in ;; esac -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iptables b/completions/iptables index 0d54afbd..0ecb1ebd 100644 --- a/completions/iptables +++ b/completions/iptables @@ -18,7 +18,7 @@ _iptables() case $prev in -*[AIDRPFXLZ]) COMPREPLY=( $( compgen -W '`iptables $table -nL | \ - sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" ) ) + command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" ) ) ;; -*t) COMPREPLY=( $( compgen -W 'nat filter mangle' -- "$cur" ) ) @@ -26,17 +26,17 @@ _iptables() -j) if [[ "$table" == "-t filter" || -z "$table" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT - `iptables $table -nL | sed -ne "$chain" \ + `iptables $table -nL | command sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ "$cur" ) ) elif [[ $table == "-t nat" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \ - sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ + command sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ -- "$cur" ) ) elif [[ $table == "-t mangle" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS - `iptables $table -nL | sed -ne "$chain" \ + `iptables $table -nL | command sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ "$cur" ) ) fi @@ -57,4 +57,4 @@ _iptables() } && complete -F _iptables iptables -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ipv6calc b/completions/ipv6calc index 5db7271f..0dacff94 100644 --- a/completions/ipv6calc +++ b/completions/ipv6calc @@ -7,25 +7,25 @@ _ipv6calc() case "$prev" in -d|--debug) - return 0 + return ;; -I|--in|-O|--out|-A|--action) # With ipv6calc < 0.73.0, -m does nothing here, so use sed instead. - COMPREPLY=( $( compgen -W "$( ipv6calc "$prev" -h 2>&1 | \ - sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p' )" \ + COMPREPLY=( $( compgen -W "$( $1 "$prev" -h 2>&1 | \ + command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p' )" \ -- "$cur" ) ) - return 0 + return ;; --db-geoip|--db-ip2location-ipv4|--db-ip2location-ipv6) _filedir - return 0 + return ;; --printstart|--printend) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --debug --quiet --in --out --action @@ -35,11 +35,9 @@ _ipv6calc() --masksuffix --printstart --printend --printcompressed --printuncompressed --printfulluncompressed --printmirrored' \ -- "$cur" ) ) - return 0 fi - return 0 } && complete -F _ipv6calc ipv6calc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iscsiadm b/completions/iscsiadm index 326dc208..e5218d75 100644 --- a/completions/iscsiadm +++ b/completions/iscsiadm @@ -9,23 +9,23 @@ _iscsiadm() -m|--mode) COMPREPLY=( $( compgen -W 'discovery node session iface fw host' \ -- "$cur" ) ) - return 0 + return ;; -o|--op) COMPREPLY=( $( compgen -W 'new delete update show' -- "$cur" ) ) - return 0 + return ;; -t|--type) COMPREPLY=( $( compgen -W 'sendtargets st slp isns fw' -- "$cur" ) ) - return 0 + return ;; -L|-U|--loginall|--logoutall) COMPREPLY=( $( compgen -W 'all manual automatic' -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return local options if [[ $cword -gt 1 ]] ; then @@ -63,4 +63,4 @@ _iscsiadm() } && complete -F _iscsiadm iscsiadm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/isql b/completions/isql index 43cd6dd3..862a9304 100644 --- a/completions/isql +++ b/completions/isql @@ -7,8 +7,8 @@ _isql() _init_completion || return [[ -f $ODBCINI ]] \ - && COMPREPLY=( $( command grep \\["$cur" "$ODBCINI" | tr -d \\[\\] ) ) + && COMPREPLY=( $( command grep "\[$cur" "$ODBCINI" | tr -d \[\] ) ) } && complete -F _isql isql -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iwconfig b/completions/iwconfig index 36213d2c..114081dd 100644 --- a/completions/iwconfig +++ b/completions/iwconfig @@ -9,7 +9,7 @@ _iwconfig() mode) COMPREPLY=( $( compgen -W 'managed ad-hoc master repeater secondary monitor' -- "$cur" ) ) - return 0 + return ;; essid) COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) ) @@ -18,22 +18,22 @@ _iwconfig() "$( iwlist ${words[1]} scan | \ awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" ) ) fi - return 0 + return ;; nwid) COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) - return 0 + return ;; channel) COMPREPLY=( $( compgen -W "$( iwlist ${words[1]} channel | \ awk '/^[ \t]*Channel/ {print $2}' )" -- "$cur" ) ) - return 0 + return ;; freq) COMPREPLY=( $( compgen -W "$( iwlist ${words[1]} channel | \ awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur" ) ) - return 0 + return ;; ap) COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) ) @@ -42,34 +42,34 @@ _iwconfig() "$( iwlist ${words[1]} scan | \ awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) ) fi - return 0 + return ;; rate) COMPREPLY=( $( compgen -W 'auto fixed' -- "$cur" ) ) COMPREPLY+=( $( compgen -W \ "$( iwlist ${words[1]} rate | \ awk '/^[ \t]*[0-9]/ {print $1"M"}' )" -- "$cur" ) ) - return 0 + return ;; rts|frag) COMPREPLY=( $( compgen -W 'auto fixed off' -- "$cur" ) ) - return 0 + return ;; key|enc) COMPREPLY=( $( compgen -W 'off on open restricted' -- "$cur" ) ) - return 0 + return ;; power) COMPREPLY=( $( compgen -W 'period timeout off on' -- "$cur" ) ) - return 0 + return ;; txpower) COMPREPLY=( $( compgen -W 'off on auto' -- "$cur" ) ) - return 0 + return ;; retry) COMPREPLY=( $( compgen -W 'limit lifetime' -- "$cur" ) ) - return 0 + return ;; esac @@ -87,4 +87,4 @@ _iwconfig() } && complete -F _iwconfig iwconfig -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iwlist b/completions/iwlist index 78c15b71..b27dbe8b 100644 --- a/completions/iwlist +++ b/completions/iwlist @@ -19,4 +19,4 @@ _iwlist() } && complete -F _iwlist iwlist -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iwpriv b/completions/iwpriv index 05952c5e..c7f8209e 100644 --- a/completions/iwpriv +++ b/completions/iwpriv @@ -8,11 +8,11 @@ _iwpriv() case $prev in roam) COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) - return 0 + return ;; port) COMPREPLY=( $( compgen -W 'ad-hoc managed' -- "$cur" ) ) - return 0 + return ;; esac @@ -28,4 +28,4 @@ _iwpriv() } && complete -F _iwpriv iwpriv -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/iwspy b/completions/iwspy index b59b0693..1cf3a283 100644 --- a/completions/iwspy +++ b/completions/iwspy @@ -17,4 +17,4 @@ _iwspy() } && complete -F _iwspy iwspy -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/jar b/completions/jar index 8af86a17..b7de930f 100644 --- a/completions/jar +++ b/completions/jar @@ -7,7 +7,7 @@ _jar() if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W 'c t x u' -- "$cur" ) ) - return 0 + return fi case ${words[1]} in @@ -24,4 +24,4 @@ _jar() } && complete -F _jar jar -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/jarsigner b/completions/jarsigner index c1c72af7..2441bd1a 100644 --- a/completions/jarsigner +++ b/completions/jarsigner @@ -9,23 +9,24 @@ _jarsigner() -keystore) COMPREPLY=( $( compgen -W 'NONE' -- "$cur" ) ) _filedir '@(jks|ks|p12|pfx)' - return 0 + return ;; - -storepass|-keypass|-sigfile|-digestalg|-sigalg|-tsacert|-altsigner|\ - -altsignerpath|-providerName|-providerClass|-providerArg) - return 0 + -storepass|-keypass|-sigfile|-digestalg|-sigalg|-tsacert|-tsapolicyid|\ + -tsadigestalg|-altsigner|-altsignerpath|-providerName|-providerClass|\ + -providerArg) + return + ;; + -certchain|-sigfile|-tsa) + _filedir + return ;; -storetype) COMPREPLY=( $( compgen -W 'JKS PKCS11 PKCS12' -- "$cur" ) ) - return 0 + return ;; -signedjar) _filedir jar - return 0 - ;; - -tsa) - _filedir - return 0 + return ;; esac @@ -53,4 +54,4 @@ _jarsigner() } && complete -F _jarsigner jarsigner -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/java b/completions/java index c302d1e5..7d1cf1fe 100644 --- a/completions/java +++ b/completions/java @@ -71,9 +71,9 @@ _java_classes() elif [[ -d $i ]]; then COMPREPLY+=( - $( compgen -d -- "$i/$cur" | sed -e "s|^$i/\(.*\)|\1.|" ) + $( compgen -d -- "$i/$cur" | command sed -e "s|^$i/\(.*\)|\1.|" ) $( compgen -f -X '!*.class' -- "$i/$cur" | \ - sed -e '/\$/d' -e "s|^$i/||" ) + command sed -e '/\$/d' -e "s|^$i/||" ) ) [[ $COMPREPLY == *.class ]] || compopt -o nospace @@ -103,7 +103,7 @@ _java_packages() for i in ${sourcepath//:/ }; do if [[ -d $i ]]; then COMPREPLY+=( $( command ls -F -d $i/$cur* 2>/dev/null | \ - sed -e 's|^'$i'/||' ) ) + command sed -e 's|^'$i'/||' ) ) fi done # keep only packages @@ -134,7 +134,7 @@ _java() *) # once we've seen a class, just do filename completion _filedir - return 0 + return ;; esac done @@ -143,70 +143,70 @@ _java() # standard option completions -verbose:*) COMPREPLY=( $( compgen -W 'class gc jni' -- "${cur#*:}" ) ) - return 0 + return ;; -javaagent:*) cur=${cur#*:} _filedir '@(jar|zip)' - return 0 + return ;; -agentpath:*) cur=${cur#*:} _filedir so - return 0 + return ;; # various non-standard option completions -splash:*) cur=${cur#*:} _filedir '@(gif|jp?(e)g|png)' - return 0 + return ;; -Xbootclasspath*:*) _java_path - return 0 + return ;; -Xcheck:*) COMPREPLY=( $( compgen -W 'jni' -- "${cur#*:}" ) ) - return 0 + return ;; -Xgc:*) COMPREPLY=( $( compgen -W 'singlecon gencon singlepar genpar' \ -- "${cur#*:}" ) ) - return 0 + return ;; -Xgcprio:*) COMPREPLY=( $( compgen -W 'throughput pausetime deterministic' \ -- "${cur#*:}" ) ) - return 0 + return ;; -Xloggc:*|-Xverboselog:*) cur=${cur#*:} _filedir - return 0 + return ;; -Xshare:*) COMPREPLY=( $( compgen -W 'auto off on' -- "${cur#*:}" ) ) - return 0 + return ;; -Xverbose:*) COMPREPLY=( $( compgen -W 'memory load jni cpuinfo codegen opt gcpause gcreport' -- "${cur#*:}" ) ) - return 0 + return ;; -Xverify:*) COMPREPLY=( $( compgen -W 'all none remote' -- "${cur#*:}" ) ) - return 0 + return ;; # the rest that we have no completions for -D*|-*:*) - return 0 + return ;; esac case $prev in -cp|-classpath) _java_path - return 0 + return ;; esac @@ -238,19 +238,29 @@ _javadoc() case $prev in -overview|-helpfile) _filedir '?(x)htm?(l)' - return 0 + return + ;; + -doclet|-exclude|-subpackages|-source|-locale|-encoding|-windowtitle|\ + -doctitle|-header|-footer|-top|-bottom|-group|-noqualifier|-tag|\ + -charset|-sourcetab|-docencoding) + return ;; -stylesheetfile) _filedir css - return 0 + return ;; -d|-link|-linkoffline) _filedir -d - return 0 + return ;; - -classpath|-bootclasspath|-docletpath|-sourcepath|-extdirs) + -classpath|-cp|-bootclasspath|-docletpath|-sourcepath|-extdirs|\ + -excludedocfilessubdir) _java_path - return 0 + return + ;; + -helpfile) + _filedir + return ;; esac @@ -279,11 +289,11 @@ _javac() case $prev in -d) _filedir -d - return 0 + return ;; - -classpath|-bootclasspath|-sourcepath|-extdirs) + -cp|-classpath|-bootclasspath|-sourcepath|-extdirs) _java_path - return 0 + return ;; esac @@ -294,7 +304,7 @@ _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 | sed -e 's/-g:none/-g:{none}/' -ne \ + 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 @@ -315,4 +325,4 @@ _javac() } && complete -F _javac javac -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/javaws b/completions/javaws index b9afefd7..7d6e22c8 100644 --- a/completions/javaws +++ b/completions/javaws @@ -7,28 +7,28 @@ _javaws() case $prev in -help|-license|-about|-viewer|-arg|-param|-property|-update|-umask) - return 0 + return ;; -basedir|-codebase) _filedir -d - return 0 + return ;; -uninstall|-import) _filedir jnlp - return 0 + return ;; esac if [[ $cur == *= ]]; then - return 0 + return elif [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W "$( _parse_help "$1" -help ) " -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi _filedir jnlp } && complete -F _javaws javaws -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/jpegoptim b/completions/jpegoptim new file mode 100644 index 00000000..754f16a2 --- /dev/null +++ b/completions/jpegoptim @@ -0,0 +1,38 @@ +# jpegoptim(1) completion -*- shell-script -*- + +_jpegoptim() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help|-V|--version) + return + ;; + -d|--dest) + _filedir -d + return + ;; + -m|--max|-T|--threshold) + COMPREPLY=( $( compgen -W '{0..100}' -- "$cur" ) ) + return + ;; + -S|--size) + COMPREPLY=( $( compgen -W '{1..99}%' -- "$cur" ) ) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir 'jp?(e)g' +} && +complete -F _jpegoptim jpegoptim + +# ex: filetype=sh diff --git a/completions/jps b/completions/jps index 774ad6ce..42f8d1a5 100644 --- a/completions/jps +++ b/completions/jps @@ -22,4 +22,4 @@ _jps() } && complete -F _jps jps -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/jshint b/completions/jshint new file mode 100644 index 00000000..ea9bbeb5 --- /dev/null +++ b/completions/jshint @@ -0,0 +1,38 @@ +# bash completion for jshint -*- shell-script -*- + +_jshint() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -v|--version|-h|--help|--exclude|--filename|-e|--extra-ext) + return + ;; + -c|--config) + _filedir + return + ;; + --reporter) + COMPREPLY=( $( compgen -W "jslint checkstyle unix" -- "$cur" ) ) + return + ;; + --extract) + COMPREPLY=( $( compgen -W "auto always never" -- "$cur" ) ) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir js +} && +complete -F _jshint jshint + +# ex: filetype=sh diff --git a/completions/k3b b/completions/k3b index 9c03642f..2cbcbb1b 100644 --- a/completions/k3b +++ b/completions/k3b @@ -7,32 +7,32 @@ _k3b() case $prev in --help*|--author|-v|--version|--license|--lang) - return 0 + return ;; --datacd|--audiocd|--videocd|--mixedcd|--emovixcd|--videodvd) _filedir - return 0 + return ;; --copydvd|--formatdvd|--videodvdrip) _dvd_devices - return 0 + return ;; --copycd|--erasecd|--cddarip|--videocdrip) _cd_devices _dvd_devices - return 0 + return ;; --cdimage|--image) - _filedir @(cue|iso|toc) - return 0 + _filedir '@(cue|iso|toc)' + return ;; --dvdimage) _filedir iso - return 0 + return ;; --ao) COMPREPLY=( $( compgen -W 'alsa arts' -- "$cur" ) ) - return 0 + return ;; esac @@ -45,4 +45,4 @@ _k3b() } && complete -F _k3b k3b -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/kcov b/completions/kcov index 86d2d10c..7e9aa1e0 100644 --- a/completions/kcov +++ b/completions/kcov @@ -3,7 +3,7 @@ _kcov() { local cur prev words cword split - _init_completion -s || return + _init_completion -s -n : || return case "$prev" in --pid|-p) @@ -11,25 +11,31 @@ _kcov() return ;; --sort-type|-s) - COMPREPLY=( $( compgen -W 'filename percentage lines uncovered' \ - -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'filename percent reverse lines + uncovered' -- "$cur" ) ) return ;; --include-path|--exclude-path) _filedir return ;; + --replace-src-path) + if [[ "$cur" == ?*:* ]]; then + cur="${cur##*:}" + _filedir + else + _filedir + compopt -o nospace + fi + return + ;; --limits|-l) - split=false if [[ "$cur" == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" - split=true - fi - COMPREPLY=( $( compgen -W "{0..100}" -- "$cur" ) ) - if $split; then - COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) + COMPREPLY=( $( compgen -P "$prev," -W "{0..100}" -- "$cur" ) ) else + COMPREPLY=( $( compgen -W "{0..100}" -- "$cur" ) ) compopt -o nospace fi return @@ -49,6 +55,7 @@ _kcov() fi _filedir -} && complete -F _kcov kcov +} && +complete -F _kcov kcov -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/kill b/completions/kill index ed5ae585..ac179cd9 100644 --- a/completions/kill +++ b/completions/kill @@ -26,4 +26,4 @@ _kill() } && complete -F _kill kill -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/killall b/completions/killall index ed502f97..6d1532c3 100644 --- a/completions/killall +++ b/completions/killall @@ -33,4 +33,4 @@ _killall() } && complete -F _killall killall -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/kldload b/completions/kldload index f362db69..0442e95e 100644 --- a/completions/kldload +++ b/completions/kldload @@ -15,8 +15,7 @@ _kldload() COMPREPLY=( ${COMPREPLY[@]#$moddir} ) COMPREPLY=( ${COMPREPLY[@]%.ko} ) - return 0 } && complete -F _kldload kldload -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/kldunload b/completions/kldunload index adb268d8..82770189 100644 --- a/completions/kldunload +++ b/completions/kldunload @@ -7,9 +7,9 @@ _kldunload() local cur prev words cword _init_completion || return - COMPREPLY=( $( kldstat | \ - sed -ne "s/^.*[ \t]\{1,\}\($cur[a-z_]\{1,\}\).ko$/\1/p" ) ) + COMPREPLY=( $( kldstat | command sed -ne \ + "s/^.*[[:blank:]]\{1,\}\($cur[a-z_]\{1,\}\).ko$/\1/p" ) ) } && complete -F _kldunload kldunload -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/koji b/completions/koji index bd6cb2fd..30b8d49a 100644 --- a/completions/koji +++ b/completions/koji @@ -244,4 +244,4 @@ _koji() } && complete -F _koji koji arm-koji ppc-koji s390-koji sparc-koji -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ktutil b/completions/ktutil index 88eb5275..384db329 100644 --- a/completions/ktutil +++ b/completions/ktutil @@ -29,27 +29,27 @@ _ktutil() case $prev in -p|--principal) _heimdal_principals - return 0 + return ;; -e|--enctype) _heimdal_encodings - return 0 + return ;; -a|--admin-server) _known_hosts_real "$cur" - return 0 + return ;; -r|--realm) _heimdal_realms - return 0 + return ;; -s|-k|--srvtab|--keytab) _filedir - return 0 + return ;; esac - $split && return 0 + $split && return commands='add change copy get list remove rename purge srvconvert srv2keytab srvcreate key2srvtab' @@ -117,4 +117,4 @@ _ktutil() } && complete -F _ktutil ktutil -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/larch b/completions/larch index 79716a5f..5b7ebd14 100644 --- a/completions/larch +++ b/completions/larch @@ -33,8 +33,7 @@ _larch() "$cur" ) ) fi - return 0 } && complete -F _larch -o default larch -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lastlog b/completions/lastlog index a8724029..4ac6b520 100644 --- a/completions/lastlog +++ b/completions/lastlog @@ -7,19 +7,19 @@ _lastlog() case $prev in -b|--before|-h|--help|-t|--time) - return 0 + return ;; -u|--user) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _lastlog lastlog -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ldapsearch b/completions/ldapsearch index 6a9b7b1b..282760f7 100644 --- a/completions/ldapsearch +++ b/completions/ldapsearch @@ -18,32 +18,32 @@ _ldapsearch() case $prev in -h) _known_hosts_real "$cur" - return 0 + return ;; -H) _ldap_uris - return 0 + return ;; -T) _filedir -d - return 0 + return ;; -f|-y) _filedir - return 0 + return ;; -s) COMPREPLY=( $( compgen -W 'base one sub children' -- "$cur" ) ) - return 0 + return ;; -a) COMPREPLY=( $( compgen -W 'never always search find' \ -- "$cur" ) ) - return 0 + return ;; -P) _ldap_protocols - return 0 + return ;; esac @@ -61,19 +61,19 @@ _ldapaddmodify() case $prev in -h) _known_hosts_real "$cur" - return 0 + return ;; -H) _ldap_uris - return 0 + return ;; -S|-f|-y) _filedir - return 0 + return ;; -P) _ldap_protocols - return 0 + return ;; esac @@ -91,19 +91,19 @@ _ldapdelete() case $prev in -h) _known_hosts_real "$cur" - return 0 + return ;; -H) _ldap_uris - return 0 + return ;; -f|-y) _filedir - return 0 + return ;; -P) _ldap_protocols - return 0 + return ;; esac @@ -121,19 +121,19 @@ _ldapcompare() case $prev in -h) _known_hosts_real "$cur" - return 0 + return ;; -H) _ldap_uris - return 0 + return ;; -y) _filedir - return 0 + return ;; -P) _ldap_protocols - return 0 + return ;; esac @@ -151,19 +151,19 @@ _ldapmodrdn() case $prev in -h) _known_hosts_real "$cur" - return 0 + return ;; -H) _ldap_uris - return 0 + return ;; -f|-y) _filedir - return 0 + return ;; -P) _ldap_protocols - return 0 + return ;; esac @@ -181,19 +181,19 @@ _ldapwhoami() case $prev in -h) _known_hosts_real "$cur" - return 0 + return ;; -H) _ldap_uris - return 0 + return ;; -f|-y) _filedir - return 0 + return ;; -P) _ldap_protocols - return 0 + return ;; esac @@ -211,15 +211,15 @@ _ldappasswd() case $prev in -h) _known_hosts_real "$cur" - return 0 + return ;; -H) _ldap_uris - return 0 + return ;; -t|-T|-y) _filedir - return 0 + return ;; esac @@ -229,4 +229,4 @@ _ldappasswd() } && complete -F _ldappasswd ldappasswd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ldapvi b/completions/ldapvi index 9c9b6491..e3c1f103 100644 --- a/completions/ldapvi +++ b/completions/ldapvi @@ -8,37 +8,37 @@ _ldapvi() case $prev in -h|--host) _known_hosts_real "$cur" - return 0 + return ;; -Y|--sasl-mech) COMPREPLY=( $( compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 PLAIN ANONYMOUS' -- "$cur" ) ) - return 0 + return ;; --bind) COMPREPLY=( $( compgen -W 'simple sasl' -- "$cur" ) ) - return 0 + return ;; --bind-dialog) COMPREPLY=( $( compgen -W 'never auto always' -- "$cur" ) ) - return 0 + return ;; --scope) COMPREPLY=( $( compgen -W 'base one sub' -- "$cur" ) ) - return 0 + return ;; --deref) COMPREPLY=( $( compgen -W 'never searching finding always' \ -- "$cur" ) ) - return 0 + return ;; --encoding) COMPREPLY=( $( compgen -W 'ASCII UTF-8 binary' -- "$cur" ) ) - return 0 + return ;; --tls) COMPREPLY=( $( compgen -W 'never allow try strict' -- "$cur" ) ) - return 0 + return ;; esac @@ -48,4 +48,4 @@ _ldapvi() } && complete -F _ldapvi ldapvi -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lftp b/completions/lftp index 86706002..edb363b2 100644 --- a/completions/lftp +++ b/completions/lftp @@ -8,16 +8,16 @@ _lftp() case $prev in -f) _filedir - return 0 + return ;; -c|-h|--help|-v|--version|-e|-u|-p) - return 0 + return ;; esac if [[ "$cur" == -* ]] ; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi COMPREPLY=( $( compgen -W \ @@ -26,4 +26,4 @@ _lftp() } && complete -F _lftp lftp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lftpget b/completions/lftpget index 88ab31f6..8f1d4a2f 100644 --- a/completions/lftpget +++ b/completions/lftpget @@ -11,4 +11,4 @@ _lftpget() } && complete -F _lftpget lftpget -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lilo b/completions/lilo index 3073183c..1ccca35c 100644 --- a/completions/lilo +++ b/completions/lilo @@ -3,7 +3,7 @@ _lilo_labels() { COMPREPLY=( $( compgen -W "$( awk -F'=' '/label/ {print $2}' \ - /etc/lilo.conf | sed -e 's/\"//g' )" -- "$cur" ) ) + /etc/lilo.conf | command sed -e 's/\"//g' )" -- "$cur" ) ) } _lilo() @@ -14,28 +14,28 @@ _lilo() case $prev in -C|-i|-m|-s|-S) _filedir - return 0 + return ;; -r) _filedir -d - return 0 + return ;; -I|-D|-R) # label completion _lilo_labels - return 0 + return ;; -A|-b|-M|-u|-U) # device completion cur=${cur:=/dev/} _filedir - return 0 + return ;; -T) # topic completion COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= table= video' -- "$cur" ) ) - return 0 + return ;; esac @@ -47,4 +47,4 @@ _lilo() } && complete -F _lilo lilo -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/links b/completions/links index abb19900..8c72970e 100644 --- a/completions/links +++ b/completions/links @@ -23,12 +23,11 @@ _links() -- "$cur" ) ) fi _filedir '@(htm|html)' - return 0 + return ;; esac - return 0 } && complete -F _links links -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lintian b/completions/lintian index 1c9eaa6e..e62a6265 100644 --- a/completions/lintian +++ b/completions/lintian @@ -4,13 +4,13 @@ _lintian_tags() { local match search tags - tags=$( grep -e ^Tag /usr/share/lintian/checks/*.desc | cut -d\ -f2 ) + tags=$( awk '/^Tag/ { print $2 }' /usr/share/lintian/checks/*.desc ) if [[ "$cur" == *, ]]; then search=${cur//,/ } for item in $search; do - match=$(grep -nE "^Tag: $item$" /usr/share/lintian/checks/*.desc \ - | cut -d: -f1 ) - tags=$( 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 @@ -18,24 +18,22 @@ _lintian_tags() else COMPREPLY+=( $(compgen -W "$tags" -- "$cur") ) fi - return 0 } _lintian_checks() { local match search todisable checks - checks=$(grep -e ^Check-Script -e ^Abbrev \ - /usr/share/lintian/checks/*.desc | cut -d\ -f2 ) + checks=$( awk '/^(Check-Script|Abbrev)/ { print $2 }' \ + /usr/share/lintian/checks/*.desc ) if [[ "$cur" == *, ]]; then search=${cur//,/ } for item in $search; do - match=$(grep -nE "^(Check-Script|Abbrev): $item$" \ - /usr/share/lintian/checks/*.desc | cut -d: -f1 ) - todisable=$(grep -e ^Check-Script -e ^Abbrev $match | \ - cut -d\ -f2 ) + 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=$( sed -e "s/\<$name\>//g" <<<$checks ) + checks=$( command sed -e "s/\<$name\>//g" <<<$checks ) done done COMPREPLY+=( $(compgen -W "$checks") ) @@ -44,21 +42,20 @@ _lintian_checks() else COMPREPLY+=( $(compgen -W "$checks" -- "$cur") ) fi - return 0 } _lintian_infos() { local match search infos - infos=$(grep -e ^Collector /usr/share/lintian/collection/*.desc \ - | cut -d\ -f2 ) + infos=$( awk '/^Collector/ { print $2 }' \ + /usr/share/lintian/collection/*.desc ) if [[ "$cur" == *, ]]; then search=${cur//,/ } for item in $search; do - match=$( grep -nE "^Collector: $item$" \ - /usr/share/lintian/collection/*.desc | cut -d: -f1 ) - infos=$( 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 @@ -66,12 +63,6 @@ _lintian_infos() else COMPREPLY+=( $(compgen -W "$infos" -- "$cur") ) fi - return 0 -} - -_lintian_arches() -{ - return 0 } _lintian() @@ -94,7 +85,7 @@ _lintian() --root" selection_opts="--all --binary --source --udeb --packages-file" - if [[ "$prev" = -* ]]; then + if [[ "$prev" == -* ]]; then case $prev in -C|--check-part|-X|--dont-check-part) _lintian_checks @@ -176,4 +167,4 @@ _lintian_info() } && complete -F _lintian_info lintian-info -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lisp b/completions/lisp index 45cd4e6f..279ffcdb 100644 --- a/completions/lisp +++ b/completions/lisp @@ -16,8 +16,7 @@ _lisp() _filedir fi - return 0 } && complete -F _lisp -o default lisp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/list_admins b/completions/list_admins index 6c05a7d3..06542f91 100644 --- a/completions/list_admins +++ b/completions/list_admins @@ -14,4 +14,4 @@ _list_admins() } && complete -F _list_admins list_admins -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/list_lists b/completions/list_lists index 04471e1e..629e4c07 100644 --- a/completions/list_lists +++ b/completions/list_lists @@ -18,4 +18,4 @@ _list_lists() } && complete -F _list_lists list_lists -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/list_members b/completions/list_members index d432b36c..e60f61da 100644 --- a/completions/list_members +++ b/completions/list_members @@ -8,20 +8,20 @@ _list_members() case $prev in -o|--output) _filedir - return 0 + return ;; -d|--digest) COMPREPLY=( $( compgen -W 'mime plain' -- "$cur" ) ) - return 0 + return ;; -n|--nomail) COMPREPLY=( $( compgen -W 'byadmin byuser bybounce unknown' \ -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--output --regular --digest --nomail @@ -33,4 +33,4 @@ _list_members() } && complete -F _list_members list_members -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/list_owners b/completions/list_owners index a780265b..88b25bb3 100644 --- a/completions/list_owners +++ b/completions/list_owners @@ -15,4 +15,4 @@ _list_owners() } && complete -F _list_owners list_owners -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lpq b/completions/lpq index d667713e..b02705af 100644 --- a/completions/lpq +++ b/completions/lpq @@ -8,21 +8,21 @@ _lpq() case $prev in -P) COMPREPLY=( $( compgen -W "$( lpstat -a 2>/dev/null | cut -d' ' -f1 )" -- "$cur" ) ) - return 0 + return ;; -U) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; esac if [[ "$cur" == - ]]; then COMPREPLY=( $( compgen -W '-E -P -U -a -h -l' -- "$cur" ) ) - return 0 + return fi _filedir } && complete -F _lpq lpq -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lpr b/completions/lpr index 35ddd625..b1515bd5 100644 --- a/completions/lpr +++ b/completions/lpr @@ -8,26 +8,26 @@ _lpr() case $prev in -P) COMPREPLY=( $( compgen -W "$( lpstat -a 2>/dev/null | cut -d' ' -f1 )" -- "$cur" ) ) - return 0 + return ;; -U) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + 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 == *= ]] && compopt -o nospace - return 0 + return ;; esac if [[ "$cur" == - ]]; then COMPREPLY=( $( compgen -W '-E -H -C -J -T -P -U -h -l -m -o -p -q -r' -- "$cur" ) ) - return 0 + return fi _filedir } && complete -F _lpr lpr -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lrzip b/completions/lrzip index d4106fb2..f8e2cf1c 100644 --- a/completions/lrzip +++ b/completions/lrzip @@ -8,39 +8,39 @@ _lrzip() local xspec="*.lrz" case $prev in - -w|-S|-V|-h|-'?') - return 0 + -w|-S|-V|-h|-'?'|-m) + return ;; -d) xspec="!"$xspec ;; -o) _filedir - return 0 + return ;; -O) _filedir -d - return 0 + return ;; -L) COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) - return 0 + return ;; -N) COMPREPLY=( $( compgen -W '{-20..19}' -- "$cur" ) ) - return 0 + return ;; -p) COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) - return 0 + return ;; esac - _expand || return 0 + _expand || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi local IFS=$'\n' @@ -50,4 +50,4 @@ _lrzip() } && complete -F _lrzip lrzip -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lsof b/completions/lsof index 6ff7786c..329946d5 100644 --- a/completions/lsof +++ b/completions/lsof @@ -7,38 +7,38 @@ _lsof() case $prev in -'?'|-h|+c|-c|-d|-F|-i|+r|-r|-s|-S|-T) - return 0 + return ;; -A|-k|-m|+m|-o) _filedir - return 0 + return ;; +d|+D) _filedir -d - return 0 + return ;; -D) COMPREPLY=( $( compgen -W '? b i r u' -- "$cur" ) ) - return 0 + return ;; -f) COMPREPLY=( $( compgen -W 'c f g G n' -- "$cur" ) ) - return 0 + return ;; -g) # TODO: handle ^foo exclusions, comma separated lists _pgids - return 0 + return ;; -p) # TODO: handle ^foo exclusions, comma separated lists _pids - return 0 + return ;; -u) # TODO: handle ^foo exclusions, comma separated lists COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; esac @@ -46,11 +46,11 @@ _lsof() 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" ) ) - return 0 + return fi _filedir } && complete -F _lsof lsof -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lua b/completions/lua index 83dc7368..9413319e 100644 --- a/completions/lua +++ b/completions/lua @@ -20,4 +20,4 @@ _lua() } && complete -F _lua lua -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/luac b/completions/luac index a0330735..9c91f25a 100644 --- a/completions/luac +++ b/completions/luac @@ -24,4 +24,4 @@ _luac() } && complete -F _luac luac -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/luseradd b/completions/luseradd index e5b00c3c..41769b00 100644 --- a/completions/luseradd +++ b/completions/luseradd @@ -37,4 +37,4 @@ _luseradd() } && complete -F _luseradd luseradd lusermod -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/luserdel b/completions/luserdel index 05faaac2..83e1818b 100644 --- a/completions/luserdel +++ b/completions/luserdel @@ -20,4 +20,4 @@ _luserdel() } && complete -F _luserdel luserdel -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lvm b/completions/lvm index ba0720ed..fb83a3fb 100644 --- a/completions/lvm +++ b/completions/lvm @@ -1,26 +1,38 @@ # bash completion for lvm -*- shell-script -*- +_lvm_filedir() +{ + cur=${cur:-/dev/} + _filedir +} + _lvm_volumegroups() { COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \ - sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) ) + 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" ) ) } _lvm_physicalvolumes() { COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \ - sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur" ) ) + command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur" ) ) } _lvm_logicalvolumes() { COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \ - sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur" ) ) + command sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur" ) ) if [[ $cur == /dev/mapper/* ]]; then _filedir local i for i in ${!COMPREPLY[@]}; do - [[ ${COMPREPLY[i]} == */control ]] && unset COMPREPLY[i] + [[ ${COMPREPLY[i]} == */control ]] && unset 'COMPREPLY[i]' done fi } @@ -85,18 +97,18 @@ _pvs() -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" ) ) - return 0 + return ;; --units) _lvm_units - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi } && complete -F _pvs pvs @@ -109,14 +121,14 @@ _pvdisplay() case $prev in --units) _lvm_units - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi } && complete -F _pvdisplay pvdisplay @@ -129,14 +141,14 @@ _pvchange() case $prev in -A|-x|--autobackup|--allocatable) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi } && complete -F _pvchange pvchange @@ -149,26 +161,26 @@ _pvcreate() case $prev in --restorefile) _filedir - return 0 + return ;; -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) - return 0 + return ;; --metadatacopies) COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) ) - return 0 + return ;; --metadatasize|--setphysicalvolumesize) _lvm_sizes - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_filedir fi } && complete -F _pvcreate pvcreate @@ -181,11 +193,11 @@ _pvmove() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -n|--name) _lvm_logicalvolumes - return 0 + return esac if [[ "$cur" == -* ]]; then @@ -206,7 +218,7 @@ _pvremove() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi } && complete -F _pvremove pvremove @@ -233,11 +245,11 @@ _vgs() 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" ) ) - return 0 + return ;; --units) _lvm_units - return 0 + return ;; esac @@ -257,7 +269,7 @@ _vgdisplay() case $prev in --units) _lvm_units - return 0 + return ;; esac @@ -277,7 +289,7 @@ _vgchange() case $prev in -a|-A|-x|--available|--autobackup|--resizeable) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac @@ -300,15 +312,15 @@ _vgcreate() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) - return 0 + return ;; -s|--physicalextentsize) _lvm_sizes - return 0 + return ;; esac @@ -318,11 +330,11 @@ _vgcreate() --physicalextentsize --test --verbose --version' -- "$cur" ) ) else local args - _lvm_count_args @(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize) + _lvm_count_args '@(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize)' if [[ $args -eq 0 ]]; then _lvm_volumegroups else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi fi } && @@ -349,7 +361,7 @@ _vgrename() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac @@ -369,7 +381,7 @@ _vgreduce() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac @@ -378,7 +390,7 @@ _vgreduce() else local args - _lvm_count_args @(-A|--autobackup) + _lvm_count_args '@(-A|--autobackup)' if [[ $args -eq 0 ]]; then _lvm_volumegroups else @@ -396,11 +408,11 @@ _vgextend() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -L|--size) _lvm_sizes - return 0 + return ;; esac @@ -408,11 +420,11 @@ _vgextend() COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else local args - _lvm_count_args @(-A|--autobackup|-L|--size) + _lvm_count_args '@(-A|--autobackup|-L|--size)' if [[ $args -eq 0 ]]; then _lvm_volumegroups else - _lvm_physicalvolumes + _lvm_physicalvolumes_all fi fi } && @@ -452,15 +464,15 @@ _vgconvert() case $prev in -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) - return 0 + return ;; --metadatacopies) COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) ) - return 0 + return ;; --metadatasize) _lvm_sizes - return 0 + return ;; esac @@ -480,7 +492,7 @@ _vgcfgbackup() case $prev in -f|--file) _filedir - return 0 + return ;; esac @@ -500,15 +512,15 @@ _vgcfgrestore() case $prev in -f|--file) _filedir - return 0 + return ;; -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) - return 0 + return ;; -n|--name) _lvm_volumegroups - return 0 + return ;; esac @@ -528,7 +540,7 @@ _vgmerge() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac @@ -548,11 +560,11 @@ _vgsplit() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) - return 0 + return ;; esac @@ -561,7 +573,7 @@ _vgsplit() --metadatatype --test --verbose --version' -- "$cur" ) ) else local args - _lvm_count_args @(-A|--autobackup|-M|--metadatatype) + _lvm_count_args '@(-A|--autobackup|-M|--metadatatype)' if [[ $args -eq 0 || $args -eq 1 ]]; then _lvm_volumegroups else @@ -605,11 +617,11 @@ _lvs() 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" ) ) - return 0 + return ;; --units) _lvm_units - return 0 + return ;; esac @@ -629,7 +641,7 @@ _lvdisplay() case $prev in --units) _lvm_units - return 0 + return ;; esac @@ -649,11 +661,11 @@ _lvchange() case $prev in -a|-A|-C|-M|--available|--autobackup|--contiguous|--persistent) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -p|--permission) COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) ) - return 0 + return ;; esac @@ -673,19 +685,19 @@ _lvcreate() case $prev in -A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -L|--size) _lvm_sizes - return 0 + return ;; -p|--permission) COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) ) - return 0 + return ;; -n|--name) _lvm_logicalvolumes - return 0 + return ;; esac @@ -693,7 +705,7 @@ _lvcreate() 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) + _lvm_count_args '@(-A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero|-L|--size|-p|--permission|-n|--name)' if [[ $args -eq 0 ]]; then _lvm_volumegroups else @@ -711,7 +723,7 @@ _lvremove() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac @@ -731,7 +743,7 @@ _lvrename() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac @@ -751,11 +763,11 @@ _lvreduce() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -L|--size) _lvm_sizes - return 0 + return ;; esac @@ -775,11 +787,11 @@ _lvresize() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -L|--size) _lvm_sizes - return 0 + return ;; esac @@ -787,7 +799,7 @@ _lvresize() COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else local args - _lvm_count_args @(-A|--autobackup|-L|--size) + _lvm_count_args '@(-A|--autobackup|-L|--size)' if [[ $args -eq 0 ]]; then _lvm_logicalvolumes else @@ -805,11 +817,11 @@ _lvextend() case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -L|--size) _lvm_sizes - return 0 + return ;; esac @@ -817,7 +829,7 @@ _lvextend() COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else local args - _lvm_count_args @(-A|--autobackup|-L|--size) + _lvm_count_args '@(-A|--autobackup|-L|--size)' if [[ $args -eq 0 ]]; then _lvm_logicalvolumes else @@ -841,118 +853,17 @@ _lvm() vgimport vgmerge vgmknodes vgreduce vgremove vgrename vgs vgscan vgsplit version' -- "$cur" ) ) else - case ${words[1]} in - pvchange) - _pvchange - ;; - pvcreate) - _pvcreate - ;; - pvdisplay) - _pvdisplay - ;; - pvmove) - _pvmove - ;; - pvremove) - _pvremove - ;; - pvresize) - _pvresize - ;; - pvs) - _pvs - ;; - pvscan) - _pvscan - ;; - vgcfgbackup) - _vgcfgbackup - ;; - vgcfgrestore) - _vgcfgrestore - ;; - vgchange) - _vgchange - ;; - vgck) - _vgck - ;; - vgconvert) - _vgconvert - ;; - vgcreate) - _vgcreate - ;; - vgdisplay) - _vgdisplay - ;; - vgexport) - _vgexport - ;; - vgextend) - _vgextend - ;; - vgimport) - _vgimport - ;; - vgmerge) - _vgmerge - ;; - vgmknodes) - _vgmknodes - ;; - vgreduce) - _vgreduce - ;; - vgremove) - _vgremove - ;; - vgrename) - _vgrename - ;; - vgs) - _vgs - ;; - vgscan) - _vgscan - ;; - vgsplit) - _vgsplit - ;; - lvchange) - _lvchange - ;; - lvcreate) - _lvcreate - ;; - lvdisplay) - _lvdisplay - ;; - lvextend) - _lvextend - ;; - lvreduce) - _lvreduce - ;; - lvremove) - _lvremove - ;; - lvrename) - _lvrename - ;; - lvresize) - _lvresize - ;; - lvs) - _lvs - ;; - lvscan) - _lvscan + case "${words[1]}" in + pvchange|pvcreate|pvdisplay|pvmove|pvremove|pvresize|pvs|pvscan|\ + vgcfgbackup|vgcfgrestore|vgchange|vgck|vgconvert|vgcreate|\ + vgdisplay|vgexport|vgextend|vgimport|vgmerge|vgmknodes|vgreduce|\ + vgremove|vgrename|vgs|vgscan|vgsplit|lvchange|lvcreate|lvdisplay|\ + lvextend|lvreduce|lvremove|lvrename|lvresize|lvscan) + _${words[1]} ;; esac fi } && complete -F _lvm lvm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lz4 b/completions/lz4 new file mode 100644 index 00000000..56602ca2 --- /dev/null +++ b/completions/lz4 @@ -0,0 +1,53 @@ +# lz4 completion -*- shell-script -*- + +_lz4() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -b) + _filedir + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W \ + '$( _parse_help "$1" -h | command sed -e "/#/d" ) -B{4..7} -i{1..9}' \ + -- "$cur" ) ) + return + fi + + local args word xspec="*.?(t)lz4" + _count_args + [[ $args -gt 2 ]] && return + + for word in ${words[@]}; do + case $word in + -*[dt]*) + case $args in + 1) xspec="!"$xspec ;; + 2) [[ $word == *t* ]] && return + esac + break + ;; + -z) + case $args in + 1) xspec= ;; + 2) xspec="!"$xspec ;; + esac + break + ;; + esac + done + + _expand || return + local IFS=$'\n' + compopt -o filenames + COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ + $( compgen -d -- "$cur" ) ) +} && +complete -F _lz4 lz4 lz4c + +# ex: filetype=sh diff --git a/completions/lzip b/completions/lzip index ae35b9d4..c1aab4a8 100644 --- a/completions/lzip +++ b/completions/lzip @@ -46,4 +46,4 @@ _lzip() } && complete -F _lzip clzip lzip pdlzip plzip -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lzma b/completions/lzma index 30566ed0..74dac25c 100644 --- a/completions/lzma +++ b/completions/lzma @@ -11,22 +11,20 @@ _lzma() --help --decompress --compress --keep --force --suffix --test --stdout --quiet --verbose --license --list --version --small --fast --best --text' -- "$cur" ) ) - return 0 + return fi local IFS=$'\n' xspec="*.@(lzma|tlz)" if [[ "$prev" == --* ]]; then - [[ "$prev" == --decompress || \ - "$prev" == --list || \ - "$prev" == --test ]] && xspec="!"$xspec + [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec [[ "$prev" == --compress ]] && xspec= elif [[ "$prev" == -* ]]; then [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec [[ "$prev" == -*z* ]] && xspec= fi - _expand || return 0 + _expand || return compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ @@ -34,4 +32,4 @@ _lzma() } && complete -F _lzma lzma -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/lzop b/completions/lzop index e23d5410..f6753529 100644 --- a/completions/lzop +++ b/completions/lzop @@ -8,14 +8,14 @@ _lzop() case $prev in -o|--output) _filedir - return 0 + return ;; --path) _filedir -d - return 0 + return ;; -S|--suffix) - return 0 + return ;; esac @@ -27,7 +27,7 @@ _lzop() --keep --delete --crc32 --no-warn --ignore-warn --quiet --verbose --no-stdin --filter --checksum --no-color --mono --color' \ -- "$cur" ) ) - return 0 + return fi local xspec="*.?(t)lzo" @@ -48,7 +48,7 @@ _lzop() ;; esac - _expand || return 0 + _expand || return local IFS=$'\n' compopt -o filenames @@ -57,4 +57,4 @@ _lzop() } && complete -F _lzop lzop -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/macof b/completions/macof index 264f1c9d..dacae2fd 100644 --- a/completions/macof +++ b/completions/macof @@ -8,7 +8,7 @@ _macof() case $prev in -i) _available_interfaces -a - return 0 + return ;; esac @@ -20,4 +20,4 @@ _macof() } && complete -F _macof macof -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mailmanctl b/completions/mailmanctl index 5e6ed2ee..717df7b9 100644 --- a/completions/mailmanctl +++ b/completions/mailmanctl @@ -15,4 +15,4 @@ _mailmanctl() } && complete -F _mailmanctl mailmanctl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/make b/completions/make index b4ad9e73..1075b37a 100644 --- a/completions/make +++ b/completions/make @@ -1,13 +1,12 @@ # bash completion for GNU make -*- shell-script -*- -function _make_target_extract_script() +_make_target_extract_script() { local mode="$1" shift local prefix="$1" - local prefix_pat=$( printf "%s\n" "$prefix" | \ - sed 's/[][\,.*^$(){}?+|/]/\\&/g' ) + local prefix_pat=$( command sed 's/[][\,.*^$(){}?+|/]/\\&/g' <<<"$prefix" ) local basename=${prefix##*/} local dirname_len=$(( ${#prefix} - ${#basename} )) @@ -20,51 +19,63 @@ function _make_target_extract_script() fi cat <<EOF - /^# Make data base/,/^# Files/d # skip until files section - /^# Not a target/,/^$/ d # skip not target blocks - /^${prefix_pat}/,/^$/! d # skip anything user dont want + 1,/^# * Make data base/ d; # skip any makefile output + /^# * Finished Make data base/,/^# * Make data base/{ + d; # skip any makefile output + } + /^# * Variables/,/^# * Files/ d; # skip until files section + /^# * Not a target/,/^$/ d; # skip not target blocks + /^${prefix_pat}/,/^$/! d; # skip anything user dont want # The stuff above here describes lines that are not # explicit targets or not targets other than special ones # The stuff below here decides whether an explicit target # should be output. - /^# File is an intermediate prerequisite/ { - s/^.*$//;x # unhold target - d # delete line + /^# * File is an intermediate prerequisite/ { + s/^.*$//;x; # unhold target + d; # delete line } /^$/ { # end of target block - x # unhold target - /^$/d # dont print blanks - s,^(.{${dirname_len}})(.{${#basename}}[^:/]*/?)[^:]*:.*$,${output},p - d # hide any bugs + x; # unhold target + /^$/d; # dont print blanks + s|^\(.\{${dirname_len}\}\)\(.\{${#basename}\}[^:/]*/\{0,1\}\)[^:]*:.*$|${output}|p; + d; # hide any bugs } - /^[^#\t:%]+:/ { # found target block - - /^\.PHONY:/ d # special target - /^\.SUFFIXES:/ d # special target - /^\.DEFAULT:/ d # special target - /^\.PRECIOUS:/ d # special target - /^\.INTERMEDIATE:/ d # special target - /^\.SECONDARY:/ d # special target - /^\.SECONDEXPANSION:/ d # special target - /^\.DELETE_ON_ERROR:/ d # special target - /^\.IGNORE:/ d # special target - /^\.LOW_RESOLUTION_TIME:/ d # special target - /^\.SILENT:/ d # special target - /^\.EXPORT_ALL_VARIABLES:/ d # special target - /^\.NOTPARALLEL:/ d # special target - /^\.ONESHELL:/ d # special target - /^\.POSIX:/ d # special target - /^\.NOEXPORT:/ d # special target - /^\.MAKE:/ d # special target - - /^[^a-zA-Z0-9]/ d # convention for hidden tgt - - h # hold target - d # delete line + # This pattern includes a literal tab character as \t is not a portable + # representation and fails with BSD sed + /^[^# :%]\{1,\}:/ { # found target block + /^\.PHONY:/ d; # special target + /^\.SUFFIXES:/ d; # special target + /^\.DEFAULT:/ d; # special target + /^\.PRECIOUS:/ d; # special target + /^\.INTERMEDIATE:/ d; # special target + /^\.SECONDARY:/ d; # special target + /^\.SECONDEXPANSION:/ d; # special target + /^\.DELETE_ON_ERROR:/ d; # special target + /^\.IGNORE:/ d; # special target + /^\.LOW_RESOLUTION_TIME:/ d; # special target + /^\.SILENT:/ d; # special target + /^\.EXPORT_ALL_VARIABLES:/ d; # special target + /^\.NOTPARALLEL:/ d; # special target + /^\.ONESHELL:/ d; # special target + /^\.POSIX:/ d; # special target + /^\.NOEXPORT:/ d; # special target + /^\.MAKE:/ d; # special target +EOF + + # don't complete with hidden targets unless we are doing a partial completion + if [[ -z "${prefix_pat}" || "${prefix_pat}" = */ ]]; then + cat <<EOF + /^${prefix_pat}[^a-zA-Z0-9]/d; # convention for hidden tgt +EOF + fi + + cat <<EOF + h; # hold target + d; # delete line } EOF @@ -81,26 +92,26 @@ _make() -f|--file|--makefile|-o|--old-file|--assume-old|-W|--what-if|\ --new-file|--assume-new) _filedir - return 0 + return ;; -I|--include-dir|-C|--directory|-m) _filedir -d - return 0 + return ;; -E) COMPREPLY=( $( compgen -v -- "$cur" ) ) - return 0 + return ;; --eval|-D|-V|-x) - return 0 + return ;; --jobs|-j) COMPREPLY=( $( compgen -W "{1..$(( $(_ncpus)*2 ))}" -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then local opts="$( _parse_help "$1" )" @@ -141,10 +152,11 @@ _make() mode=-d # display-only mode fi - local reset=$( set +o | grep -F posix ); set +o posix # for <(...) + local reset=$( shopt -po posix ); set +o posix # <(...) COMPREPLY=( $( LC_ALL=C \ - make -npq "${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null | \ - sed -nrf <(_make_target_extract_script $mode "$cur") ) ) + $1 -npq __BASH_MAKE_COMPLETION__=1 \ + "${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null | \ + command sed -nf <(_make_target_extract_script $mode "$cur") ) ) $reset if [[ $mode != -d ]]; then @@ -157,4 +169,4 @@ _make() } && complete -F _make make gmake gnumake pmake colormake -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/makepkg b/completions/makepkg index 3aa836e5..84b4af79 100644 --- a/completions/makepkg +++ b/completions/makepkg @@ -8,17 +8,18 @@ _makepkg() case "$prev" in -l|--linkadd|-c|--chown) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-l --linkadd -p --prepend -c --chown' \ -- "$cur" ) ) - return 0 + return fi _filedir -} && complete -F _makepkg makepkg +} && +complete -F _makepkg makepkg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/man b/completions/man index 6e42f85f..a00ac7a0 100644 --- a/completions/man +++ b/completions/man @@ -1,8 +1,5 @@ # man(1) completion -*- shell-script -*- -[[ $OSTYPE == *@(darwin|freebsd|solaris|cygwin|openbsd)* ]] || _userland GNU \ - || return 1 - _man() { local cur prev words cword split @@ -48,25 +45,18 @@ _man() return fi - _expand || return 0 + _expand || return # file based completion if parameter looks like a path if [[ "$cur" == @(*/|[.~])* ]]; then _filedir "$manext" - return 0 - fi - - local manpath - if [[ $OSTYPE == *@(darwin|linux|freebsd|cygwin)* ]] || _userland GNU; then - manpath=$( manpath 2>/dev/null || command man --path ) - else - manpath=$MANPATH + return fi - if [[ -z $manpath ]]; then - COMPREPLY=( $( compgen -c -- "$cur" ) ) - return 0 - fi + local manpath="$MANPATH" + [[ -z $manpath ]] && \ + 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 local sect @@ -98,8 +88,7 @@ _man() fi __ltrim_colon_completions "$cur" - return 0 } && complete -F _man man apropos whatis -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mc b/completions/mc index f3065793..dc322a15 100644 --- a/completions/mc +++ b/completions/mc @@ -8,19 +8,19 @@ _mc() case $prev in -e|--edit|-v|--view|-l|--ftplog|-P|--printwd) _filedir - return 0 + return ;; -C|--colors|-D|--debuglevel) # argument required but no completions available - return 0 + return ;; -h|--help|--help-*|-V|--version) # all other arguments are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ @@ -32,4 +32,4 @@ _mc() } && complete -F _mc mc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mcrypt b/completions/mcrypt index 8c7d189c..6d6a898f 100644 --- a/completions/mcrypt +++ b/completions/mcrypt @@ -9,39 +9,38 @@ _mcrypt() case $prev in -g|--openpgp-z) COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) ) - return 0 + return ;; -o|--keymode) - COMPREPLY=( $( compgen -W '$( mcrypt --list-keymodes \ + COMPREPLY=( $( compgen -W '$( $1 --list-keymodes \ 2>/dev/null )' -- "$cur" ) ) - return 0 + return ;; -m|--mode) - COMPREPLY=( $( compgen -W "$( mcrypt --list \ - 2>/dev/null | sed -e 's/.*: //' -e 's/ $//' | \ - sort -u )" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "$( $1 --list 2>/dev/null | \ + cut -d: -f2- )" -- "$cur" ) ) + return ;; -a|--algorithm) - COMPREPLY=( $( compgen -W "$( mcrypt --list 2>/dev/null | \ + COMPREPLY=( $( compgen -W "$( $1 --list 2>/dev/null | \ awk '{print $1}' )" -- "$cur" ) ) - return 0 + return ;; -h|--hash) - COMPREPLY=( $( compgen -W '$( mcrypt --list-hash 2>/dev/null | \ - sed -e 1d )' -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W '$( $1 --list-hash 2>/dev/null | \ + command sed -e 1d )' -- "$cur" ) ) + return ;; -k|-s|--key|--keysize) - return 0 + return ;; -f|-c|--keyfile|--config) _filedir - return 0 + return ;; --algorithms-directory|--modes-directory) _filedir -d - return 0 + return ;; esac @@ -65,4 +64,4 @@ _mcrypt() } && complete -F _mcrypt mcrypt mdecrypt -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mdadm b/completions/mdadm index 111a2c35..d19e89d2 100644 --- a/completions/mdadm +++ b/completions/mdadm @@ -76,27 +76,27 @@ _mdadm() case $prev in -c|--config|-b|--bitmap|--backup-file) _filedir - return 0 + return ;; -l|--level) _mdadm_raid_level - return 0 + return ;; -p|--layout|--parity) _mdadm_raid_layout - return 0 + return ;; -a|--auto) _mdadm_auto_flag - return 0 + return ;; -U|--update) _mdadm_update_flag - return 0 + return ;; esac - $split && return 0 + $split && return local options='--help --help-options --version --verbose --quiet --brief --force --config= --scan --metadata= --homehost=' @@ -147,4 +147,4 @@ _mdadm() } && complete -F _mdadm mdadm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mdtool b/completions/mdtool index 879dabf6..b4f36e56 100644 --- a/completions/mdtool +++ b/completions/mdtool @@ -29,7 +29,7 @@ _mdtool() # ;; # esac #fi - return 0 + return ;; "generate-makefiles") compopt -o filenames @@ -38,7 +38,7 @@ _mdtool() COMPREPLY=( $( compgen -W '--simple-makefiles --s --d:' \ -- "$cur" ) ) fi - return 0 + return ;; "setup") # TODO: at least return filenames after these options. @@ -47,7 +47,7 @@ _mdtool() 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" ) ) - return 0 + return ;; esac fi @@ -55,8 +55,7 @@ _mdtool() COMPREPLY=( $( compgen -W 'gsetup build dbgen project-export generate-makefiles gettext-update setup -q' -- "$cur" ) ) - return 0 } && complete -F _mdtool mdtool -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/medusa b/completions/medusa index 84a03813..697cafea 100644 --- a/completions/medusa +++ b/completions/medusa @@ -8,16 +8,16 @@ _medusa() case $prev in -h) _known_hosts_real "$cur" - return 0 + return ;; -H|-U|-P|-C|-O) _filedir - return 0 + return ;; -M) - COMPREPLY=( $( compgen -W "$(medusa -d | awk '/^ +\+/ {print $2}' \ - | sed -e 's/\.mod$//')" ) ) - return 0 + COMPREPLY=( $( compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' \ + | command sed -e 's/\.mod$//')" ) ) + return ;; esac @@ -27,4 +27,4 @@ _medusa() } && complete -F _medusa medusa -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mii-diag b/completions/mii-diag index 2743d9d0..87f5d8d5 100644 --- a/completions/mii-diag +++ b/completions/mii-diag @@ -9,11 +9,11 @@ _mii_diag() -F|-A|--advertise|--fixed-speed) COMPREPLY=( $( compgen -W '100baseT4 100baseTx 100baseTx-FD 100baseTx-HD 10baseT 10baseT-FD 10baseT-HD' -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -23,4 +23,4 @@ _mii_diag() } && complete -F _mii_diag -o default mii-diag -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mii-tool b/completions/mii-tool index facebe4a..3c5f9b45 100644 --- a/completions/mii-tool +++ b/completions/mii-tool @@ -9,16 +9,16 @@ _mii_tool() -F|--force) COMPREPLY=( $( compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD' -- "$cur" ) ) - return 0 + return ;; -A|--advertise) COMPREPLY=( $( compgen -W '100baseT4 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD' -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -29,4 +29,4 @@ _mii_tool() } && complete -F _mii_tool -o default mii-tool -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/minicom b/completions/minicom index d168ce44..897475ed 100644 --- a/completions/minicom +++ b/completions/minicom @@ -8,17 +8,17 @@ _minicom() case $prev in -a|-c) COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) - return 0 + return ;; -S|-C) _filedir - return 0 + return ;; -P) COMPREPLY=( $( printf '%s\n' /dev/tty* ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \ -- "$cur" ) ) - return 0 + return ;; esac @@ -26,19 +26,14 @@ _minicom() 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" ) ) - return 0 - else - local confdir - [[ -n $( command ls /etc/minirc.* 2>/dev/null ) ]] && confdir=/etc - [[ -n $( command ls /etc/minicom/minirc.* 2>/dev/null ) ]] \ - && confdir=/etc/minicom - if [[ -n $confdir ]]; then - COMPREPLY=( $( compgen -W '$( printf "%s\n" $confdir/minirc.* | \ - sed -e "s|$confdir/minirc.||")' -- "$cur" ) ) - return 0 - fi + return fi + + COMPREPLY=( + $( printf '%s\n' /etc/minirc.* /etc/minicom/minirc.* ~/.minirc.* \ + | command sed -e '/\*$/d' -e 's/^.*minirc\.//' \ + | command grep "^${cur}" ) ) } && complete -F _minicom -o default minicom -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mkinitrd b/completions/mkinitrd index c54f22a2..f0efb294 100644 --- a/completions/mkinitrd +++ b/completions/mkinitrd @@ -8,19 +8,19 @@ _mkinitrd() case $prev in --preload|--with|--builtin) _modules - return 0 + return ;; --fstab|--dsdt) _filedir - return 0 + return ;; --net-dev) _available_interfaces - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--version --help -v -f --preload \ @@ -47,4 +47,4 @@ _mkinitrd() } && complete -F _mkinitrd mkinitrd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mktemp b/completions/mktemp index 3871e708..a8903c16 100644 --- a/completions/mktemp +++ b/completions/mktemp @@ -7,15 +7,15 @@ _mktemp() case "$prev" in --help|--version|--suffix) - return 0 + return ;; --tmpdir|-p) _filedir -d - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then local opts=$( _parse_help "$1" ) @@ -26,4 +26,4 @@ _mktemp() } && complete -F _mktemp mktemp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mmsitepass b/completions/mmsitepass index 71fc8b09..db1cbf74 100644 --- a/completions/mmsitepass +++ b/completions/mmsitepass @@ -12,4 +12,4 @@ _mmsitepass() } && complete -F _mmsitepass mmsitepass -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/modinfo b/completions/modinfo index f0016843..28f19308 100644 --- a/completions/modinfo +++ b/completions/modinfo @@ -41,4 +41,4 @@ _modinfo() } && complete -F _modinfo modinfo -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/modprobe b/completions/modprobe index b59e4dca..43a2b01b 100644 --- a/completions/modprobe +++ b/completions/modprobe @@ -2,10 +2,13 @@ _modprobe() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return case "$prev" in + -h|--help|-V|--version) + return + ;; -C|--config) _filedir return @@ -20,13 +23,20 @@ _modprobe() ;; esac + $split && return + if [[ "$cur" == -* ]]; then - 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" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + if [[ ! $COMPREPLY ]]; then + 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" ) ) + fi + [[ $COMPREPLY == *= ]] && compopt -o nospace return fi @@ -74,7 +84,8 @@ _modprobe() elif [[ -n "$module" ]]; then # do module parameter completion COMPREPLY=( $( compgen -W "$( PATH="$PATH:/sbin" modinfo \ - -p "$module" 2>/dev/null | cut -d: -f1 )" -- "$cur" ) ) + -p "$module" 2>/dev/null | \ + awk -F: '!/^[ \t]/ { print $1 }' )" -- "$cur" ) ) else _modules $version if [[ $COMPREPLY ]]; then @@ -84,7 +95,7 @@ _modprobe() for i in ${!mods[@]}; do for module in ${COMPREPLY[@]}; do if [[ ${mods[i]} == $module ]]; then - unset mods[i] + unset 'mods[i]' break fi done @@ -97,4 +108,4 @@ _modprobe() } && complete -F _modprobe modprobe -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/monodevelop b/completions/monodevelop index 9102b8bb..13685dfb 100644 --- a/completions/monodevelop +++ b/completions/monodevelop @@ -13,8 +13,7 @@ _monodevelop() else _filedir fi - return 0 } && complete -F _monodevelop monodevelop -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mount b/completions/mount index 6818ac39..a8748d1b 100644 --- a/completions/mount +++ b/completions/mount @@ -21,7 +21,7 @@ _mount() case $prev in -t|--types) _fstypes - return 0 + return ;; esac @@ -32,7 +32,7 @@ _mount() [[ -x $sm ]] || continue COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \ awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) ) - return 0 + return done fi @@ -42,8 +42,8 @@ _mount() if [[ -n $host ]]; then COMPREPLY=( $( compgen -P "//$host" -W \ "$( smbclient -d 0 -NL $host 2>/dev/null | - sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' | - sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" \ + 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 @@ -51,7 +51,7 @@ _mount() COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- "$cur" ) ) elif [[ ! -e /etc/fstab ]]; then # probably Cygwin - COMPREPLY=( $( compgen -W "$( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" ) ) + 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" ) ) @@ -59,4 +59,4 @@ _mount() } && complete -F _mount -o default -o dirnames mount -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mount.linux b/completions/mount.linux index ddb9180e..ed198ad8 100644 --- a/completions/mount.linux +++ b/completions/mount.linux @@ -222,7 +222,7 @@ _mount() [[ -x $sm ]] || continue COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \ awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) ) - return 0 + return done fi @@ -232,8 +232,8 @@ _mount() if [[ -n $host ]]; then COMPREPLY=( $( compgen -P "//$host" -W \ "$( smbclient -d 0 -NL $host 2>/dev/null | - sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' | - sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" \ + command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | + command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p' )" \ -- "${cur#//$host}" ) ) fi fi @@ -242,4 +242,4 @@ _mount() } && complete -F _mount mount -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mplayer b/completions/mplayer index 88e9dc7d..ab08b9a9 100644 --- a/completions/mplayer +++ b/completions/mplayer @@ -4,8 +4,8 @@ _mplayer_options_list() { cur=${cur%\\} COMPREPLY=( $( compgen -W "$( $1 -nomsgcolor -nomsgmodule $2 help 2>/dev/null | \ - sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' | \ - sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' )" -- "$cur" ) ) + command sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' | \ + command sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' )" -- "$cur" ) ) } _mplayer() @@ -19,15 +19,15 @@ _mplayer() -[av][cfo]|-[av]fm|-vop|-fstype|-demuxer|-o[av]c|-of|-profile| \ -audio-demuxer|-sub-demuxer) _mplayer_options_list $cmd $prev - return 0 + return ;; -show-profile) _mplayer_options_list $cmd -profile - return 0 + return ;; - -audiofile) - _filedir '@(mp3|mpg|ogg|w?(a)v|mid|flac|mka|ape)' - return 0 + -audiofile|-audio-file) + _filedir '@(mp3|mpg|ogg|w?(a)v|mid|flac|mka|ac3|ape)' + return ;; -font|-subfont) if [[ $prev == -font ]]; then @@ -37,11 +37,11 @@ _mplayer() fi local IFS=$'\n' COMPREPLY+=( $( compgen -W '$( fc-list 2>/dev/null )' -- "$cur" ) ) - return 0 + return ;; - -sub) + -sub|-sub-file) _filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)' - return 0 + return ;; -vobsub) _filedir '@(idx|ifo|sub)' @@ -52,26 +52,26 @@ _mplayer() else printf '%s\n' $i fi - done ) ) - return 0 + done ) ) + return ;; -subcp|-msgcharset) local cp - cp=( $( iconv --list 2>/dev/null | 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" ) ) else COMPREPLY=( $( compgen -W '${cp[@]^^}' -- "$cur" ) ) fi - return 0 + return ;; -ifo) _filedir ifo - return 0 + return ;; -cuefile) _filedir '@(bin|cue)' - return 0 + return ;; -skin) # if you don't have installed mplayer in /usr you @@ -86,37 +86,38 @@ _mplayer() local IFS=$'\n' for i in ~/.mplayer/skins ${dirs[@]}; do if [[ -d $i && -r $i ]]; then - for j in $( compgen -d $i/$cur ); do + for j in $( compgen -d -- $i/$cur ); do COMPREPLY[$k]=${j#$i/} k=$((++k)) done fi done - return 0 + return ;; -cdrom-device) _cd_devices _dvd_devices - return 0 + return ;; -dvd-device) - _filedir - return 0 + _dvd_devices + _filedir iso + return ;; -bluray-device) _filedir -d - return 0 + return ;; -mixer|-dvdauth|-fb|-zrdev) cur=${cur:=/dev/} _filedir - return 0 + return ;; -edl|-edlout|-lircconf|-menu-cfg|-playlist|-csslib|-dumpfile| \ -subfile|-vobsub|-aofile|-fbmodeconfig|-include|-o|-dvdkey| \ -passlogfile) _filedir - return 0 + return ;; -autoq|-autosync|-loop|-menu-root|-speed|-sstep|-aid|-alang| \ -bandwidth|-bluray-angle|-bluray-chapter|-cache|-chapter|-dvd-speed| \ @@ -134,23 +135,23 @@ _mplayer() -subalign|-subwidth|-subfont-blur|-subfont-outline| \ -subfont-autoscale|-subfont-encoding|-subfont-osd-scale| \ -subfont-text-scale) - return 0 + return ;; -channels) COMPREPLY=( $( compgen -W '2 4 6 8' -- "$cur" ) ) - return 0 + 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" ) ) __ltrim_colon_completions "$cur" - return 0 + return ;; -lavdopts) COMPREPLY=( $( compgen -W 'bitexact bug= debug= ec= er= fast gray idct= lowres= sb= st= skiploopfilter= skipidct= skipframe= threads= vismv= vstats' -- "$cur" ) ) - return 0 + return ;; -lavcopts) COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= @@ -163,21 +164,21 @@ _mplayer() scplx_mask= naq ildct format= pred qpel precmp= cmp= subcmp= predia= dia= trell last_pred= preme= subq= psnr mpeg_quant aic umv' -- "$cur" ) ) - return 0 + return ;; -ssf) COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= cvs=' \ -- "$cur" ) ) - return 0 + return ;; -jpeg) COMPREPLY=( $( compgen -W 'noprogressive progressive nobaseline baseline optimize= smooth= quality= outdir=' -- "$cur" ) ) - return 0 + return ;; -xvidopts) COMPREPLY=( $( compgen -W 'dr2 nodr2' -- "$cur" ) ) - return 0 + return ;; -xvidencopts) COMPREPLY=( $( compgen -W 'pass= bitrate= fixed_quant= me_quality= @@ -185,38 +186,38 @@ _mplayer() quant_range= min_key_interval= max_key_interval= mpeg_quant mod_quant lumi_mask hintedme hintfile debug keyframe_boost= kfthreshold= kfreduction=' -- "$cur" ) ) - return 0 + return ;; -divx4opts) COMPREPLY=( $( compgen -W 'br= key= deinterlace q= min_quant= max_quant= rc_period= rc_reaction_period= crispness= rc_reaction_ratio= pass= vbrpass= help' -- "$cur" ) ) - return 0 + return ;; -info) COMPREPLY=( $( compgen -W 'name= artist= genre= subject= copyright= srcform= comment= help' -- "$cur" ) ) - return 0 + return ;; -lameopts) COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= ratio= vol= mode= padding= fast preset= help' -- "$cur" ) ) - return 0 + return ;; -rawaudio) COMPREPLY=( $( compgen -W 'on channels= rate= samplesize= format=' \ -- "$cur" ) ) - return 0 + return ;; -rawvideo) COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w= h= y420 yv12 yuy2 y8 format= size=' -- "$cur" ) ) - return 0 + return ;; -aop) COMPREPLY=( $( compgen -W 'list= delay= format= fout= volume= mul= softclip' -- "$cur" ) ) - return 0 + return ;; -dxr2) COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded iec958-decoded @@ -225,7 +226,7 @@ _mplayer() 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" ) ) - return 0 + return ;; -tv) COMPREPLY=( $( compgen -W 'on noaudio driver= device= input= freq= @@ -233,30 +234,30 @@ _mplayer() audiorate= forceaudio alsa amode= forcechan= adevice= audioid= volume= bass= treble= balance= fps= channels= immediatemode=' \ -- "$cur" ) ) - return 0 + return ;; -mf) COMPREPLY=( $( compgen -W 'on w= h= fps= type=' -- "$cur" ) ) - return 0 + return ;; -cdda) COMPREPLY=( $( compgen -W 'speed= paranoia= generic-dev= sector-size= overlap= toc-bias toc-offset= skip noskip' \ -- "$cur" ) ) - return 0 + return ;; -input) COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate keylist cmdlist js-dev file' -- "$cur" ) ) - return 0 + return ;; -af-adv) COMPREPLY=( $( compgen -W 'force= list=' -- "$cur" ) ) - return 0 + return ;; -noconfig) COMPREPLY=( $( compgen -W 'all gui system user' -- "$cur" ) ) - return 0 + return ;; -*) # Assume arg is required for everything else except options @@ -267,24 +268,23 @@ _mplayer() [[ ${j,,} != @(flag|print) ]] && return 1 break fi - done || return 0 + done || return ;; esac case $cur in -*) COMPREPLY=( $( compgen -W '$( $cmd -nomsgcolor -nomsgmodule -list-options 2>/dev/null | \ - sed -ne '1,/^[[:space:]]*Name/d' \ + command sed -ne '1,/^[[:space:]]*Name/d' \ -e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \ -e "/^-\(Total\|.*\*\)\{0,1\}$/!p" )' -- "$cur" ) ) ;; *) - _filedir '@(mp?(e)g|MP?(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]|m4[av]|M4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m[24]v|M[24]V|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)|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|webm|WEBM|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)?(.part)' ;; esac - return 0 } && complete -F _mplayer mplayer mplayer2 mencoder gmplayer kplayer -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mr b/completions/mr new file mode 100644 index 00000000..9229e309 --- /dev/null +++ b/completions/mr @@ -0,0 +1,86 @@ +# mr completion -*- shell-script -*- + +_mr() { + local cur prev words cword + _init_completion || return + + local help commands options + + help="$(PERLDOC_PAGER=cat PERLDOC=-otext "${1}" help 2>/dev/null)" + + commands="$(awk '/\[options\]/ { print $3 }' <<<"${help}")" + # Split [online|offline] and remove `action` placeholder. + commands="${commands//@(action|[\[\|\]])/$'\n'}" + # Add standard aliases. + commands="${commands} ci co ls" + + # Determine if user has entered an `mr` command. Used to block top-level + # (option and command) completions. + local cmd i + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ $commands == *"${words[i]}"* ]]; then + cmd="${words[i]}" + break + fi + done + + # Complete options for specific commands. + if [[ -n $cmd ]]; then + case $cmd in + bootstrap) + _filedir + # Also complete stdin (-) as a potential bootstrap source. + if [[ -z "${cur}" || $cur == - ]] && [[ $prev != - ]]; then + COMPREPLY+=( - ) + fi + return + ;; + clean) + if [[ "${cur}" == -* ]]; then + COMPREPLY=( $( compgen -W '-f' -- "${cur}" ) ) + fi + return + ;; + commit|ci|record) + if [[ "${cur}" == -* ]]; then + COMPREPLY=( $( compgen -W '-m' -- "${cur}" ) ) + fi + return + ;; + run) + COMPREPLY=( $( compgen -c -- "${cur}" ) ) + return + ;; + *) + # Do not complete any other command. + return + ;; + esac + fi + + # Complete top-level options and commands. + case $prev in + -c|--config) + _filedir + return + ;; + -d|--directory) + _filedir -d + return + ;; + esac + + if [[ $cur == -* ]]; then + options="$(_parse_help - <<<"${help}")" + # Remove short options (all have compatible long options). + options="${options//-[a-z]$'\n'/}" + # Remove deprecated options. + options="${options//--path/}" + COMPREPLY=( $( compgen -W "${options}" -- "${cur}" ) ) + else + COMPREPLY=( $( compgen -W "${commands}" -- "${cur}" ) ) + fi +} && +complete -F _mr mr + +# ex: filetype=sh diff --git a/completions/msynctool b/completions/msynctool index 28a0163a..3eae1dfa 100644 --- a/completions/msynctool +++ b/completions/msynctool @@ -7,28 +7,28 @@ _msynctool() case $words in --configure) - COMPREPLY=( $( compgen -W "$(msynctool --showgroup \ - $prev | awk '/^Member/ {print $2}' | sed \ + COMPREPLY=( $( compgen -W "$($1 --showgroup \ + $prev | awk '/^Member/ {print $2}' | command sed \ -e 's/:$//' )" -- "$cur" ) ) - return 0 + return ;; --addmember) - COMPREPLY=( $( compgen -W '$(msynctool --listplugins \ - | sed -e '1d' )' -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W '$($1 --listplugins \ + | command sed -e '1d' )' -- "$cur" ) ) + return ;; esac case $prev in --configure|--addgroup|--delgroup|--showgroup|--sync|--addmember) - COMPREPLY=( $( compgen -W '$(msynctool --listgroups \ - | sed -e '1d' )' -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W '$($1 --listgroups \ + | command sed -e '1d' )' -- "$cur" ) ) + return ;; --showformats|--filter-objtype|--slow-sync) - COMPREPLY=( $( compgen -W '$(msynctool --listobjects \ - | sed -e '1d' )' -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W '$($1 --listobjects \ + | command sed -e '1d' )' -- "$cur" ) ) + return ;; esac @@ -39,4 +39,4 @@ _msynctool() } && complete -F _msynctool msynctool -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mtx b/completions/mtx index 0cb63251..c52c6173 100644 --- a/completions/mtx +++ b/completions/mtx @@ -38,8 +38,7 @@ _mtx() else COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) fi - return 0 } && complete -F _mtx mtx -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/munin-node-configure b/completions/munin-node-configure index 7f1d5a59..82815a6e 100644 --- a/completions/munin-node-configure +++ b/completions/munin-node-configure @@ -8,19 +8,19 @@ _munin_node_configure() case $prev in --config) _filedir - return 0 + return ;; --servicedir|--libdir) _filedir -d - return 0 + return ;; --snmp) _known_hosts_real "$cur" - return 0 + return ;; --snmpversion) COMPREPLY=( $( compgen -W '1 2c 3' -- "$cur" ) ) - return 0 + return ;; esac @@ -30,4 +30,4 @@ _munin_node_configure() } && complete -F _munin_node_configure munin-node-configure -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/munin-run b/completions/munin-run index 756a0e0a..72228522 100644 --- a/completions/munin-run +++ b/completions/munin-run @@ -8,11 +8,11 @@ _munin_run() case $prev in --config|--sconffile) _filedir - return 0 + return ;; --servicedir|--sconfdir) _filedir -d - return 0 + return ;; esac @@ -25,4 +25,4 @@ _munin_run() } && complete -F _munin_run munin-run -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/munin-update b/completions/munin-update index c035ec7b..8889a94d 100644 --- a/completions/munin-update +++ b/completions/munin-update @@ -8,11 +8,11 @@ _munin_update() case $prev in --config) _filedir - return 0 + return ;; --host) _known_hosts_real "$cur" - return 0 + return ;; esac @@ -24,4 +24,4 @@ _munin_update() } && complete -F _munin_update munin-update -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/munindoc b/completions/munindoc index c5a03c1c..f603d87b 100644 --- a/completions/munindoc +++ b/completions/munindoc @@ -10,4 +10,4 @@ _munindoc() } && complete -F _munindoc munindoc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mussh b/completions/mussh index a7bf2997..2e9842b6 100644 --- a/completions/mussh +++ b/completions/mussh @@ -42,11 +42,11 @@ _mussh() COMPREPLY+=( $( compgen -c -- "$cur" ) ) return ;; - esac + esac - [[ $cur != -* ]] || \ - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $cur != -* ]] || \ + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) } && complete -F _mussh mussh -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mutt b/completions/mutt index 3dc82a92..568479ec 100644 --- a/completions/mutt +++ b/completions/mutt @@ -10,8 +10,6 @@ _muttaddr() _muttquery "$1" COMPREPLY+=( $( compgen -u -- "$1" ) ) - - return 0 } @@ -57,7 +55,7 @@ _muttconffiles() sofar=" $1 " shift while [[ "$1" ]]; do - newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval printf %s $1) ) ) + newconffiles=( $(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval printf %s $1) ) ) for file in "${newconffiles[@]}"; do __expand_tilde_by_ref file [[ ! -f "$file" || $sofar == *\ $file\ * ]] && continue @@ -77,14 +75,12 @@ _muttaliases() local -a conffiles aliases muttrc=$(_muttrc) - [[ -z $muttrc ]] && return 0 + [[ -z $muttrc ]] && return conffiles=( $(eval _muttconffiles $muttrc $muttrc) ) - aliases=( $( sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ + aliases=( $( command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ $(eval echo "${conffiles[@]}") ) ) COMPREPLY+=( $( compgen -W "${aliases[*]}" -- "$cur" ) ) - - return 0 } @@ -94,18 +90,16 @@ _muttquery() local cur=$1 querycmd muttcmd=${words[0]} local -a queryresults - querycmd="$( $muttcmd -Q query_command 2>/dev/null | 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 | \ - sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p' ) ) + command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p' ) ) fi COMPREPLY+=( $( compgen -W "${queryresults[*]}" -- "$cur" ) ) - - return 0 } @@ -116,7 +110,7 @@ _muttfiledir() muttrc=$(_muttrc) if [[ $cur == [=+]* ]]; then - folder="$( $muttcmd -F "$muttrc" -Q folder 2>/dev/null | 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 @@ -124,15 +118,13 @@ _muttfiledir() compopt -o filenames COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) ) COMPREPLY=( ${COMPREPLY[@]#$folder/} ) - return 0 + return elif [[ $cur == !* ]]; then spoolfile="$( $muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | \ - sed -e 's|^spoolfile=\"\(.*\)\"$|\1|' )" + command sed -e 's|^spoolfile=\"\(.*\)\"$|\1|' )" [[ ! -z $spoolfile ]] && eval cur="${cur/^!/$spoolfile}" fi _filedir - - return 0 } @@ -145,24 +137,24 @@ _mutt() -*) 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 0 + return ;; *) case $prev in -a|-f|-F|-H|-i) _muttfiledir "$cur" - return 0 + return ;; -A) _muttaliases "$cur" - return 0 + return ;; -e|-m|-Q|-s|-h|-p|-R|-v|-y|-z|-Z) - return 0 + return ;; *) _muttaddr "$cur" - return 0 + return ;; esac ;; @@ -170,4 +162,4 @@ _mutt() } && complete -F _mutt -o default mutt muttng -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mysql b/completions/mysql index c41c1667..ddc94e68 100644 --- a/completions/mysql +++ b/completions/mysql @@ -8,38 +8,42 @@ _mysql() case $prev in -u|--user) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; -D|--database) - COMPREPLY=( $( compgen -W "$(mysqlshow 2>/dev/null|sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur" ) ) + return ;; -h|--host) _known_hosts_real "$cur" - return 0 + return ;; --default-character-set) - [[ -d /usr/share/mysql/charsets ]] && \ - COMPREPLY=( $( compgen -W "$(command ls /usr/share/mysql/charsets|sed -e '/^\(README\|Index\.xml\)$/d' -e 's/.xml$//') utf8" -- "$cur" ) ) - return 0 + local 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" ) ) + return ;; --character-sets-dir|--ssl-capath) _filedir -d - return 0 + return ;; -S|--socket) _filedir sock - return 0 + return ;; --protocol) COMPREPLY=( $( compgen -W 'tcp socket pipe memory' -- "$cur" ) ) - return 0 + return ;; --defaults-file|--defaults-extra-file|--tee) _filedir - return 0 + return ;; --default-character-set|-P|--port|--set-variable|\ --ssl-ca|--ssl-cert|--ssl-cipher|--ssl-key|\ @@ -47,11 +51,11 @@ _mysql() --net_buffer_length|--select_limit|--max_join_size|\ --server-arg|--debug|--delimiter|--execute|-e|--pager) # Argument required but no completions available - return 0 + return ;; '-?'|-I|--help|-V|--version) # All other options are noop with these - return 0 + return ;; esac @@ -62,21 +66,21 @@ _mysql() COMPREPLY=( $( compgen -W "$help" -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return ;; # only complete long options -) compopt -o nospace COMPREPLY=( -- ) - return 0 + return ;; esac COMPREPLY=( $( compgen -W \ - "$(mysqlshow 2>/dev/null|sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" \ + "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" \ -- "$cur" ) ) } && complete -F _mysql mysql -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/mysqladmin b/completions/mysqladmin index bdc07eb2..13799052 100644 --- a/completions/mysqladmin +++ b/completions/mysqladmin @@ -8,37 +8,37 @@ _mysqladmin() case $prev in -u|--user) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; -h|--host) _known_hosts_real "$cur" - return 0 + return ;; --character-sets-dir|--ssl-capath) _filedir -d - return 0 + return ;; -S|--socket) _filedir sock - return 0 + return ;; --defaults-file|--defaults-extra-file) _filedir - return 0 + 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 - return 0 + return ;; '-?'|--help|-V|--version) # All other options are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -51,4 +51,4 @@ _mysqladmin() } && complete -F _mysqladmin mysqladmin -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/nc b/completions/nc index 055924c9..61bf5b52 100644 --- a/completions/nc +++ b/completions/nc @@ -36,13 +36,11 @@ _nc() # Complete 1st non-option arg only local i for (( i=1; i < cword; i++ )); do - [[ ${words[i]} != -* && \ - ${words[i-1]} != @(-I|-i|-O|-P|-p|-s|-T|-V|-w|-X|-x) ]] && \ - return + [[ ${words[i]} != -* && ${words[i-1]} != -[IiOPpsTVwXx] ]] && return done _known_hosts_real "$cur" } && complete -F _nc nc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ncftp b/completions/ncftp index 0d32cfe2..4c073ce6 100644 --- a/completions/ncftp +++ b/completions/ncftp @@ -17,12 +17,11 @@ _ncftp() fi if [[ $cword -eq 1 && -f ~/.ncftp/bookmarks ]]; then - COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ + COMPREPLY=( $( compgen -W '$( command sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ ~/.ncftp/bookmarks )' -- "$cur" ) ) fi - return 0 } && complete -F _ncftp -o default ncftp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/nethogs b/completions/nethogs index 937edf1f..8eeb4ff5 100644 --- a/completions/nethogs +++ b/completions/nethogs @@ -20,6 +20,7 @@ _nethogs() fi _available_interfaces -a -} && complete -F _nethogs nethogs +} && +complete -F _nethogs nethogs -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/newlist b/completions/newlist index 9e2f6933..04bf17d1 100644 --- a/completions/newlist +++ b/completions/newlist @@ -2,16 +2,24 @@ _newlist() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return + + case $prev in + -l|--language|-u|--urlhost|-e|--emailhost|--help) + return + ;; + esac + + $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--language --quiet --help' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace else _xfunc list_lists _mailman_lists fi - } && complete -F _newlist newlist -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/newusers b/completions/newusers index aa1394d2..068b7a92 100644 --- a/completions/newusers +++ b/completions/newusers @@ -9,23 +9,23 @@ _newusers() -c|--crypt) COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \ -- "$cur" ) ) - return 0 + return ;; -s|--sha-rounds) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi _filedir } && complete -F _newusers newusers -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ngrep b/completions/ngrep index 7c867649..bbfbbd2f 100644 --- a/completions/ngrep +++ b/completions/ngrep @@ -34,4 +34,4 @@ _ngrep() } && complete -F _ngrep ngrep -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/nmap b/completions/nmap index 6fbdb073..7de8ed42 100644 --- a/completions/nmap +++ b/completions/nmap @@ -8,19 +8,19 @@ _nmap() case $prev in -iL|-oN|-oX|-oS|-oG|---excludefile|--resume|--stylesheet) _filedir - return 0 + return ;; -oA|--datadir) _filedir -d - return 0 + return ;; -e) _available_interfaces -a - return 0 + return ;; -b|--dns-servers) _known_hosts_real "$cur" - return 0 + return ;; esac @@ -47,4 +47,4 @@ _nmap() } && complete -F _nmap nmap -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/nslookup b/completions/nslookup index 88af1d5b..f137b0a1 100644 --- a/completions/nslookup +++ b/completions/nslookup @@ -39,6 +39,14 @@ _nslookup() -domain= -search -nosearch -port= -querytype= -recurse -norecurse -retry= -timeout= -vc -novc -fail -nofail' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + local args + _count_args = + if [[ $args -le 2 ]]; then + _known_hosts_real "$cur" + [[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=( - ) fi } && complete -F _nslookup nslookup @@ -75,4 +83,4 @@ _host() } && complete -F _host host -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ntpdate b/completions/ntpdate index dab38477..ade95a69 100644 --- a/completions/ntpdate +++ b/completions/ntpdate @@ -8,19 +8,19 @@ _ntpdate() case $prev in -k) _filedir - return 0 + return ;; -U) - COMPREPLY=( $( compgen -u "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -u -- "$cur" ) ) + return ;; -p) COMPREPLY=( $( compgen -W '{1..8}' -- "$cur" ) ) - return 0 + return ;; -a|-e|-o|-t) - return 0 + return ;; esac @@ -32,4 +32,4 @@ _ntpdate() } && complete -F _ntpdate ntpdate -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/openssl b/completions/openssl index 997fe1ec..57476848 100644 --- a/completions/openssl +++ b/completions/openssl @@ -20,12 +20,18 @@ _openssl_sections() done fi - [[ ! -f $config ]] && return 0 + [[ ! -f $config ]] && return COMPREPLY=( $( compgen -W "$( awk '/\[.*\]/ {print $2}' $config )" \ -- "$cur" ) ) } +_openssl_digests() +{ + "$1" dgst -h 2>&1 | \ + awk '/^-.*[ \t]to use the .* message digest algorithm/ { print $1 }' +} + _openssl() { local cur prev words cword @@ -43,7 +49,8 @@ _openssl() camellia-256-ecb cast cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb des des-cbc des-cfb des-ecb des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 - rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 rc4-40' + rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 rc4-40 + sha224 sha256 sha384 sha512' if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) @@ -56,15 +63,15 @@ _openssl() -spkac|-sign|-signkey|-signer|-signature|-ss_cert|-untrusted| \ -verify) _filedir - return 0 + return ;; -outdir|-CApath) _filedir -d - return 0 + return ;; -name|-crlexts|-extensions) _openssl_sections - return 0 + return ;; -inform|-outform|-keyform|-certform|-CAform|-CAkeyform|-dkeyform|\ -dcertform) @@ -78,20 +85,20 @@ _openssl() ;; esac COMPREPLY=( $( compgen -W "$formats" -- "$cur" ) ) - return 0 + return ;; -connect) _known_hosts_real "$cur" - return 0 + return ;; -starttls) COMPREPLY=( $( compgen -W 'smtp pop3 imap ftp' -- "$cur" ) ) - return 0 + return ;; -cipher) - COMPREPLY=( $( IFS=: compgen -W "$( openssl ciphers )" \ + COMPREPLY=( $( IFS=: compgen -W "$( $1 ciphers )" \ -- "$cur" ) ) - return 0 + return ;; esac @@ -122,9 +129,8 @@ _openssl() options='-inform -outform -in -out -print_certs' ;; dgst) - options='-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 - -c -d -hex -binary -out -sign -verify -prverify - -signature' + options="-c -d -hex -binary -out -sign -verify -prverify + -signature $( _openssl_digests $1 )" ;; dsa) options='-inform -outform -in -passin -out -passout -des @@ -156,11 +162,11 @@ _openssl() options='-out -rand -base64' ;; req) - options='-inform -outform -in -passin -out -passout -text + options="-inform -outform -in -passin -out -passout -text -noout -verify -modulus -new -rand -newkey -newkey - -nodes -key -keyform -keyout -md5 -sha1 -md2 -mdc2 + -nodes -key -keyform -keyout $( _openssl_digests $1 ) -config -x509 -days -asn1-kludge -newhdr -extensions - -reqexts section' + -reqexts section" ;; rsa) options='-inform -outform -in -passin -out -passout @@ -210,16 +216,16 @@ _openssl() -issuer_checks -verbose -certificates' ;; x509) - options='-inform -outform -keyform -CAform -CAkeyform -in + options="-inform -outform -keyform -CAform -CAkeyform -in -out -serial -hash -subject_hash -issuer_hash -subject -issuer -nameopt -email -startdate -enddate -purpose -dates -modulus -fingerprint -alias -noout -trustout -clrtrust -clrreject -addtrust -addreject -setalias -days -set_serial -signkey -x509toreq -req -CA -CAkey - -CAcreateserial -CAserial -text -C -md2 -md5 -sha1 - -mdc2 -clrext -extfile -extensions -engine' + -CAcreateserial -CAserial -text -C -clrext + -extfile -extensions -engine $( _openssl_digests $1 )" ;; - md5|md4|md2|sha1|sha|mdc2|ripemd160) + md*|sha*|ripemd160) options='-c -d' ;; esac @@ -238,4 +244,4 @@ _openssl() } && complete -F _openssl -o default openssl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/opera b/completions/opera index 6cbfbacf..26343c62 100644 --- a/completions/opera +++ b/completions/opera @@ -41,6 +41,7 @@ _opera() fi _filedir '@(?([xX]|[sS])[hH][tT][mM]?([lL]))' -} && complete -F _opera opera +} && +complete -F _opera opera -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/optipng b/completions/optipng new file mode 100644 index 00000000..7c614abe --- /dev/null +++ b/completions/optipng @@ -0,0 +1,52 @@ +# optipng(1) completion -*- shell-script -*- + +_optipng() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -'?'|-h|--help|-f) + return + ;; + -o) + COMPREPLY=( $( compgen -W '{0..7}' -- "$cur" ) ) + return + ;; + -out|-log) + _filedir + return + ;; + -dir) + _filedir -d + return + ;; + -i) + COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) ) + return + ;; + -zc|-zm) + COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) + return + ;; + -zw) + COMPREPLY=( $( compgen -W '256 512 1k 2k 4k 8k 16k 32k' \ + -- "$cur" ) ) + return + ;; + -strip) + COMPREPLY=( $( compgen -W 'all' -- "$cur" ) ) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi + + _filedir '@(png|bmp|gif|pnm|tif?(f))' +} && +complete -F _optipng optipng + +# ex: filetype=sh diff --git a/completions/p4 b/completions/p4 index 4e47267f..beea4687 100644 --- a/completions/p4 +++ b/completions/p4 @@ -45,8 +45,7 @@ _p4() esac fi - return 0 } && complete -F _p4 -o default p4 g4 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pack200 b/completions/pack200 index fa6b1c78..37c57749 100644 --- a/completions/pack200 +++ b/completions/pack200 @@ -9,36 +9,36 @@ _pack200() -S|--segment-limit|-P|--pass-file|-C|--class-attribute|\ -F|--field-attribute|-M|--method-attribute|-D|--code-attribute|\ '-?'|-h|--help|-V|--version|-J) - return 0 + return ;; -E|--effort) COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) ) - return 0 + return ;; -H|--deflate-hint) COMPREPLY=( $( compgen -W 'true false keep' -- "$cur" ) ) - return 0 + return ;; -m|--modification-time) COMPREPLY=( $( compgen -W 'latest keep' -- "$cur" ) ) - return 0 + return ;; -U|--unknown-attribute) COMPREPLY=( $( compgen -W 'error strip pass' -- "$cur" ) ) - return 0 + return ;; -f|--config-file) _filedir properties - return 0 + return ;; -l|--log-file) COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) _filedir log - return 0 + return ;; -r|--repack) _filedir jar - return 0 + return ;; esac @@ -71,4 +71,4 @@ _pack200() } && complete -F _pack200 pack200 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/passwd b/completions/passwd index e470b8bb..ce6d4c0e 100644 --- a/completions/passwd +++ b/completions/passwd @@ -7,17 +7,17 @@ _passwd() case $prev in -n|--minimum|-x|--maximum|-w|--warning|-i|--inactive|-\?|--help|--usage) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi _allowed_users } && complete -F _passwd passwd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/patch b/completions/patch index e8da15a9..1a9edca1 100644 --- a/completions/patch +++ b/completions/patch @@ -67,4 +67,4 @@ _patch() } && complete -F _patch patch -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pdftotext b/completions/pdftotext new file mode 100644 index 00000000..aed6b2c2 --- /dev/null +++ b/completions/pdftotext @@ -0,0 +1,36 @@ +# bash completion for pdftotext(1) -*- shell-script -*- + +_pdftotext() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|-help|--help|-'?'|-f|-l|-r|-x|-y|-W|-H|-fixed|-opw|-upw) + return + ;; + -enc) + COMPREPLY=( $( compgen -W '$( "$1" -listenc 2>/dev/null | + command sed -e 1d )' -- "$cur" ) ) + return + ;; + -eol) + COMPREPLY=( $( compgen -W "unix dos mac" -- "$cur" ) ) + return + ;; + esac + + if [[ $cur == -* && ${prev,,} != *.pdf ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi + + case ${prev,,} in + -|*.txt) ;; + *.pdf) COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) ; _filedir txt ;; + *) _filedir pdf ;; + esac +} && +complete -F _pdftotext pdftotext + +# ex: filetype=sh diff --git a/completions/perl b/completions/perl index 4bcc9b02..250039ee 100644 --- a/completions/perl +++ b/completions/perl @@ -1,18 +1,11 @@ # bash completion for perl -*- shell-script -*- -_perlmodules() +_perl_helper() { COMPREPLY=( $( compgen -P "$prefix" -W \ - "$( ${1:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl modules $cur )" \ - -- "$cur" ) ) - __ltrim_colon_completions "$prefix$cur" -} - -_perlfunctions() -{ - COMPREPLY=( $( compgen -P "$prefix" -W \ - "$( ${1:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl functions $cur )" \ + "$( ${2:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl $1 $cur )" \ -- "$cur" ) ) + [[ $1 == functions ]] || __ltrim_colon_completions "$prefix$cur" } _perl() @@ -27,6 +20,10 @@ _perl() temp=$cur prev=${temp:0:2} cur=${temp:2} + if [[ $prev == -d && $cur == t* ]]; then + prev=-dt + cur=${cur:1} + fi optPrefix=-P$prev optSuffix=-S/ prefix=$prev @@ -34,20 +31,20 @@ _perl() case $prev in -D|-e|-E|-i|-F|-l) - return 0 + return ;; -I|-x) local IFS=$'\n' compopt -o filenames COMPREPLY=( $( compgen -d $optPrefix $optSuffix -- "$cur" ) ) - return 0 + return ;; -m|-M) temp="${cur#-}" prefix+="${cur%$temp}" cur="$temp" - _perlmodules $1 - return 0 + _perl_helper modules $1 + return ;; -V) if [[ $cur == :* ]]; then @@ -59,16 +56,15 @@ _perl() keys %Config::Config" 2>/dev/null )' -- "$temp" ) ) __ltrim_colon_completions "$prefix$temp" fi - return 0 + return ;; -d|-dt) if [[ $cur == :* ]]; then temp="${cur#:}" prefix="$prefix${cur%$temp}" cur="Devel::$temp" - _perlmodules $1 + _perl_helper modules $1 fi - return 0 ;; esac @@ -101,15 +97,15 @@ _perldoc() case $prev in -h|-V|-n|-o|-M|-w|-L) - return 0 + return ;; -d) _filedir - return 0 + return ;; -f) - _perlfunctions $perl - return 0 + _perl_helper functions $perl + return ;; esac @@ -118,18 +114,18 @@ _perldoc() else # return available modules (unless it is clearly a file) if [[ "$cur" != @(*/|[.~])* ]]; then - _perlmodules $perl + _perl_helper perldocs $perl if [[ $cur == p* ]]; then COMPREPLY+=( $( compgen -W \ - '$( PERLDOC_PAGER=/bin/cat "$1" -u perl | \ - sed -ne "/perl.*Perl overview/,/perlwin32/p" | \ - awk "\$NF=2 && \$1 ~ /^perl/ { print \$1 }" )' \ + '$( 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@(l|m|od)' + _filedir 'p@([lm]|od)' fi } && complete -F _perldoc -o bashdefault perldoc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pgrep b/completions/pgrep index 0a1c862f..82985acf 100644 --- a/completions/pgrep +++ b/completions/pgrep @@ -6,14 +6,18 @@ _pgrep() _init_completion || return case $prev in - -c|-d|-g|-J|-M|-N|-s|-t|-T|-z) + -c|-d|--delimiter|-g|--pgroup|-J|-M|-N|-s|--session|-t|--terminal|-T|-z) return ;; - -F) + --signal) + _signals + return + ;; + -F|--pidfile) _filedir return ;; - -G) + -G|--group) _gids return ;; @@ -21,26 +25,28 @@ _pgrep() COMPREPLY=( $( compgen -W 'any none' -- "$cur" ) ) return ;; - -P) + -P|--parent) _pids return ;; - -u|-U) + -u|--euid|-U|--uid) _uids return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( "$1" --usage 2>&1 | - sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//" | - _parse_usage - )' -- "$cur" ) ) + 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" ) ) [[ $cword -eq 1 && $1 == *pkill ]] && _signals - return fi - _pnames + _pnames -s } && complete -F _pgrep pgrep pkill -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pidof b/completions/pidof index 12ac9a79..223e25d4 100644 --- a/completions/pidof +++ b/completions/pidof @@ -6,14 +6,22 @@ _pidof() _init_completion || return case $prev in - -o) + -h|--help|-V|--version) + return + ;; + -o|--omit-pid) _pids return ;; esac + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi + _pnames } && complete -F _pidof pidof -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pine b/completions/pine index 39227625..d99a3808 100644 --- a/completions/pine +++ b/completions/pine @@ -1,13 +1,32 @@ -# PINE address-book completion -*- shell-script -*- +# pine/alpine completion -*- shell-script -*- -_pineaddr() +_pine() { local cur prev words cword _init_completion || return - COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook \ - 2>/dev/null)' -- "$cur" ) ) + case $prev in + -help|-d|-f|-c|-I|-n|-url|-copy_pinerc|-copy_abook) + return + ;; + -attach|-attachlist|-attach_and_delete|-p|-P|-pinerc|-passfile|-x) + _filedir + return + ;; + -sort) + 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" ) ) + else + COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook \ + 2>/dev/null)' -- "$cur" ) ) + fi } && -complete -F _pineaddr -o default pine alpine +complete -F _pine pine alpine -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ping b/completions/ping index 7b1f77a0..221fdd51 100644 --- a/completions/ping +++ b/completions/ping @@ -58,4 +58,4 @@ _ping() } && complete -F _ping ping ping6 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pkg-config b/completions/pkg-config index f861c30e..a537d497 100644 --- a/completions/pkg-config +++ b/completions/pkg-config @@ -9,7 +9,7 @@ _pkg_config() --define-variable|--atleast-version|--atleast-pkgconfig-version| \ --exact-version|--max-version) # argument required but no completions available - return 0 + return ;; --variable) local i @@ -21,24 +21,24 @@ _pkg_config() break fi done - return 0 + return ;; -\?|--help|--version|--usage) # all other arguments are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace else - COMPREPLY=( $( compgen -W "$( pkg-config --list-all \ + COMPREPLY=( $( compgen -W "$( $1 --list-all \ 2>/dev/null | awk '{print $1}' )" -- "$cur" ) ) fi } && complete -F _pkg_config pkg-config -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pkg-get b/completions/pkg-get index bf66fcc8..d5382eb2 100644 --- a/completions/pkg-get +++ b/completions/pkg-get @@ -2,8 +2,7 @@ # # Copyright 2006 Yann Rouillard <yann@opencsw.org> -_have pkg-get && -_pkg-get_get_catalog_file() +_pkg_get_get_catalog_file() { local url="$1" local catalog_file i conffile @@ -26,50 +25,49 @@ _pkg-get_get_catalog_file() echo "$catalog_file" } && -_pkg-get() +_pkg_get() { local cur prev file catalog_file url command COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - if [[ "${prev}" = "-s" ]]; then + if [[ "${prev}" == "-s" ]]; then return 1 fi - i=${#COMP_WORDS[*]} + 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]}" == @(available|-a|describe|-D|download|-d|install|-i|list|updatecatalog|-U|upgrade|-u) ]]; then + if [[ "${COMP_WORDS[$i]}" == @(-[aDdiUu]|available|describe|download|install|list|updatecatalog|upgrade) ]]; then command="${COMP_WORDS[$i]}" fi done if [[ -n "$command" ]]; then - if [[ "$command" == @(describe|-D|download|-d|install|-i) ]]; then - catalog_file=$(_pkg-get_get_catalog_file "$url") + if [[ "$command" == @(-[Ddi]|describe|download|install) ]]; then + catalog_file=$(_pkg_get_get_catalog_file "$url") if [[ -f $catalog_file ]]; then local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' $catalog_file) COMPREPLY=( $(compgen -W "${packages_list}" -- ${cur}) ) fi fi - return 0 + return fi if [[ ${cur} == -* ]] ; then local opts="-c -d -D -f -i -l -s -S -u -U -v" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - else - local commands="available describe download install list \ - updatecatalog upgrade" - COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) ) - return 0 + return fi + + local commands="available describe download install list \ + updatecatalog upgrade" + COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) ) } && -complete -F _pkg-get pkg-get +complete -F _pkg_get pkg-get -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pkg_delete b/completions/pkg_delete index 15770acb..9125829d 100644 --- a/completions/pkg_delete +++ b/completions/pkg_delete @@ -9,13 +9,12 @@ _pkg_delete() local pkgdir=${PKG_DBDIR:-/var/db/pkg}/ - [[ "$prev" == -o || "$prev" == -p || "$prev" == -W ]] && return 0 + [[ "$prev" == -o || "$prev" == -p || "$prev" == -W ]] && return - COMPREPLY=( $( compgen -d "$pkgdir$cur" ) ) + COMPREPLY=( $( compgen -d -- "$pkgdir$cur" ) ) COMPREPLY=( ${COMPREPLY[@]#$pkgdir} ) - return 0 } && complete -F _pkg_delete -o dirnames pkg_delete pkg_info pkg_deinstall -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pkgadd b/completions/pkgadd index 28098815..009f3a25 100644 --- a/completions/pkgadd +++ b/completions/pkgadd @@ -10,18 +10,18 @@ _pkgadd () # if a device directory was given # we must complete with the package # available in this directory - local device=/var/spool/pkg; + local device=/var/spool/pkg local i=$cword while [[ $((i--)) -gt 0 ]]; do case "${words[$i]}" in -d) - device="${words[$((i+1))]}"; + device="${words[$((i+1))]}" break ;; - esac; - done; + esac + done - case $prev in + case $prev in -d) _filedir pkg _filedir -d @@ -48,7 +48,8 @@ _pkgadd () done pkginst_list="${pkginst_list[@]}" else - pkginst_list=$(strings $(dequote $device) | grep "^PKG=" | sort -u | cut -d= -f2) + pkginst_list=$(strings $(dequote $device) | \ + command grep "^PKG=" | sort -u | cut -d= -f2) fi COMPREPLY=( $(compgen -W "$pkginst_list" -- ${cur}) ) fi @@ -56,4 +57,4 @@ _pkgadd () } && complete -F _pkgadd pkgadd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pkgrm b/completions/pkgrm index 24d2a398..891507f8 100644 --- a/completions/pkgrm +++ b/completions/pkgrm @@ -2,26 +2,25 @@ # # Copyright 2006 Yann Rouillard <yann@opencsw.org> -_have pkgrm && _pkgrm () { - local cur prev words cword + local cur prev words cword _init_completion || return # if a spool directory was given # we must complete with the package # available in this directory - local spool=/var/sadm/pkg; + local spool=/var/sadm/pkg local i=$cword while [[ $((i--)) -gt 0 ]]; do - i=$((i-1)); + i=$((i-1)) case "${words[$i]}" in -s) - spool="${words[$((i+1))]}"; + spool="${words[$((i+1))]}" break ;; - esac; - done; + esac + done case $prev in -a | -V) @@ -34,17 +33,14 @@ _pkgrm () ;; *) if [[ ${cur} == -* ]]; then - local opts="-a -A -n -M -R -s -v -V -Y"; - COMPREPLY=($(compgen -W "${opts}" -- ${cur})); - return 0; + local opts="-a -A -n -M -R -s -v -V -Y" + COMPREPLY=($(compgen -W "${opts}" -- ${cur})) else - COMPREPLY=($(compgen -W "$(/bin/ls -1 $spool)" -- ${cur})); - return 0; + COMPREPLY=($(compgen -W "$(/bin/ls -1 $spool)" -- ${cur})) fi ;; esac } && complete -F _pkgrm pkgrm -# ex: ts=4 sw=4 et filetype=sh - +# ex: filetype=sh diff --git a/completions/pkgtool b/completions/pkgtool index 5adcbaf0..95d42aaa 100644 --- a/completions/pkgtool +++ b/completions/pkgtool @@ -8,19 +8,19 @@ _pkgtool() case "$prev" in --source_dir|--target_dir) _filedir -d - return 0 + return ;; --sets) # argument required but no completions available - return 0 + return ;; --source_device) COMPREPLY=( $( compgen -f -d -- "${cur:-/dev/}" ) ) - return 0 + return ;; --tagfile) _filedir - return 0 + return ;; esac @@ -28,9 +28,8 @@ _pkgtool() COMPREPLY=( $( compgen -W '--sets --ignore-tagfiles --tagfile --source-mounted --source_dir --target_dir --source_device' \ -- "$cur" ) ) - return 0 fi } && complete -F _pkgtool pkgtool -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pkgutil b/completions/pkgutil index 06bbeaf0..4b2fcdcd 100644 --- a/completions/pkgutil +++ b/completions/pkgutil @@ -14,7 +14,7 @@ _pkgutil_url2catalog() _pkgutil() { - local cur prev words cword + local cur prev words cword _init_completion -n : || return local command catalog_files configuration_files @@ -23,34 +23,34 @@ _pkgutil() i=$cword while [[ $((i--)) -gt 1 ]]; do - if [[ "${words[$i]}" = @(-t|--temp) ]]; then + if [[ "${words[$i]}" == -@(t|-temp) ]]; then local url="${words[$((i+1))]}" local catalog=$(_pkgutil_url2catalog "$url") catalog_files=("$catalog") - elif [[ "${words[$i]}" = @(--config) ]]; then + elif [[ "${words[$i]}" == --config ]]; then configuration_files=( "$(dequote ${words[$((i+1))]})" ) - elif [[ "${words[$i]}" == @(-i|--install|-u|--upgrade|-r|--remove|-d|--download|-a|--available|-c|--compare|-U|--catalog|-S|--stream) ]]; then - command="${words[$i]}" + elif [[ "${words[$i]}" == -@([iurdacUS]|-install|-upgrade|-remove|-download|-available|-compare|-catalog|-stream) ]]; then + command="${words[$i]}" fi done - if [[ "$prev" = @(-W|--workdir|-P|--pkgdir|-R|--rootpath) ]]; then + if [[ "$prev" == -@([WPR]|-workdir|-pkgdir|-rootpath) ]]; then _filedir -d - return 0 + return fi - if [[ "$prev" = @(-o|--output|--config) ]]; then + if [[ "$prev" == -@(o|-output|-config) ]]; then _filedir - return 0 + return fi - if [[ "$prev" = @(-p|--param) ]]; then + if [[ "$prev" == -@(p|-param) ]]; then compopt -o nospace COMPREPLY=( $(compgen -W "mirror: pkgaddopts: pkgrmopts: wgetopts: use_gpg: use_md5: pkgliststyle: maxpkglist: noncsw: stop_on_hook_soft_error: exclude_pattern: gpg_homedir: root_path: deptree_filter_common: show_current: catalog_not_cached: catalog_update:" -- $cur) ) - return 0 + return fi - if [[ "$prev" = @(-T|--target) ]]; then + if [[ "$prev" == @(-T|--target) ]]; then # Work-around bash_completion issue where bash interprets a colon # as a separator, borrowed from maven completion code which borrowed # it from darcs completion code :) @@ -60,7 +60,7 @@ _pkgutil() while [ $((--i)) -ge 0 ]; do COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"} done - return 0 + return fi if [[ -n "$command" ]] && [[ ! "$cur" == -* ]]; then @@ -73,7 +73,7 @@ _pkgutil() catalog_files=( "${catalog_files[@]}" "$catalog" ) done - if [[ "$command" == @(--download|-d|--install|-i|--upgrade|-u|s|--stream) ]]; then + if [[ "$command" == -@([dius]|-download|-install|-upgrade|-stream) ]]; then local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "${catalog_files[@]}") COMPREPLY=( $(compgen -W "${packages_list}" -- $cur) ) @@ -83,14 +83,13 @@ _pkgutil() packages_list=$(nawk " \$3 ~ /^$packages_list\$/ { print \$1 }" "${catalog_files[@]}") COMPREPLY=( $(compgen -W "${packages_list}" -- $cur) ) fi - return 0 + return fi local commands="-i --install -u --upgrade -r --remove -d --download -U --catalog -a --available --describe -c --compare -C --compare-diff -A --compare-avail -e --email -t --temp -x --exclude -W --workdir -P --pkgdir -R --rootpath --config -y --yes -f --force -n --nomod -N --nodeps -D --debug --trace -h --help -v --version -V --syscheck -l --list -L --listfile -F --findfile --deptree --extract -s --stream -o --output -T --target --single -p --param --parse --cleanup --catinfo" COMPREPLY=( $(compgen -W "${commands}" -- $cur) ) - return 0 -} +} && complete -F _pkgutil pkgutil -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/plague-client b/completions/plague-client index b5385467..6fd22f75 100644 --- a/completions/plague-client +++ b/completions/plague-client @@ -11,4 +11,4 @@ _plague_client() } && complete -F _plague_client plague-client -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pm-hibernate b/completions/pm-hibernate index 24b30b17..fcabbfaf 100644 --- a/completions/pm-hibernate +++ b/completions/pm-hibernate @@ -9,4 +9,4 @@ _pm_action() } && complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pm-is-supported b/completions/pm-is-supported index 2ca5a9ec..2eeb634d 100644 --- a/completions/pm-is-supported +++ b/completions/pm-is-supported @@ -10,4 +10,4 @@ _pm_is_supported() } && complete -F _pm_is_supported pm-is-supported -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pm-powersave b/completions/pm-powersave index 1f790dca..f61833cf 100644 --- a/completions/pm-powersave +++ b/completions/pm-powersave @@ -9,4 +9,4 @@ _pm_powersave() } && complete -F _pm_powersave pm-powersave -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pngfix b/completions/pngfix new file mode 100644 index 00000000..b1f630ed --- /dev/null +++ b/completions/pngfix @@ -0,0 +1,35 @@ +# pngfix completion -*- shell-script -*- + +_pngfix() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --suffix|--prefix) + return + ;; + --output) + _filedir + return + ;; + --strip) + COMPREPLY=( $( IFS='|' compgen -W '$( "$1" --help 2>&1 | + command sed -ne "s/.*--strip=\[\([^]]*\)\].*/\1/p" )' -- "$cur" ) ) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir png +} && +complete -F _pngfix pngfix + +# ex: filetype=sh diff --git a/completions/portinstall b/completions/portinstall index 3b30c5b3..314e936f 100644 --- a/completions/portinstall +++ b/completions/portinstall @@ -16,7 +16,7 @@ _portinstall() [[ "${OSTYPE%.*}" == freebsd5 && -f $indexfile ]] || indexfile=$portsdir/INDEX - [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0 + [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return COMPREPLY=( $( command grep -E "^$cur" 2>/dev/null < $indexfile | \ cut -d'|' -f1 ) ) @@ -25,8 +25,7 @@ _portinstall() COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} ) COMPREPLY+=( "${COMPREPLY2[@]}" ) - return 0 } && complete -F _portinstall -o dirnames portinstall -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/portsnap b/completions/portsnap new file mode 100644 index 00000000..f865183b --- /dev/null +++ b/completions/portsnap @@ -0,0 +1,25 @@ +# bash completion for Portsnap -*- shell-script -*- + +[[ $OSTYPE == *freebsd* ]] || return 1 + +_portsnap() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -d|-p) + _filedir -d + return + ;; + -l|-f) + _filedir + return + ;; + esac + + COMPREPLY=( $(compgen -W "fetch cron extract update" -- $cur) ) +} && +complete -F _portsnap portsnap + +# ex: filetype=sh diff --git a/completions/portupgrade b/completions/portupgrade index 96e4fb6d..64d983df 100644 --- a/completions/portupgrade +++ b/completions/portupgrade @@ -5,16 +5,15 @@ _portupgrade() local cur prev words cword _init_completion || return - [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0 + [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return local pkgdir=${PKG_DBDIR:-/var/db/pkg}/ - COMPREPLY=( $( compgen -d "$pkgdir$cur" ) ) + COMPREPLY=( $( compgen -d -- "$pkgdir$cur" ) ) COMPREPLY=( ${COMPREPLY[@]#$pkgdir} ) COMPREPLY=( ${COMPREPLY[@]%-*} ) - return 0 } && complete -F _portupgrade -o dirnames portupgrade -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/postcat b/completions/postcat index c601cb0c..69214354 100644 --- a/completions/postcat +++ b/completions/postcat @@ -8,35 +8,34 @@ _postcat() case $prev in -c) _filedir -d - return 0 + return ;; esac if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi local idx qfile=0 for idx in "${words[@]}"; do - [[ "$idx" = -q ]] && qfile=1 && break + [[ "$idx" == -q ]] && qfile=1 && break done if [[ $qfile -eq 1 ]]; then local len=${#cur} pval idx=0 for pval in $( mailq 2>/dev/null | \ - sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do + command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do if [[ "$cur" == "${pval:0:$len}" ]]; then COMPREPLY[$idx]=$pval idx=$(($idx+1)) fi done - return 0 - else - _filedir - return 0 + return fi + + _filedir } && complete -F _postcat postcat -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/postconf b/completions/postconf index 5b998d9e..c1f17d9d 100644 --- a/completions/postconf +++ b/completions/postconf @@ -10,11 +10,11 @@ _postconf() case $prev in -b|-t) _filedir - return 0 + return ;; -c) _filedir -d - return 0 + return ;; -e) cur=${cur#[\"\']} @@ -24,7 +24,7 @@ _postconf() if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi local len=${#cur} idx=0 pval @@ -34,8 +34,7 @@ _postconf() idx=$(($idx+1)) fi done - return 0 } && complete -F _postconf postconf -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/postfix b/completions/postfix index b74bcafe..9b116be1 100644 --- a/completions/postfix +++ b/completions/postfix @@ -8,17 +8,17 @@ _postfix() case $prev in -c) _filedir -d - return 0 + return ;; -D) COMPREPLY=( $( compgen -W 'start' -- "$cur" ) ) - return 0 + return ;; esac if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi COMPREPLY=( $( compgen -W 'check start stop abort flush reload status @@ -26,4 +26,4 @@ _postfix() } && complete -F _postfix postfix -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/postmap b/completions/postmap index 001db9b5..1b415f69 100644 --- a/completions/postmap +++ b/completions/postmap @@ -8,16 +8,16 @@ _postmap() case $prev in -c) _filedir -d - return 0 + return ;; -[dq]) - return 0 + return ;; esac if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi if [[ "$cur" == *:* ]]; then @@ -36,8 +36,7 @@ _postmap() COMPREPLY=( $( compgen -f -- "$cur" ) ) fi fi - return 0 } && complete -F _postmap postmap postalias -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/postsuper b/completions/postsuper index 25bc916f..e69cbea0 100644 --- a/completions/postsuper +++ b/completions/postsuper @@ -10,53 +10,53 @@ _postsuper() case $prev in -c) _filedir -d - return 0 + return ;; -[dr]) len=${#cur} idx=0 for pval in ALL $( mailq 2>/dev/null | \ - sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do + command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do if [[ "$cur" == "${pval:0:$len}" ]]; then COMPREPLY[$idx]=$pval idx=$(($idx+1)) fi done - return 0 + return ;; -h) len=${#cur} idx=0 for pval in ALL $( mailq 2>/dev/null | \ - sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d' ); do + 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)) fi done - return 0 + return ;; -H) len=${#cur} idx=0 for pval in ALL $( mailq 2>/dev/null | \ - sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do + 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)) fi done - return 0 + return ;; esac if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- "$cur" ) ) } && complete -F _postsuper postsuper -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/povray b/completions/povray index fa2f9812..e90279b3 100644 --- a/completions/povray +++ b/completions/povray @@ -9,7 +9,7 @@ _povray() local povcur=$cur pfx oext defoext defoext=png # default output extension, if cannot be determined FIXME - _expand || return 0 + _expand || return case $povcur in [-+]I*) @@ -17,7 +17,7 @@ _povray() pfx="${povcur%"$cur"}" _filedir pov COMPREPLY=( ${COMPREPLY[@]/#/$pfx} ) - return 0 + return ;; [-+]O*) # guess what output file type user may want @@ -35,24 +35,24 @@ _povray() pfx="${povcur%"$cur"}" _filedir $oext COMPREPLY=( ${COMPREPLY[@]/#/$pfx} ) - return 0 + return ;; *.ini\[|*.ini\[*[^]]) # sections in .ini files cur="${povcur#*\[}" pfx="${povcur%\["$cur"}" # prefix == filename - [[ -r $pfx ]] || return 0 - COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \ + [[ -r $pfx ]] || return + 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[}" ) - return 0 + return ;; *) _filedir '@(ini|pov)' - return 0 + return ;; esac } && complete -F _povray povray xpovray spovray -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/prelink b/completions/prelink index f84261d1..0db3140c 100644 --- a/completions/prelink +++ b/completions/prelink @@ -39,4 +39,4 @@ _prelink() } && complete -F _prelink prelink -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/protoc b/completions/protoc index 4621cf64..1d4bef16 100644 --- a/completions/protoc +++ b/completions/protoc @@ -49,7 +49,7 @@ _protoc() COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) local i for i in ${!COMPREPLY[@]}; do - [[ ${COMPREPLY[i]} == -oFILE ]] && unset COMPREPLY[i] + [[ ${COMPREPLY[i]} == -oFILE ]] && unset 'COMPREPLY[i]' done [[ $COMPREPLY == *= ]] && compopt -o nospace return @@ -60,4 +60,4 @@ _protoc() } && complete -F _protoc protoc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/psql b/completions/psql index 186177a3..668bb9ef 100644 --- a/completions/psql +++ b/completions/psql @@ -4,14 +4,14 @@ _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 -AtqwlF $'\t' 2>/dev/null | \ + 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 -Atqwc 'select usename from pg_user' \ + COMPREPLY=( $( compgen -W "$( psql -XAtqwc 'select usename from pg_user' \ template1 2>/dev/null )" -- "$cur" ) ) [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $( compgen -u -- "$cur" ) ) } @@ -26,23 +26,23 @@ _createdb() case $prev in -h|--host) _known_hosts_real "$cur" - return 0 + return ;; -U|--username|-O|--owner) _pg_users - return 0 + return ;; -p|--port|-D|--tablespace|-E|--encoding|-T|--template) # argument required but no completions available - return 0 + return ;; --help|--version) # all other arguments are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -51,7 +51,37 @@ _createdb() _pg_databases fi } && -complete -F _createdb -o default createdb +complete -F _createdb createdb + +# createuser(1) completion +# +_createuser() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--version|-p|--port|-c|--connection-limit) + return + ;; + -h|--host) + _known_hosts_real "$cur" + return + ;; + -U|--username) + _pg_users + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + fi +} && +complete -F _createuser createuser # dropdb(1) completion # @@ -63,19 +93,19 @@ _dropdb() case $prev in -h|--host) _known_hosts_real "$cur" - return 0 + return ;; -U|--username) _pg_users - return 0 + return ;; --help|--version) # all other arguments are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -84,7 +114,39 @@ _dropdb() _pg_databases fi } && -complete -F _dropdb -o default dropdb +complete -F _dropdb dropdb + +# dropuser(1) completion +# +_dropuser() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--version|-p|--port) + return + ;; + -h|--host) + _known_hosts_real "$cur" + return + ;; + -U|--username) + _pg_users + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + else + _pg_users + fi +} && +complete -F _dropuser dropuser # psql(1) completion # @@ -96,32 +158,32 @@ _psql() case $prev in -h|--host) _known_hosts_real "$cur" - return 0 + return ;; -U|--username) _pg_users - return 0 + return ;; -d|--dbname) _pg_databases - return 0 + return ;; -o|--output|-f|--file|-L|--log-file) _filedir - return 0 + 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 0 + return ;; -\?|--help|-V|--version) # all other arguments are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then # return list of available options @@ -134,4 +196,4 @@ _psql() } && complete -F _psql psql -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/puppet b/completions/puppet index f24917a7..b36b0341 100644 --- a/completions/puppet +++ b/completions/puppet @@ -21,8 +21,8 @@ _puppet_certs() PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetca &>/dev/null \ && puppetca=puppetca - if [[ "$1" = '--all' ]]; then - cert_list=$( $puppetca --list --all | sed -e 's/^[+-]\?\s*\(\S\+\)\s\+.*$/\1/' ) + if [[ "$1" == --all ]]; then + cert_list=$( $puppetca --list --all | command sed -e 's/^[+-]\{0,1\}\s*\(\S\+\)\s\+.*$/\1/' ) else cert_list=$( $puppetca --list ) fi @@ -31,7 +31,7 @@ _puppet_certs() _puppet_types() { - puppet_types=$( puppet describe --list | sed -e 's/^\(\S\+\).*$/\1/' ) + puppet_types=$( puppet describe --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/' ) COMPREPLY+=( $( compgen -W "$puppet_types" -- "$cur" ) ) } @@ -41,270 +41,287 @@ _puppet_references() PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetdoc &>/dev/null \ && puppetdoc=puppetdoc - puppet_doc_list=$( $puppetdoc --list | sed -e 's/^\(\S\+\).*$/\1/' ) + 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" ) ) +} + _puppet() { local cur prev words cword _init_completion || return - local xspec helpopts command subcommand + local xspec helpopts subcommand action case $prev in - --help) - return 0 + -h|--help|-V|--version) + return ;; esac case ${words[0]} in puppetmasterd) - command=master + subcommand=master ;; puppetd) - command=agent + subcommand=agent ;; puppetca) - command=cert + subcommand=cert ;; ralsh) - command=resource + subcommand=resource ;; puppetrun) - command=kick + subcommand=kick ;; puppetqd) - command=queue + subcommand=queue ;; filebucket) - command=filebucket + subcommand=filebucket ;; puppetdoc) - command=doc + subcommand=doc ;; pi) - command=describe + subcommand=describe ;; puppet) case ${words[1]} in - agent|apply|cert|describe|doc|filebucket|kick|master|queue|resource) - command=${words[1]} - ;; - *.pp|*.rb|-*) - command=apply - ;; - *) - COMPREPLY=( $( compgen -W 'agent apply cert describe doc - filebucket kick master queue resource' -- "$cur" ) ) - return 0 - ;; + agent|apply|cert|describe|doc|filebucket|kick|master|parser|queue|resource) + subcommand=${words[1]} + ;; + *.pp|*.rb) + subcommand=apply + ;; + *) + COMPREPLY=( $( compgen -W 'agent apply cert describe doc + filebucket kick master parser queue resource' \ + -- "$cur" ) ) + return + ;; esac esac - case $command in + case $subcommand in agent) case $prev in + --certname) + _known_hosts_real "$cur" + return + ;; + --digest) + _puppet_digest + return + ;; --fqdn) - return 0 + _known_hosts_real "$cur" + return ;; - --logdest) + -l|--logdest) _puppet_logdest - return 0 - ;; - --serve) - # From /usr/lib/ruby/1.8/puppet/network/handler/ - COMPREPLY=( $( compgen -W 'ca filebucket fileserver master - report runner status' -- "$cur" ) ) - return 0 + return ;; - --digest) - _puppet_digest - return 0 + --masterport) + COMPREPLY=( $( compgen -W '8140' -- "$cur" ) ) + return ;; - --waitforcert) + -w|--waitforcert) COMPREPLY=( $( compgen -W '0 15 30 60 120' -- "$cur" ) ) - return 0 + return ;; *) - COMPREPLY=( $( compgen -W '--daemonize --no-daemonize - --debug --detailed-exitcodes --disable --enable --help - --fqdn --logdest --onetime --serve --test --noop - --digest --fingerprint --version --verbose - --waitforcert --no-client' -- "$cur" ) ) - return 0 + _puppet_subcmd_opts "$1" $subcommand + # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize] + COMPREPLY+=( $( compgen -W '--no-daemonize' -- "$cur" ) ) + return esac ;; apply) case $prev in - --logdest) + --catalog) + COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) + _filedir json + return + ;; + --execute) + return + ;; + -l|--logdest) _puppet_logdest - return 0 + return ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version --debug - --verbose --execute --detailed-exitcodes - --logdest' -- "$cur" ) ) + _puppet_subcmd_opts "$1" $subcommand else _filedir fi - return 0 + return esac ;; cert) case $prev in --digest) _puppet_digest - return 0 + return ;; *) - subcommand=$prev - COMPREPLY=( $( compgen -W '--digest --debug --verbose' \ + action=$prev + COMPREPLY=( $( compgen -W '--digest --debug --help --verbose --version' \ -- "$cur" ) ) - case $subcommand in - --generate) + case $action in + fingerprint|list|verify|--fingerprint|--list|--verify) + COMPREPLY+=( $( compgen -W '--all' -- "$cur" ) ) + _puppet_certs --all + return + ;; + generate|--generate) _known_hosts_real "$cur" - return 0 + return ;; - --clean|--fingerprint|--revoke|--verify) - COMPREPLY+=( $( compgen -W '--all' -- "$cur" ) ) + clean|print|revoke|--clean|--print|--revoke) _puppet_certs --all - return 0 + return ;; - --sign) + sign|--sign) COMPREPLY+=( $( compgen -W '--all' -- "$cur" ) ) _puppet_certs - return 0 - ;; - --list|--print) - COMPREPLY+=( $( compgen -W '--all' -- "$cur" ) ) - return 0 + return ;; *) - COMPREPLY=( $( compgen -W '--clean --generate - --help --list --print --fingerprint --revoke - --sign --version --verify' -- "$cur" ) ) - return 0 + COMPREPLY+=( $( compgen -W 'clean fingerprint generate + list print revoke sign verify reinventory' -- "$cur" ) ) + return esac esac ;; describe) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --short --providers --list - --meta' -- "$cur" ) ) - else + _puppet_subcmd_opts "$1" $subcommand + if [[ "$cur" != -* ]]; then _puppet_types fi - return 0 + return ;; doc) case $prev in - --outputdir) + -o|--outputdir) _filedir -d - return 0 + return ;; - --mode) + -m|--mode) COMPREPLY=( $( compgen -W 'text trac pdf rdoc' -- "$cur" ) ) - return 0 + return ;; - --reference) + -r|--reference) _puppet_references - return 0 + return ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--all --help --outputdir - --mode --reference --charset --list' -- "$cur" ) ) + _puppet_subcmd_opts "$1" $subcommand else _filedir fi - return 0 + return esac ;; filebucket) case $prev in - --server) + -s|--server) _known_hosts_real "$cur" - return 0 + return ;; - --bucket) + -b|--bucket) _filedir -d - return 0 + return ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version --debug - --verbose --local --remote --server --bucket' \ - -- "$cur" ) ) + _puppet_subcmd_opts "$1" $subcommand else COMPREPLY=( $( compgen -W 'backup get restore' \ -- "$cur" ) ) _filedir fi - return 0 + return esac ;; kick) case $prev in - --class) - return 0 + -c|--class) + return ;; --host) _known_hosts_real "$cur" - return 0 + return ;; - --tag) - return 0 + -t|--tag) + return ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--all --class --debug - --foreground --help --host --no-fqdn - --ignoreschedules --tag --test --ping' -- "$cur" ) ) + _puppet_subcmd_opts "$1" $subcommand else _known_hosts_real "$cur" fi - return 0 + return esac ;; master) case $prev in - --logdest) + -l|--logdest) _puppet_logdest - return 0 + return ;; *) - COMPREPLY=( $( compgen -W '--daemonize --no-daemonize - --debug --help --logdest --verbose --version' \ - -- "$cur" ) ) - return 0 + _puppet_subcmd_opts "$1" $subcommand + # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize] + COMPREPLY+=( $( compgen -W '--no-daemonize' -- "$cur" ) ) + return + esac + ;; + parser) + action=$prev + case $action in + validate) + _filedir pp + return + ;; + *) + COMPREPLY=( $( compgen -W 'validate' -- "$cur" ) ) + return esac ;; queue) case $prev in - --logdest) + -l|--logdest) _puppet_logdest - return 0 + return ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help --version --debug - --verbose --execute --detailed-exitcodes - --logdest' -- "$cur" ) ) + _puppet_subcmd_opts "$1" $subcommand else _filedir fi - return 0 + return esac ;; resource|*) - COMPREPLY=( $( compgen -W '--help --version --debug --verbose' \ - -- "$cur" ) ) - return 0 + _puppet_subcmd_opts "$1" $subcommand + return ;; esac } && complete -F _puppet puppetmasterd puppetd puppetca ralsh puppetrun puppetqd filebucket puppetdoc puppet -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pwck b/completions/pwck index 0ed0debc..468aa7c6 100644 --- a/completions/pwck +++ b/completions/pwck @@ -7,11 +7,11 @@ _pwck() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi _filedir } && complete -F _pwck pwck -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pwd b/completions/pwd index ca00a3ff..f4a558a2 100644 --- a/completions/pwd +++ b/completions/pwd @@ -17,4 +17,4 @@ _pwd() } && complete -F _pwd pwd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pwdx b/completions/pwdx index e91d9bf4..ed8d3ec2 100644 --- a/completions/pwdx +++ b/completions/pwdx @@ -5,14 +5,20 @@ _pwdx() local cur prev words cword _init_completion || return - [[ $prev == -V ]] && return + case $prev in + -h|--help|-V|--version) + return + ;; + esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-V' -- "$cur" ) ) + local help='$( _parse_help "$1" )' + [[ $help ]] || help=-V + COMPREPLY=( $( compgen -W "$help" -- "$cur" ) ) else _pids fi } && complete -F _pwdx pwdx -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pwgen b/completions/pwgen index 3aa39a5c..d30526e9 100644 --- a/completions/pwgen +++ b/completions/pwgen @@ -25,4 +25,4 @@ _pwgen() } && complete -F _pwgen pwgen -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/py.test b/completions/py.test new file mode 100644 index 00000000..6362bf0a --- /dev/null +++ b/completions/py.test @@ -0,0 +1,71 @@ +# 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/pydoc b/completions/pydoc index 2783d174..0e750cbb 100644 --- a/completions/pydoc +++ b/completions/pydoc @@ -17,7 +17,7 @@ _pydoc() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W \ - '$( "$1" | sed -e "s/^pydoc3\{0,1\} //" | _parse_help - )' \ + '$( "$1" | command sed -e "s/^pydoc3\{0,1\} //" | _parse_help - )' \ -- "$cur" ) ) return fi @@ -30,10 +30,10 @@ _pydoc() # 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 | sed -e /^Here/d )' -- "$cur" ) ) + '$( $1 keywords topics | command sed -e /^Here/d )' -- "$cur" ) ) _filedir py } && complete -F _pydoc pydoc pydoc3 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pyflakes b/completions/pyflakes new file mode 100644 index 00000000..05025263 --- /dev/null +++ b/completions/pyflakes @@ -0,0 +1,23 @@ +# pyflakes(1) completion -*- shell-script -*- + +_pyflakes() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|--help|--version) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi + + _filedir py +} && +complete -F _pyflakes pyflakes + +# ex: filetype=sh diff --git a/completions/pylint b/completions/pylint index 8c69dce9..0383c7e2 100644 --- a/completions/pylint +++ b/completions/pylint @@ -63,4 +63,4 @@ _pylint() } && complete -F _pylint pylint -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/python b/completions/python index 9c7cec13..758b44ef 100644 --- a/completions/python +++ b/completions/python @@ -2,56 +2,62 @@ _python_modules() { - COMPREPLY+=( $( compgen -W "$( ${1:-python} -c 'import pkgutil -for mod in pkgutil.iter_modules(): print(mod[1])' )" 2>/dev/null -- "$cur" ) ) + COMPREPLY+=( $( compgen -W \ + "$( ${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python 2>/dev/null )" \ + -- "$cur" ) ) } _python() { - local cur prev words cword + local cur prev words cword prefix _init_completion || return + case $cur in + -[QWX]?*) + prefix=${cur:0:2} + prev=$prefix + cur=${cur:2} + ;; + esac + case $prev in - -'?'|-h|--help|-V|--version|-c) - return 0 + -'?'|-h|--help|-V|--version|-c|-X) + return ;; -m) _python_modules "$1" - return 0 + return ;; -Q) - COMPREPLY=( $( compgen -W "old new warn warnall" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "old new warn warnall" -P "$prefix" \ + -- "$cur" ) ) + return ;; -W) COMPREPLY=( $( compgen -W "ignore default all module once error" \ - -- "$cur" ) ) - return 0 + -P "$prefix" -- "$cur" ) ) + return ;; - !(?(*/)python*([0-9.])|-?)) - [[ $cword -lt 2 || ${words[cword-2]} != -@(Q|W) ]] \ - && _filedir + --jit) + # TODO: quite a few others, parse from "--jit help" output? + COMPREPLY=( $( compgen -W "help off" -- "$cur" ) ) + return + ;; + !(?(*/)python*([0-9.])|?(*/)pypy*([0-9.])|-?)) + [[ $cword -lt 2 || ${words[cword-2]} != -[QWX] ]] && _filedir ;; esac - # if '-c' is already given, complete all kind of files. - local i - for (( i=0; i < ${#words[@]}-1; i++ )); do - if [[ ${words[i]} == -c ]]; then - _filedir - fi - done - - - if [[ "$cur" != -* ]]; then - _filedir 'py?([co])' + # if -c or -m is already given, complete all kind of files. + if [[ "${words[@]::$cword}" == *\ -[cm]\ * ]]; then + _filedir + elif [[ "$cur" != -* ]]; then + _filedir 'py?([cowz])' else COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) fi - - return 0 } && -complete -F _python python python2 python3 +complete -F _python python python2 python3 pypy pypy3 micropython -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/pyvenv b/completions/pyvenv new file mode 100644 index 00000000..8e366a01 --- /dev/null +++ b/completions/pyvenv @@ -0,0 +1,25 @@ +# bash completion for pyvenv -*- shell-script -*- + +_pyvenv() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help) + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + _longopt "$1" + return + fi + + _filedir -d +} && +complete -F _pyvenv pyvenv pyvenv-3.{4..5} + +# ex: filetype=sh diff --git a/completions/qdbus b/completions/qdbus index a098fbc9..dee0760a 100644 --- a/completions/qdbus +++ b/completions/qdbus @@ -5,10 +5,10 @@ _qdbus() local cur prev words cword _init_completion || return - [[ -n $cur ]] && unset words[${#words[@]}-1] + [[ -n $cur ]] && unset "words[$((${#words[@]}-1))]" COMPREPLY=( $( compgen -W '$( command ${words[@]} 2>/dev/null | \ - sed s/\(.*\)// )' -- "$cur" ) ) + command sed "s/(.*)//" )' -- "$cur" ) ) } && complete -F _qdbus qdbus dcop -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/qemu b/completions/qemu index 3899715a..724e7a5f 100644 --- a/completions/qemu +++ b/completions/qemu @@ -9,91 +9,91 @@ _qemu() -fd[ab]|-hd[abcd]|-cdrom|-option-rom|-kernel|-initrd|-bootp|-pidfile| \ -loadvm|-mtdblock|-sd|-pflash|-bios) _filedir - return 0 + return ;; -tftp|-smb|-L|-chroot) _filedir -d - return 0 + return ;; -boot) COMPREPLY=( $( compgen -W 'a c d n' -- "$cur" ) ) - return 0 + return ;; -k) 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" ) ) - return 0 + return ;; -soundhw) - COMPREPLY=( $( compgen -W "$( qemu -soundhw ? | awk \ + COMPREPLY=( $( compgen -W "$( $1 -soundhw ? | awk \ '/^[[:lower:]]/ {print $1}' ) all" -- "$cur" ) ) - return 0 + return ;; -M) - COMPREPLY=( $( compgen -W "$( qemu -M ? | awk \ + COMPREPLY=( $( compgen -W "$( $1 -M ? | awk \ '/^[[:lower:]]/ {print $1}' )" -- "$cur" ) ) - return 0 + return ;; -cpu) - COMPREPLY=( $( compgen -W "$( qemu -cpu ? | awk \ + COMPREPLY=( $( compgen -W "$( $1 -cpu ? | awk \ '{print $2}' )" -- "$cur" ) ) - return 0 + return ;; -usbdevice) COMPREPLY=( $( compgen -W 'mouse tablet disk: host: serial: braille net' -- "$cur" ) ) - return 0 + return ;; -net) COMPREPLY=( $( compgen -W 'nic user tap socket vde none dump' \ -- "$cur" ) ) - return 0 + return ;; -serial|-parallel|-monitor) COMPREPLY=( $( compgen -W 'vc pty none null /dev/ file: stdio pipe: COM udp: tcp: telnet: unix: mon: braille' -- "$cur" ) ) - return 0 + return ;; -redir) COMPREPLY=( $( compgen -S":" -W 'tcp udp' -- "$cur" ) ) - return 0 + return ;; -bt) COMPREPLY=( $( compgen -W 'hci vhci device' -- "$cur" ) ) - return 0 + return ;; -vga) COMPREPLY=( $( compgen -W 'cirrus std vmware xenfb none' \ -- "$cur" ) ) - return 0 + return ;; -drive) COMPREPLY=( $( compgen -S"=" -W 'file if bus unit index media cyls snapshot cache format serial addr' -- "$cur" ) ) - return 0 + return ;; - -ballon) + -balloon) COMPREPLY=( $( compgen -W 'none virtio' -- "$cur" ) ) - return 0 + return ;; -smbios) COMPREPLY=( $( compgen -W 'file type' -- "$cur" ) ) - return 0 + return ;; -watchdog) - COMPREPLY=( $( compgen -W "$( qemu -watchdog ? 2>&1 | \ + COMPREPLY=( $( compgen -W "$( $1 -watchdog ? 2>&1 | \ awk '{print $1}' )" -- "$cur" ) ) - return 0 + return ;; -watchdog-action) COMPREPLY=( $( compgen -W 'reset shutdown poweroff pause debug none' -- "$cur" ) ) - return 0 + return ;; -runas) _allowed_users - return 0 + return ;; esac @@ -105,6 +105,6 @@ _qemu() _filedir fi } && -complete -F _qemu qemu +complete -F _qemu qemu qemu-kvm qemu-system-i386 qemu-system-x86_64 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/qrunner b/completions/qrunner index d92c011b..4e02a175 100644 --- a/completions/qrunner +++ b/completions/qrunner @@ -5,7 +5,7 @@ _qrunner() local cur prev words cword split _init_completion -s || return - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--runner --once --list --verbose --subproc @@ -15,4 +15,4 @@ _qrunner() } && complete -F _qrunner qrunner -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/querybts b/completions/querybts index 9e28887a..e08c905c 100644 --- a/completions/querybts +++ b/completions/querybts @@ -9,15 +9,15 @@ _querybts() -B|--bts) COMPREPLY=( $( compgen -W "debian guug kde mandrake help" \ -- "$cur" ) ) - return 0 + return ;; -u|--ui|--interface) COMPREPLY=( $( compgen -W "newt text gnome" -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $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 @@ -30,4 +30,4 @@ _querybts() } && complete -F _querybts querybts -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/quota b/completions/quota index 626a3802..c1604f8e 100644 --- a/completions/quota +++ b/completions/quota @@ -8,7 +8,7 @@ _user_or_group() for (( i=1; i < cword; i++ )); do if [[ "${words[i]}" == -@(g|-group) ]]; then COMPREPLY=( $( compgen -g -- "$cur" ) ) - return 0 + return fi done @@ -45,14 +45,14 @@ _quota() case $prev in -F|--format) _quota_formats - return 0 + return ;; -h|--help|-V|--version) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then _quota_parse_help "$1" @@ -70,18 +70,18 @@ _setquota() case $prev in -F|--format) _quota_formats - return 0 + return ;; -p|--prototype) _user_or_group - return 0 + return ;; -h|--help|-V|--version) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then _quota_parse_help "$1" @@ -110,22 +110,22 @@ _edquota() case $prev in -F|--format) _quota_formats - return 0 + return ;; -f|--filesystem) _filesystems - return 0 + return ;; -p|--prototype) _user_or_group - return 0 + return ;; -h|--help|-V|--version) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then _quota_parse_help "$1" @@ -143,14 +143,14 @@ _quotacheck() case $prev in -F|--format) _quota_formats - return 0 + return ;; -h|--help|-V|--version) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then _quota_parse_help "$1" @@ -168,18 +168,18 @@ _quotaon() case $prev in -F|--format) _quota_formats - return 0 + return ;; -x|--xfs-command) COMPREPLY=( $( compgen -W 'delete enforce' -- "$cur" ) ) - return 0 + return ;; -h|--help|-V|--version) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then _quota_parse_help "$1" @@ -189,4 +189,4 @@ _quotaon() } && complete -F _quotaon -o default quotaon quotaoff -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rcs b/completions/rcs index 67c1c9d8..d63fe170 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]##*/} @@ -33,4 +33,4 @@ _rcs() } && complete -F _rcs ci co rlog rcs rcsdiff -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rdesktop b/completions/rdesktop index 50273f2d..acc43098 100644 --- a/completions/rdesktop +++ b/completions/rdesktop @@ -13,15 +13,15 @@ _rdesktop() COMPREPLY+=( $( command ls $HOME/.rdesktop/keymaps 2>/dev/null ) ) COMPREPLY+=( $( command ls ./keymaps 2>/dev/null ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) - return 0 + return ;; -a) COMPREPLY=( $( compgen -W '8 15 16 24' -- "$cur" ) ) - return 0 + return ;; -x) COMPREPLY=( $( compgen -W 'broadband modem lan' -- "$cur" ) ) - return 0 + return ;; -r) case $cur in @@ -37,10 +37,10 @@ _rdesktop() [[ $COMPREPLY == *: ]] && compopt -o nospace ;; esac - return 0 + return ;; -u|-d|-s|-c|-p|-n|-g|-S|-T|-X) - return 0 + return ;; esac @@ -54,4 +54,4 @@ _rdesktop() } && complete -F _rdesktop rdesktop -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/remove_members b/completions/remove_members index 5003fcab..66dbfda6 100644 --- a/completions/remove_members +++ b/completions/remove_members @@ -8,11 +8,11 @@ _remove_members() case $prev in -f|--file) _filedir - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--file --all --fromall --nouserack @@ -24,4 +24,4 @@ _remove_members() } && complete -F _remove_members remove_members -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/removepkg b/completions/removepkg index 287952cb..eaeb70a7 100644 --- a/completions/removepkg +++ b/completions/removepkg @@ -20,4 +20,4 @@ _removepkg() } && complete -F _removepkg removepkg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/reportbug b/completions/reportbug index 83be47f5..1049d194 100644 --- a/completions/reportbug +++ b/completions/reportbug @@ -8,35 +8,35 @@ _reportbug() case $prev in -f|--filename|-i|--include|--mta|-o|--output) _filedir - return 0 + return ;; -B|--bts) COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \ "$cur" ) ) - return 0 + return ;; -e|--editor|--mua) words=( words[0] "$cur" ) cword=1 _command - return 0 + return ;; --mode) COMPREPLY=( $( compgen -W "novice standard expert" -- "$cur" ) ) - return 0 + return ;; -S|--severity) COMPREPLY=( $( compgen -W "grave serious important normal minor wishlist" -- "$cur" ) ) - return 0 + return ;; -u|--ui|--interface) COMPREPLY=( $( compgen -W "newt text gnome" -- "$cur" ) ) - return 0 + return ;; -t|--type) COMPREPLY=( $( compgen -W "gnats debbugs" -- "$cur" ) ) - return 0 + return ;; -T|--tag) COMPREPLY=( $( compgen -W "none woody potato sarge sarge-ignore @@ -44,12 +44,12 @@ _reportbug() d-i fixed fixed-in-experimental fixed-upstream help l10n moreinfo patch pending security unreproducible upstream wontfix ipv6 lfs" -- "$cur" ) ) - return 0 + return ;; --from-buildd) COMPREPLY=( $( compgen -S "_" -W '$( apt-cache dumpavail | \ command grep "^Source: $cur" | sort -u | cut -f2 -d" " )' )) - return 0 + return ;; *) ;; @@ -75,8 +75,7 @@ _reportbug() security.debian.org tech-ctte upgrade-reports www.debian.org' \ -- "$cur" ) $( apt-cache pkgnames -- "$cur" 2> /dev/null ) ) _filedir - return 0 } && complete -F _reportbug reportbug -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/resolvconf b/completions/resolvconf index c2f1b42b..1902e7d1 100644 --- a/completions/resolvconf +++ b/completions/resolvconf @@ -8,7 +8,7 @@ _resolvconf() case $prev in -a|-d) _available_interfaces - return 0 + return ;; esac @@ -18,4 +18,4 @@ _resolvconf() } && complete -F _resolvconf resolvconf -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rfkill b/completions/rfkill index 305f19d1..a3741d22 100644 --- a/completions/rfkill +++ b/completions/rfkill @@ -15,7 +15,7 @@ _rfkill() ;; 2) if [[ $prev == block || $prev == unblock ]]; then - COMPREPLY=( $( compgen -W "$(rfkill list | awk -F: \ + COMPREPLY=( $( compgen -W "$($1 list | awk -F: \ '/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \ wwan gps" -- "$cur" ) ) fi @@ -25,4 +25,4 @@ _rfkill() } && complete -F _rfkill rfkill -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ri b/completions/ri index 62a9b709..16e44664 100644 --- a/completions/ri +++ b/completions/ri @@ -34,10 +34,36 @@ _ri_get_methods() # needs at least Ruby 1.8.0 in order to use -W0 _ri() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s -n : || return - local class method prefix ri_path ri_version separator IFS + case $prev in + -h|--help|-w|--width) + return + ;; + -f|--format) + COMPREPLY=( $( compgen -W 'ansi bs html rdoc' -- "$cur" ) ) + return + ;; + -d|--doc-dir) + _filedir -d + return + ;; + --dump) + _filedir ri + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + local class method prefix ri_path ri_version ri_major separator IFS local -a classes ri_path=$(type -p ri) @@ -46,6 +72,7 @@ _ri() # from being captured when used with Ruby 1.8.1 and later ri_version="$(ruby -W0 $ri_path -v 2>&1)" || ri_version=integrated [[ $ri_version != ${ri_version%200*} ]] && ri_version=integrated + [[ $ri_version =~ ri[[:space:]]v?([0-9]+) ]] && ri_major=${BASH_REMATCH[1]} # need to also split on commas IFS=$', \n\t' @@ -57,13 +84,15 @@ _ri() classes=( $class ) prefix="-P $class$separator" _ri_get_methods - return 0 + return fi 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 ) ) + elif [[ $ri_major && $ri_major -ge 3 ]]; then + classes=( $( ri -l 2>/dev/null ) ) elif [[ $ri_version == "ri 1.8a" ]]; then classes=( $( ruby -W0 $ri_path | \ ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \ @@ -75,9 +104,11 @@ _ri() fi COMPREPLY=( $( compgen -W '${classes[@]}' -- "$cur" ) ) + __ltrim_colon_completions "$cur" + if [[ "$cur" == [A-Z]* ]]; then # we're completing on class or module alone - return 0 + return fi # we're completing on methods @@ -86,4 +117,4 @@ _ri() } && complete -F _ri ri -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rmlist b/completions/rmlist index dd31333c..ff827473 100644 --- a/completions/rmlist +++ b/completions/rmlist @@ -14,4 +14,4 @@ _rmlist() } && complete -F _rmlist rmlist -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rmmod b/completions/rmmod index 20d3bfce..9868c79a 100644 --- a/completions/rmmod +++ b/completions/rmmod @@ -18,8 +18,7 @@ _rmmod() fi _installed_modules "$cur" - return 0 } && complete -F _rmmod rmmod -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/route b/completions/route index 40d4f490..128ebc16 100644 --- a/completions/route +++ b/completions/route @@ -9,7 +9,7 @@ _route() if [[ $prev == dev ]]; then _available_interfaces - return 0 + return fi # Remove already given options from completions @@ -27,4 +27,4 @@ _route() } && complete -F _route route -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rpcdebug b/completions/rpcdebug index 3501af13..4eb332fd 100644 --- a/completions/rpcdebug +++ b/completions/rpcdebug @@ -13,7 +13,7 @@ _rpcdebug_flags() if [[ -n $module ]]; then COMPREPLY=( $( compgen -W "$( rpcdebug -vh 2>&1 | \ - sed -ne 's/^'$module'[[:space:]]\{1,\}//p' )" -- "$cur" ) ) + command sed -ne 's/^'$module'[[:space:]]\{1,\}//p' )" -- "$cur" ) ) fi } @@ -25,15 +25,15 @@ _rpcdebug() case $prev in -s) _rpcdebug_flags - return 0 + return ;; -c) _rpcdebug_flags - return 0 + return ;; -m) COMPREPLY=( $( compgen -W 'rpc nfs nfsd nlm' -- "$cur" ) ) - return 0 + return ;; esac @@ -44,4 +44,4 @@ _rpcdebug() } && complete -F _rpcdebug rpcdebug -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rpm b/completions/rpm index a66534a6..6b4e66fa 100644 --- a/completions/rpm +++ b/completions/rpm @@ -7,7 +7,7 @@ _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 "$( sed -ne \ + COMPREPLY=( $( compgen -W "$( command sed -ne \ 's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \ /var/log/rpmpkgs )" -- "$cur" ) ) elif type rpmqpack &>/dev/null ; then @@ -29,14 +29,14 @@ _rpm_groups() _rpm_macros() { # get a list of macros - COMPREPLY=( $( compgen -W "$( ${1:-rpm} --showrc | sed -ne \ + 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 | sed -ne \ + COMPREPLY=( $( compgen -W "$( ${1:-rpm} --showrc | command sed -ne \ 's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p' )" \ -- "$cur" ) ) } @@ -63,63 +63,60 @@ _rpm() -- "$cur" ) ) ;; esac - return 0 + return fi case $prev in --dbpath|--excludepath|--prefix|--relocate|--root|-r) _filedir -d - return 0 + return ;; --eval|-E) _rpm_macros $1 - return 0 + return ;; --pipe) compopt -o filenames COMPREPLY=( $( compgen -c -- "$cur" ) ) - return 0 + return ;; --rcfile) _filedir - return 0 + return ;; --specfile) # complete on .spec files _filedir spec - return 0 + return ;; - --whatprovides) + --whatenhances|--whatprovides|--whatrecommends|--whatrequires|\ + --whatsuggests|--whatsupplements) if [[ "$cur" == */* ]]; then _filedir else # complete on capabilities - local IFS=$'\n' + local IFS=$'\n' fmt + case $prev in + *enhances) fmt=ENHANCENAME ;; + *provides) fmt=PROVIDENAME ;; + *recommends) fmt=RECOMMENDNAME ;; + *requires) fmt=REQUIRENAME ;; + *suggests) fmt=SUGGESTNAME ;; + *supplements) fmt=SUPPLEMENTNAME ;; + esac COMPREPLY=( $( compgen -W "$( $1 -qa --nodigest --nosignature \ - --queryformat='%{PROVIDENAME}\n' 2>/dev/null )" \ - -- "$cur" ) ) + --queryformat=\"%{$fmt}\\n\" 2>/dev/null | + command grep -vF '(none)' )" -- "$cur" ) ) fi - return 0 - ;; - --whatrequires) - if [[ "$cur" == */* ]]; then - _filedir - else - # complete on capabilities - local IFS=$'\n' - COMPREPLY=( $( compgen -W "$( $1 -qa --nodigest --nosignature \ - --queryformat='%{REQUIRENAME}\n' 2>/dev/null )" \ - -- "$cur" ) ) - fi - return 0 + return ;; --define|-D|--fileid|--hdrid|--pkgid) # argument required but no completions available - return 0 + return ;; esac - $split && return 0 + $split && return # options common to all modes local opts="--define= --eval= --macros= --nodigest --nosignature --rcfile= @@ -153,7 +150,8 @@ _rpm() --enhances --filesbypkg --filecaps --fileclass --filecolor --fileprovide --filerequire --filesbypkg --info --list --obsoletes --pipe --provides --queryformat= --requires - --scripts --suggests --triggers --xml" + --scripts --suggests --triggers --xml --recommends + --supplements --filetriggers" if [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then # -qf completion @@ -180,7 +178,9 @@ _rpm() COMPREPLY=( $( compgen -W "$opts --all --file --fileid --dbpath --fscontext --ftswalk --group --hdrid --last --package --pkgid --root= --specfile --state - --triggeredby --whatprovides --whatrequires" \ + --triggeredby --whatenhances --whatprovides + --whatrecommends --whatrequires --whatsuggests + --whatsupplements" \ -- "$cur" ) ) elif [[ ${words[@]} != *\ -@(*([^ -])a|-all )* ]]; then _rpm_installed_packages $1 @@ -200,7 +200,9 @@ _rpm() COMPREPLY=( $( compgen -W "$opts --root= --dbpath --nodeps --nogroup --nolinkto --nomode --nomtime --nordev --nouser --nofiles --noscripts --nomd5 --querytags --specfile - --whatrequires --whatprovides" -- "$cur" ) ) + --whatenhances --whatprovides --whatrecommends + --whatrequires --whatsuggests --whatsupplements" \ + -- "$cur" ) ) # check whether we're doing file completion elif [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then _filedir @@ -228,8 +230,6 @@ _rpm() ;; esac [[ $COMPREPLY == *= ]] && compopt -o nospace - - return 0 } && complete -F _rpm rpm @@ -244,45 +244,45 @@ _rpmbuild() case $prev in --buildroot|--root|-r|--dbpath) _filedir -d - return 0 + return ;; --target) _rpm_buildarchs - return 0 + return ;; --eval|-E) _rpm_macros $rpm - return 0 + return ;; --macros|--rcfile) _filedir - return 0 + return ;; --buildpolicy) local cfgdir=$( $rpm --eval '%{_rpmconfigdir}' 2>/dev/null ) if [[ $cfgdir ]]; then COMPREPLY=( $( compgen -W "$( command ls $cfgdir 2>/dev/null \ - | sed -ne 's/^brp-//p' )" -- "$cur" ) ) + | command sed -ne 's/^brp-//p' )" -- "$cur" ) ) fi ;; --define|-D|--with|--without) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi # Figure out file extensions to complete local word ext for word in ${words[@]}; do case $word in - -b?) + -b?|--clean|--nobuild) ext=spec break ;; @@ -300,4 +300,4 @@ _rpmbuild() } && complete -F _rpmbuild rpmbuild rpmbuild-md5 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rpm2tgz b/completions/rpm2tgz index 34e54a5a..abdf321b 100644 --- a/completions/rpm2tgz +++ b/completions/rpm2tgz @@ -11,6 +11,7 @@ _rpm2tgz() fi _filedir "rpm" -} && complete -F _rpm2tgz rpm2tgz rpm2txz rpm2targz +} && +complete -F _rpm2tgz rpm2tgz rpm2txz rpm2targz -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rpmcheck b/completions/rpmcheck index dce7319e..565f1313 100644 --- a/completions/rpmcheck +++ b/completions/rpmcheck @@ -8,7 +8,7 @@ _rpmcheck() case $prev in -base) _filedir - return 0 + return ;; esac @@ -21,4 +21,4 @@ _rpmcheck() } && complete -F _rpmcheck rpmcheck -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rrdtool b/completions/rrdtool index c7d2bd2a..705be0d0 100644 --- a/completions/rrdtool +++ b/completions/rrdtool @@ -14,4 +14,4 @@ _rrdtool () } && complete -F _rrdtool rrdtool -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/rsync b/completions/rsync index 04e1cda1..d72f6324 100644 --- a/completions/rsync +++ b/completions/rsync @@ -5,34 +5,34 @@ _rsync() local cur prev words cword split _init_completion -s -n : || return - _expand || return 0 + _expand || return case $prev in --config|--password-file|--include-from|--exclude-from|--files-from|\ --log-file|--write-batch|--only-write-batch|--read-batch) compopt +o nospace _filedir - return 0 + return ;; -T|--temp-dir|--compare-dest|--backup-dir|--partial-dir|--copy-dest|\ --link-dest) compopt +o nospace _filedir -d - return 0 + return ;; -e|--rsh) compopt +o nospace COMPREPLY=( $( compgen -W 'rsh ssh' -- "$cur" ) ) - return 0 + return ;; --compress-level) compopt +o nospace COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) - return 0 + return ;; esac - $split && return 0 + $split && return case $cur in -*) @@ -80,9 +80,7 @@ _rsync() _xfunc ssh _scp_local_files ;; esac - - return 0 } && complete -F _rsync -o nospace rsync -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sbcl b/completions/sbcl index 28cb9d80..3db4a39a 100644 --- a/completions/sbcl +++ b/completions/sbcl @@ -15,9 +15,7 @@ _sbcl() else _filedir fi - - return 0 } && complete -F _sbcl sbcl sbcl-mt -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sbopkg b/completions/sbopkg index f6589103..e5742af6 100644 --- a/completions/sbopkg +++ b/completions/sbopkg @@ -40,6 +40,7 @@ _sbopkg() for (( i=${#words[@]}-1; i>0; i-- )); do if [[ "${words[i]}" == -f ]]; then config="${words[i+1]}" + __expand_tilde_by_ref config break fi done @@ -60,9 +61,10 @@ _sbopkg() done [[ -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]] || return - COMPREPLY=( $( sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\ + 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 +} && +complete -F _sbopkg sbopkg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/screen b/completions/screen index 1ba1b24b..6b5c319f 100644 --- a/completions/screen +++ b/completions/screen @@ -2,7 +2,7 @@ _screen_sessions() { - local sessions=( $( command screen -ls | sed -ne \ + 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 @@ -29,7 +29,7 @@ _screen() case ${words[cword-2]} in -[dD]) _screen_sessions - return 0 + return ;; esac fi @@ -54,32 +54,32 @@ _screen() -[rR]) # list detached _screen_sessions 'Detached' - return 0 + return ;; -[dD]) # list attached _screen_sessions 'Attached' - return 0 + return ;; -x) # list both _screen_sessions - return 0 + return ;; -s) _shells - return 0 + return ;; -c) _filedir - return 0 + return ;; -T) _terms - return 0 + return ;; -e|-h|-p|-S|-t) - return 0 + return ;; esac @@ -91,4 +91,4 @@ _screen() } && complete -F _screen screen -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sh b/completions/sh index b70e53e2..fd785a6d 100644 --- a/completions/sh +++ b/completions/sh @@ -7,27 +7,30 @@ _sh() case $prev in -c) - return 0 + return ;; -o|+o) COMPREPLY=( $( compgen -W 'allexport errexit ignoreeof monitor noclobber noglob noexec nolog notify nounset verbose vi xtrace' -- "$cur" ) ) - return 0 + 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" ) ) - return 0 + return elif [[ "$cur" == +* ]]; then COMPREPLY=( $( compgen -W "${opts//-/+}" -- "$cur" ) ) - return 0 + return fi - _filedir sh + local args ext= + _count_args + [[ $args -eq 1 ]] && ext=sh + _filedir $ext } && complete -F _sh sh -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sitecopy b/completions/sitecopy index 12480e97..ef1310df 100644 --- a/completions/sitecopy +++ b/completions/sitecopy @@ -13,15 +13,15 @@ _sitecopy() COMPREPLY=( $( compgen -W "socket files rcfile ftp http httpbody rsh sftp xml xmlparse cleartext" -- "$cur" ) ) compopt -o nospace - return 0 + return ;; --logfile|-g|--rcfile|-r) _filedir - return 0 + return ;; --storepath|-p) _filedir -d - return 0 + return ;; esac @@ -29,14 +29,14 @@ _sitecopy() --*) COMPREPLY=( $( compgen -W "$(_parse_help $1)" -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return ;; # only complete long options -) compopt -o nospace COMPREPLY=( -- ) - return 0 + return ;; esac @@ -44,8 +44,7 @@ _sitecopy() COMPREPLY=( $( compgen -W "$($1 -v | \ command sed -n '/^Site:/s/Site: //p')" -- "$cur" ) ) fi - return 0 } && complete -F _sitecopy -o default sitecopy -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/slackpkg b/completions/slackpkg index dab9c6d4..83396a4e 100644 --- a/completions/slackpkg +++ b/completions/slackpkg @@ -79,12 +79,12 @@ _slackpkg() 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 | \ - grep "^$cur" ) ) + command grep "^$cur" ) ) return ;; info) COMPREPLY=( $( cut -f 6 -d\ "${WORKDIR}/pkglist" 2> /dev/null | \ - grep "^$cur" ) ) + command grep "^$cur" ) ) return ;; update) @@ -101,6 +101,7 @@ _slackpkg() ;; esac -} && complete -F _slackpkg slackpkg +} && +complete -F _slackpkg slackpkg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/slapt-get b/completions/slapt-get index 93d110bc..512981b6 100644 --- a/completions/slapt-get +++ b/completions/slapt-get @@ -45,6 +45,7 @@ _slapt_get() for (( i=${#words[@]}-1; i>0; i-- )); do if [[ ${words[i]} == -@(c|-config) ]]; then config="${words[i+1]}" + __expand_tilde_by_ref config break fi done @@ -55,13 +56,13 @@ _slapt_get() # slapt-get will fail to search for "^name-version" # it can search for names only local name=${cur%%-*} - COMPREPLY=( $( slapt-get -c $config --search "^$name" 2>/dev/null |\ - 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=( $( slapt-get -c $config --available 2>/dev/null | \ - 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 @@ -74,6 +75,7 @@ _slapt_get() return ;; esac -} && complete -F _slapt_get slapt-get +} && +complete -F _slapt_get slapt-get -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/slapt-src b/completions/slapt-src index 94ddb892..2f65415f 100644 --- a/completions/slapt-src +++ b/completions/slapt-src @@ -2,8 +2,8 @@ _slapt_src() { - local cur prev words cword - _init_completion -n : || return + local cur prev words cword split + _init_completion -s -n : || return case "$prev" in --config|-c) @@ -16,6 +16,8 @@ _slapt_src() ;; esac + $split && return + if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace @@ -25,7 +27,7 @@ _slapt_src() local i t # search for last action (-i|-w|-b|-f) for (( i=${#words[@]}-1; i>0; i-- )); do - if [[ ${words[i]} == -@(i|w|f|b|-install|-show|-build|-fetch) ]]; then + if [[ ${words[i]} == -@([iwfb]|-install|-show|-build|-fetch) ]]; then t="all" break fi @@ -39,6 +41,11 @@ _slapt_src() for (( i=${#words[@]}-1; i>0; i-- )); do if [[ ${words[i]} == -@(c|-config) ]]; then config="${words[i+1]}" + __expand_tilde_by_ref config + break + fi + if [[ ${words[i]} == --config=?* ]]; then + config="${words[i]#*=}" break fi done @@ -47,12 +54,14 @@ _slapt_src() if [[ "$cur" == *:* ]]; then local name=${cur%:*} local version=${cur##*:} - COMPREPLY=( $( slapt-src --config "$config" --search "^$name" 2> \ - /dev/null | 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=( $( slapt-src --config "$config" --search "^$cur" 2> \ - /dev/null | 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 +} && +complete -F _slapt_src slapt-src -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/smartctl b/completions/smartctl index bc0d0c01..3e952aa2 100644 --- a/completions/smartctl +++ b/completions/smartctl @@ -72,7 +72,7 @@ _smartctl_presets() } _smartctl_test() { - [[ $cur == @(pending|scttempint|vendor), ]] && return 0 + [[ $cur == @(pending|scttempint|vendor), ]] && return COMPREPLY=( $( compgen -W 'offline short long conveyance select, select,redo select,next afterselect,on afterselect,off pending, scttempint, vendor,' -- "$cur" ) ) @@ -100,55 +100,55 @@ _smartctl() ;; -d|--device) _smartctl_device - return 0 + return ;; -T|--tolerance) _smartctl_tolerance - return 0 + return ;; -b|--badsum) _smartctl_badsum - return 0 + return ;; -r|--report) _smartctl_report - return 0 + return ;; -n|--nocheck) _smartctl_powermode - return 0 + return ;; -s|--smart|-o|--offlineauto|-S|--saveauto) _smartctl_feature - return 0 + return ;; -l|--log) _smartctl_log - return 0 + return ;; -v|--vendorattribute) _smartctl_vendorattribute - return 0 + return ;; -F|--firmwarebug) _smartctl_firmwarebug - return 0 + return ;; -P|--presets) _smartctl_presets - return 0 + return ;; -B|--drivedb) _smartctl_drivedb - return 0 + return ;; -t|--test) _smartctl_test - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --version --info --all --xall @@ -165,4 +165,4 @@ _smartctl() } && complete -F _smartctl smartctl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/smbclient b/completions/smbclient index fe14f940..3a5616cd 100644 --- a/completions/smbclient +++ b/completions/smbclient @@ -16,7 +16,7 @@ _samba_hosts() { if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then COMPREPLY=( $( compgen -W "$( smbtree -N -S | \ - sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \ + command sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \ )" -- "$cur" ) ) fi } @@ -46,57 +46,57 @@ _smbclient() case $prev in -R|--name-resolve) _samba_resolve_order - return 0 + return ;; -t) COMPREPLY=( $( compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \ -- "$cur" ) ) - return 0 + return ;; -s|--configfile|-A|--authentication-file) _filedir - return 0 + return ;; -l|--log-basename|-D|--directory) _filedir -d - return 0 + return ;; -O|--socket-options) _samba_sockopts - return 0 + return ;; -T) COMPREPLY=( $( compgen -W 'c x I X F b g q r N a' -- "$cur" ) ) - return 0 + return ;; -W|--workgroup) _samba_domains - return 0 + return ;; -d|--debuglevel) _samba_debuglevel - return 0 + return ;; -L|--list) _samba_hosts - return 0 + return ;; -S|--signing) _samba_signing - return 0 + 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 - return 0 + return ;; -\?|--help|-V|--version) # all other arguments are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -113,22 +113,22 @@ _smbget() case $prev in -o|--outputfile|-f|--rcfile) _filedir - return 0 + return ;; -d|--debuglevel) _samba_debuglevel - return 0 + return ;; -w|--workgroup) _samba_domains - return 0 + return ;; -u|--username|-p|--password|-b|--blocksize) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -145,35 +145,35 @@ _smbcacls() case $prev in -s|--configfile|-A|--authentication-file) _filedir - return 0 + return ;; -l|--log-basename) _filedir -d - return 0 + return ;; -d|--debuglevel) _samba_debuglevel - return 0 + return ;; --signing) _samba_signing - return 0 + return ;; -O|--socket-options) _samba_sockopts - return 0 + return ;; -W|--workgroup) _samba_domains - return 0 + return ;; -\?|--help|--usage|-D|--delete|-M|--modify|-a|--add|-S|--set|-C|\ --chown|-G|--chgrp|-n|--netbiosname|-i|--scope|-U|--user) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -190,26 +190,26 @@ _smbcquotas() case $prev in -s|--configfile|-A|--authentication-file) _filedir - return 0 + return ;; -l|--log-basename) _filedir -d - return 0 + return ;; -d|--debuglevel) _samba_debuglevel - return 0 + return ;; --signing) _samba_signing - return 0 + return ;; -\?|--help|--usage|-U|-u|--user|-S|--set) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -226,22 +226,22 @@ _smbpasswd() case $prev in -r) _samba_hosts - return 0 + return ;; -R) _samba_resolve_order - return 0 + return ;; -c) _filedir - return 0 + return ;; -D) _samba_debuglevel - return 0 + return ;; -U|-h|-w) - return 0 + return ;; esac @@ -259,22 +259,22 @@ _smbtar() case $prev in -r|-t) _filedir tar - return 0 + return ;; -s) _samba_hosts - return 0 + return ;; -l) _samba_debuglevel - return 0 + return ;; -N) _filedir - return 0 + return ;; -p|-x|-b|-d|-u) - return 0 + return ;; esac @@ -292,26 +292,26 @@ _smbtree() case $prev in -s|--configfile|-A|--authentication-file) _filedir - return 0 + return ;; -l|--log-basename) _filedir -d - return 0 + return ;; -d|--debuglevel) _samba_debuglevel - return 0 + return ;; -S|--signing) _samba_signing - return 0 + return ;; -\?|--help|--usage|-U|--user) - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) @@ -320,4 +320,4 @@ _smbtree() } && complete -F _smbtree smbtree -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/snownews b/completions/snownews index 0cb35cdc..b5b070da 100644 --- a/completions/snownews +++ b/completions/snownews @@ -12,4 +12,4 @@ _snownews() } && complete -F _snownews snownews -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sqlite3 b/completions/sqlite3 index e97c2e9e..37d78a01 100644 --- a/completions/sqlite3 +++ b/completions/sqlite3 @@ -9,21 +9,21 @@ _sqlite3() case $prev in -help|-version|-separator|-nullvalue|*.$dbexts) - return 0 + return ;; -init) _filedir - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) - return 0 + return fi - _filedir $dbexts + _filedir "$dbexts" } && complete -F _sqlite3 sqlite3 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ss b/completions/ss index 655f1f1f..63e6a458 100644 --- a/completions/ss +++ b/completions/ss @@ -17,7 +17,7 @@ _ss() -A|--query) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," COMPREPLY=( $( compgen -P "$prefix" -W '$( "$1" --help | \ - sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p" )' \ + command sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p" )' \ -- "${cur##*,}" ) ) return ;; @@ -36,4 +36,4 @@ _ss() } && complete -F _ss ss -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ssh b/completions/ssh index ebd7424a..ecd50e57 100644 --- a/completions/ssh +++ b/completions/ssh @@ -1,16 +1,31 @@ # ssh(1) completion -*- shell-script -*- +_ssh_queries() +{ + COMPREPLY+=( $( compgen -W \ + "cipher cipher-auth mac kex key protocol-version" -- "$cur" ) ) +} + +_ssh_query() +{ + ${1:-ssh} -Q $2 2>/dev/null +} + _ssh_ciphers() { - COMPREPLY+=( $( compgen -W '3des-cbc aes128-cbc aes192-cbc aes256-cbc + 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' -- "$cur" ) ) + blowfish-cbc cast128-cbc" + COMPREPLY+=( $( compgen -W "$ciphers" -- "$cur" ) ) } _ssh_macs() { - COMPREPLY+=( $( compgen -W 'hmac-md5 hmac-sha1 umac-64@openssh.com - hmac-ripemd160 hmac-sha1-96 hmac-md5-96' -- "$cur" ) ) + 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" ) ) } _ssh_options() @@ -39,7 +54,8 @@ _ssh_options() } # Complete a ssh suboption (like ForwardAgent=y<tab>) -# Only one parameter: the string to complete including the equal sign. +# Two parameters: the string to complete including the equal sign, and +# the ssh executable to invoke (optional). # Not all suboptions are completed. # Doesn't handle comma-separated lists. _ssh_suboption() @@ -74,6 +90,12 @@ _ssh_suboption() COMPREPLY=( $( compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3} cs{0..7} ef lowdelay throughput reliability' -- "$cur" ) ) ;; + HostbasedKeyTypes|HostKeyAlgorithms) + COMPREPLY=( $( compgen -W '$( _ssh_query "$2" key )' -- "$cur" ) ) + ;; + KexAlgorithms) + COMPREPLY=( $( compgen -W '$( _ssh_query "$2" kex )' -- "$cur" ) ) + ;; Protocol) COMPREPLY=( $( compgen -W '1 2 1,2 2,1' -- "$cur" ) ) ;; @@ -89,10 +111,10 @@ _ssh_suboption() keyboard-interactive password' -- "$cur" ) ) ;; MACs) - _ssh_macs + _ssh_macs "$2" ;; Ciphers) - _ssh_ciphers + _ssh_ciphers "$2" ;; esac return 0 @@ -106,57 +128,78 @@ _ssh_suboption_check() # Get prev and cur words without splitting on = local cureq=`_get_cword :=` preveq=`_get_pword :=` if [[ $cureq == *=* && $preveq == -o ]]; then - _ssh_suboption $cureq + _ssh_suboption $cureq "$1" return $? fi return 1 } +# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument +_ssh_configfile() +{ + set -- "${words[@]}" + while [[ $# -gt 0 ]]; do + if [[ $1 == -F* ]]; then + if [[ ${#1} -gt 2 ]]; then + configfile="$(dequote "${1:2}")" + else + shift + [[ $1 ]] && configfile="$(dequote "$1")" + fi + break + fi + shift + done +} + _ssh() { local cur prev words cword _init_completion -n : || return - local configfile local -a config - _ssh_suboption_check && return 0 + _ssh_suboption_check "$1" && return case $prev in -F|-i|-S) _filedir - return 0 + return ;; -c) - _ssh_ciphers - return 0 + _ssh_ciphers "$1" + return ;; -m) - _ssh_macs - return 0 + _ssh_macs "$1" + return ;; -l) COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 + return ;; -O) COMPREPLY=( $( compgen -W 'check forward exit stop' -- "$cur" ) ) - return 0 + return ;; -o) _ssh_options - return 0 + return + ;; + -Q) + _ssh_queries "$1" + return ;; -w) _available_interfaces - return 0 + return ;; -b) _ip_addresses - return 0 + return ;; -D|-e|-I|-L|-p|-R|-W) - return 0 + return ;; esac @@ -169,30 +212,19 @@ _ssh() elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument - set -- "${words[@]}" - while [[ $# -gt 0 ]]; do - if [[ $1 == -F* ]]; then - if [[ ${#1} -gt 2 ]]; then - configfile="$(dequote "${1:2}")" - else - shift - [[ $1 ]] && configfile="$(dequote "$1")" - fi - break - fi - shift - done + local configfile + _ssh_configfile _known_hosts_real -a -F "$configfile" "$cur" - if [[ $cword -ne 1 ]]; then + + local args + _count_args + if [[ $args -gt 1 ]]; then compopt -o filenames COMPREPLY+=( $( compgen -c -- "$cur" ) ) fi fi - - return 0 } && -shopt -u hostcomplete && complete -F _ssh ssh slogin autossh +shopt -u hostcomplete && complete -F _ssh ssh slogin autossh sidedoor # sftp(1) completion # @@ -201,25 +233,27 @@ _sftp() local cur prev words cword _init_completion || return - local configfile - - _ssh_suboption_check && return 0 + _ssh_suboption_check && return case $prev in -b|-F|-i) _filedir - return 0 + return ;; -o) _ssh_options - return 0 + return ;; -c) _ssh_ciphers - return 0 + return + ;; + -S) + _command + return ;; - -B|-D|-P|-R|-S|-s) - return 0 + -B|-D|-l|-P|-R|-s) + return ;; esac @@ -232,24 +266,10 @@ _sftp() elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - # Search COMP_WORDS for '-F configfile' argument - set -- "${words[@]}" - while [[ $# -gt 0 ]]; do - if [[ $1 == -F* ]]; then - if [[ ${#1} -gt 2 ]]; then - configfile="$(dequote "${1:2}")" - else - shift - [[ $1 ]] && configfile="$(dequote "$1")" - fi - break - fi - shift - done + local configfile + _ssh_configfile _known_hosts_real -a -F "$configfile" "$cur" fi - - return 0 } && shopt -u hostcomplete && complete -F _sftp sftp @@ -269,7 +289,7 @@ _scp_remote_files() local path=${cur#*:} # unescape (3 backslashes to 1 for chars we escaped) - path=$( 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 @@ -281,13 +301,13 @@ _scp_remote_files() # escape problematic characters; remove non-dirs files=$( ssh -o 'Batchmode yes' $userhost \ command ls -aF1dL "$path*" 2>/dev/null | \ - 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 \ command ls -aF1dL "$path*" 2>/dev/null | \ - sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \ + command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \ -e 's/[^\/]$/& /g' ) fi COMPREPLY+=( $files ) @@ -309,10 +329,10 @@ _scp_local_files() if $dirsonly ; then COMPREPLY+=( $( command ls -aF1dL $cur* 2>/dev/null | \ - sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") ) + command sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") ) else COMPREPLY+=( $( command ls -aF1dL $cur* 2>/dev/null | \ - sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \ + command sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \ -e 's/[^\/]$/& /g' -e "s/^/$1/") ) fi } @@ -324,79 +344,69 @@ _scp() local cur prev words cword _init_completion -n : || return - local configfile prefix + local prefix _ssh_suboption_check && { COMPREPLY=( "${COMPREPLY[@]/%/ }" ) - return 0 + return } case $prev in -l|-P) - return 0 + return ;; - -F|-i|-S) + -F|-i) _filedir compopt +o nospace - return 0 + return ;; -c) _ssh_ciphers COMPREPLY=( "${COMPREPLY[@]/%/ }" ) - return 0 + return ;; -o) _ssh_options - return 0 + return + ;; + -S) + _command + compopt +o nospace + return ;; esac - _expand || return 0 + _expand || return case $cur in !(*:*)/*|[.~]*) ;; # looks like a path - *:*) _scp_remote_files ; return 0 ;; + *:*) _scp_remote_files ; return ;; esac if [[ "$cur" == -F* ]]; then cur=${cur#-F} prefix=-F else - # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument - set -- "${words[@]}" - while [[ $# -gt 0 ]]; do - if [[ $1 == -F* ]]; then - if [[ ${#1} -gt 2 ]]; then - configfile="$(dequote "${1:2}")" - else - shift - [[ $1 ]] && configfile="$(dequote "$1")" - fi - break - fi - shift - done - case $cur in -*) COMPREPLY=( $( compgen -W '$( _parse_usage "${words[0]}" )' \ -- "$cur" ) ) COMPREPLY=( "${COMPREPLY[@]/%/ }" ) - return 0 + return ;; */*|[.~]*) # not a known host, pass through ;; *) + local configfile + _ssh_configfile _known_hosts_real -c -a -F "$configfile" "$cur" ;; esac fi _scp_local_files "$prefix" - - return 0 } && complete -F _scp -o nospace scp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ssh-add b/completions/ssh-add index 1d563688..1885c37a 100644 --- a/completions/ssh-add +++ b/completions/ssh-add @@ -12,7 +12,7 @@ _ssh_add() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" -? )' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" "-\?" )' -- "$cur" ) ) return fi @@ -20,4 +20,4 @@ _ssh_add() } && complete -F _ssh_add ssh-add -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ssh-copy-id b/completions/ssh-copy-id index 9c5af9ca..bd8c8fe0 100644 --- a/completions/ssh-copy-id +++ b/completions/ssh-copy-id @@ -7,8 +7,8 @@ _ssh_copy_id() case $prev in -i) - _filedir - return 0 + _filedir pub + return ;; esac @@ -17,9 +17,7 @@ _ssh_copy_id() else _known_hosts_real -a "$cur" fi - - return 0 } && complete -F _ssh_copy_id ssh-copy-id -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ssh-keygen b/completions/ssh-keygen new file mode 100644 index 00000000..f72b9aa2 --- /dev/null +++ b/completions/ssh-keygen @@ -0,0 +1,50 @@ +# ssh-keygen(1) completion -*- shell-script -*- + +_ssh_keygen() +{ + local cur prev words cword + _init_completion -n = || return + + case $prev in + -a|-b|-C|-D|-I|-J|-j|-M|-N|-n|-r|-P|-S|-V|-W|-z) + return + ;; + -F|-R) + # TODO: trim this down to actual entries in known hosts files + _known_hosts_real "$cur" + return + ;; + -f|-G|-K|-s|-T) + _filedir + return + ;; + -m) + COMPREPLY=( $( compgen -W 'PEM PKCS8 RFC4716' -- "$cur" ) ) + return + ;; + -O) + if [[ $cur != *=* ]]; then + 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" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + fi + return + ;; + -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" ) ) + fi +} && +complete -F _ssh_keygen ssh-keygen + +# ex: filetype=sh diff --git a/completions/sshfs b/completions/sshfs index 90a92645..4f6d1a1b 100644 --- a/completions/sshfs +++ b/completions/sshfs @@ -7,21 +7,19 @@ _sshfs() local userhost path - _expand || return 0 + _expand || return if [[ "$cur" == *:* ]]; then _xfunc ssh _scp_remote_files -d # unlike scp and rsync, sshfs works with 1 backslash instead of 3 COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" ) - return 0 + return fi [[ "$cur" == @(*/|[.~])* ]] || _known_hosts_real -c -a "$cur" _xfunc ssh _scp_local_files -d - - return 0 } && complete -F _sshfs -o nospace sshfs -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sshmitm b/completions/sshmitm index 829bfcd5..f7332201 100644 --- a/completions/sshmitm +++ b/completions/sshmitm @@ -14,4 +14,4 @@ _sshmitm() } && complete -F _sshmitm sshmitm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sshow b/completions/sshow index 2e9bd467..8c3cdc4c 100644 --- a/completions/sshow +++ b/completions/sshow @@ -8,7 +8,7 @@ _sshow() case $prev in -i) _available_interfaces -a - return 0 + return ;; esac @@ -19,4 +19,4 @@ _sshow() } && complete -F _sshow sshow -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/strace b/completions/strace index 0b8f0e9c..eae169b4 100644 --- a/completions/strace +++ b/completions/strace @@ -59,7 +59,7 @@ _strace() COMPREPLY=( $( compgen -W '${!syscalls[@]} file process network signal ipc desc all none' \ -- "$cur" ) ) - return 0 + return ;; esac else @@ -67,24 +67,24 @@ _strace() COMPREPLY=( $( compgen -S"=" -W 'trace abbrev verbose raw signal read write' -- "$cur" ) ) fi - return 0 + return ;; -o) _filedir - return 0 + return ;; -p) _pids - return 0 + return ;; -S) COMPREPLY=( $( compgen -W 'time calls name nothing' \ -- "$cur" ) ) - return 0 + return ;; -u) _allowed_users - return 0 + return ;; esac @@ -98,4 +98,4 @@ _strace() } && complete -F _strace -o default strace -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/strings b/completions/strings index 8f47d374..27c00497 100644 --- a/completions/strings +++ b/completions/strings @@ -14,8 +14,8 @@ _strings() return ;; -T|--target) - COMPREPLY=( $( compgen -W '$( "$1" --help 2>/dev/null | \ - sed -ne "s/: supported targets: \(.*\)/\1/p" )' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( LC_ALL=C "$1" --help 2>/dev/null | \ + command sed -ne "s/: supported targets: \(.*\)/\1/p" )' -- "$cur" ) ) return ;; -e|--encoding) @@ -41,4 +41,4 @@ _strings() } && complete -F _strings strings -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sudo b/completions/sudo index b13b7313..2fe1c001 100644 --- a/completions/sudo +++ b/completions/sudo @@ -20,7 +20,7 @@ _sudo() mode=edit break fi - [[ ${COMP_WORDS[i]} == -@(u|U|g|C|p) ]] && ((i++)) + [[ ${COMP_WORDS[i]} == -[uUgCp] ]] && ((i++)) done case "$prev" in @@ -46,6 +46,7 @@ _sudo() if [[ $mode == edit ]]; then _filedir fi -} && complete -F _sudo sudo sudoedit +} && +complete -F _sudo sudo sudoedit -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/svcadm b/completions/svcadm index 21cc723c..f23af1ff 100644 --- a/completions/svcadm +++ b/completions/svcadm @@ -2,8 +2,8 @@ # # Copyright 2006 Yann Rouillard <yann@opencsw.org> -# -# svcadm accept any complete FMRI or abreviated FMRI +# +# svcadm accept any complete FMRI or abbreviated FMRI # - a complete FMRI is svc:/foo/bar/bar/baz # - abbreviated FMRI are foo/bar/bar/baz, bar/bar/baz, bar/baz or baz # @@ -11,7 +11,7 @@ # but to not clutter the interface with all completions, we will only # cut every completion alternative at the next slash. # -# For exemple, if the user types <nothing><tab>, we will propose for svc://foo/bar/bar/baz +# For example, if the user types <nothing><tab>, we will propose for svc://foo/bar/bar/baz # the following completion: foo/, bar/ and baz # If the user types <b><tab>, we will propose: bar/ and baz # If the user types <bar/><tab>, we will propose: bar/bar/ and bar/baz @@ -55,7 +55,7 @@ _smf_complete_fmri () fmri_part_list="$fmri" fi - # Here we make sure the completions begins with the pattern and + # Here we make sure the completions begins with the pattern and # we cut them at the first slash for fmri_part in $fmri_part_list; do [[ "$fmri_part" == $cur* ]] || continue @@ -74,14 +74,14 @@ _smf_complete_fmri () # next completion alternatives local i=${#COMPREPLY[*]} if [[ $i -gt 0 ]] && [[ "${COMPREPLY[$((--i))]}" == */ ]]; then - # we have to iterate throught the list as we may have duplicate + # we have to iterate through the list as we may have duplicate while [[ $i -ne 0 ]]; do [[ "${COMPREPLY[$i]}" != "${COMPREPLY[$((i - 1))]}" ]] && break ((i--)) done if [[ $i -eq 0 ]]; then _smf_complete_fmri "${COMPREPLY[0]}" "$prefix" - return 0 + return fi fi @@ -97,7 +97,7 @@ _smf_complete_fmri () _svcadm () { - local cur prev words cword + local cur prev words cword _init_completion -n : || return local command_list="enable disable restart refresh clear mark milestone" @@ -140,4 +140,4 @@ _svcadm () } && complete -F _svcadm svcadm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/svk b/completions/svk index 632eeb29..d78d3557 100644 --- a/completions/svk +++ b/completions/svk @@ -24,12 +24,12 @@ _svk() case $prev in -F|--file|--targets) _filedir - return 0 + return ;; --encoding) COMPREPLY=( $( compgen -W \ - '$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) ) - return 0 + '$( iconv --list | command sed -e "s@//@@;" )' -- "$cur" ) ) + return ;; esac @@ -191,7 +191,7 @@ _svk() --delete' -- "$cur" ) ) ;; sync) - COMPREPLY=( $( compgen -W "$( svk mirror --list \ + COMPREPLY=( $( compgen -W "$( $1 mirror --list \ 2>/dev/null | awk '/^\//{print $1}' )" -- "$cur" ) ) ;; co|checkout|push|pull) @@ -200,8 +200,8 @@ _svk() else path=// fi - COMPREPLY=( $( compgen -W "$( svk list $path 2>/dev/null | \ - sed -e 's|\(.*\)|'$path'\1|')" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "$( $1 list $path 2>/dev/null | \ + command sed -e 's|\(.*\)|'$path'\1|')" -- "$cur" ) ) ;; *) _filedir @@ -209,9 +209,7 @@ _svk() esac fi fi - - return 0 } && complete -F _svk svk -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sync_members b/completions/sync_members index 715d53f4..2fe50eaf 100644 --- a/completions/sync_members +++ b/completions/sync_members @@ -8,15 +8,15 @@ _sync_members() case $prev in -w|-g|-d|--welcome-msg|--goodbye-msg|--digest) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) - return 0 + return ;; -d|--file) _filedir - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--no-change --welcome-msg --goodbye-msg @@ -28,4 +28,4 @@ _sync_members() } && complete -F _sync_members sync_members -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/synclient b/completions/synclient new file mode 100644 index 00000000..b7ebf026 --- /dev/null +++ b/completions/synclient @@ -0,0 +1,24 @@ +# bash completion for synclient(1) -*- shell-script -*- + +_synclient() +{ + local cur prev words cword split + _init_completion -n = || return + + case $prev in + -\?|-h|-V) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + elif [[ $cur != *=?* ]]; then + COMPREPLY=( $( compgen -S = -W '$( $1 -l 2>/dev/null | \ + awk "/^[ \t]/ { print \$1 }" )' -- "$cur" ) ) + compopt -o nospace + fi +} && +complete -F _synclient synclient + +# ex: filetype=sh diff --git a/completions/sysbench b/completions/sysbench index e3d666cb..3d2b7b1e 100644 --- a/completions/sysbench +++ b/completions/sysbench @@ -8,100 +8,100 @@ _sysbench() case $prev in --num-threads|--max-requests|--max-time|--thread-stack-size| \ --help|--version|help|version) - return 0 + return ;; --init-rng|--debug|--validate) COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) - return 0 + return ;; --test) COMPREPLY=( $( compgen -W 'fileio cpu memory threads mutex oltp' \ -- "$cur" ) ) - return 0 + return ;; --cpu-max-prime) - return 0 + return ;; --file-test-mode) COMPREPLY=( $( compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \ -- "$cur" ) ) - return 0 + return ;; --file-io-mode) COMPREPLY=( $( compgen -W 'sync async fastmmap slowmmap' \ -- "$cur" ) ) - return 0 + return ;; --file-extra-flags) COMPREPLY=( $( compgen -W 'sync dsync direct' -- "$cur" ) ) - return 0 + return ;; --file-fsync-all|--file-fsync-end) COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) - return 0 + return ;; --file-fsync-mode) COMPREPLY=( $( compgen -W 'fsync fdatasync' -- "$cur" ) ) - return 0 + return ;; --memory-scope) COMPREPLY=( $( compgen -W 'global local' -- "$cur" ) ) - return 0 + return ;; --memory-hugetlb) COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) - return 0 + return ;; --memory-oper) COMPREPLY=( $( compgen -W 'read write none' -- "$cur" ) ) - return 0 + return ;; --memory-access-mode) COMPREPLY=( $( compgen -W 'seq rnd' -- "$cur" ) ) - return 0 + return ;; --oltp-test-mode) COMPREPLY=( $( compgen -W 'simple complex nontrx sp' -- "$cur" ) ) - return 0 + return ;; --oltp-read-only|--oltp-skip-trx|--oltp-quto-inc|--mysql-ssl) COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) - return 0 + return ;; --oltp-nontrx-mode) COMPREPLY=( $( compgen -W 'select update_key update_nokey insert delete' -- "$cur" ) ) - return 0 + return ;; --oltp-dist-type) COMPREPLY=( $( compgen -W 'uniform gaussian special' -- "$cur" ) ) - return 0 + return ;; --db-driver) COMPREPLY=( $( compgen -W "$( $1 --test=oltp help 2>/dev/null | - sed -e '/^.*database drivers:/,/^$/!d' \ - -ne 's/^ *\([^ ]*\) .*/\1/p' )" -- "$cur" ) ) - return 0 + command sed -e '/^.*database drivers:/,/^$/!d' \ + -ne 's/^ *\([^ ]*\) .*/\1/p' )" -- "$cur" ) ) + return ;; --db-ps-mode) COMPREPLY=( $( compgen -W 'auto disable' -- "$cur" ) ) - return 0 + return ;; --mysql-socket) _filedir sock - return 0 + return ;; --mysql-table-engine) COMPREPLY=( $( compgen -W 'myisam innodb bdb heap ndbcluster federated' -- "$cur" ) ) - return 0 + return ;; --mysql-engine-trx) COMPREPLY=( $( compgen -W 'yes no auto' -- "$cur" ) ) - return 0 + return ;; --*) - $split && return 0 + $split && return ;; esac @@ -130,4 +130,4 @@ _sysbench() } && complete -F _sysbench sysbench -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/sysctl b/completions/sysctl index 0ab37129..8216f989 100644 --- a/completions/sysctl +++ b/completions/sysctl @@ -6,6 +6,9 @@ _sysctl() _init_completion || return case $prev in + --help|--version) + return + ;; -p) _filedir conf return @@ -13,7 +16,9 @@ _sysctl() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + local opts="$( _parse_help "$1" )" + [[ $opts ]] || opts="$( _parse_usage "$1" )" + COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) else local suffix= [[ $prev == -w ]] && suffix== @@ -21,9 +26,7 @@ _sysctl() "$( PATH="$PATH:/sbin" sysctl -N -a 2>/dev/null )" -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi - - return 0 } && complete -F _sysctl sysctl -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/tar b/completions/tar index 374e0692..5a854edd 100644 --- a/completions/tar +++ b/completions/tar @@ -1,37 +1,455 @@ # bash completion for GNU tar -*- shell-script -*- +# +# General info +# ============ +# +# The "old" style arguments +# ------------------------- +# +# We don't "advice" the old tar option format by default for GNU tar, example: +# +# 'tar czfT /tmp/archive.tar patterns.txt' +# +# We rather advice the 'tar -czf /tmp/archive.tar -T patterns.txt' format of +# arguments. Though, if user starts the 'first' tar argument without leading +# dash, we treat the command line apropriately. +# +# +# long/short options origin +# ------------------------- +# +# For GNU tar, everything is parsed from `tar --help` output so not so much +# per-distribution work should be needed. The _parse_help does not seem to be +# good enough so parsed here directly. +# +# +# FIXME: --starting-file (-K) (should be matched for extraction only) +# FIXME: handle already used (at least short) options +# FIXME: Test-cases for make check. +# - check for no global variable pollution +# FIXME: why PS4='$BASH_SOURCE:$LINENO: ' shows sometimes negative lines? +# FIXME: timeout on tarball listing +# FIXME: cache 'tar --help' parsing results into global variables +# FIXME: at least 'tar -<tab>' should show some helping text (apart from just +# pure option advices) +# FIXME: short option completion should be more intuitive +# - verbose mode option should be advised multiple times +# - mode option should be advised only once +# - format option should be advised only once +# ... -_tar() +__gtar_parse_help_opt() { - local cur prev words cword split - _init_completion -s || return + local opttype arg opt separator optvar + opttype=long + arg="$2" + opt="$1" + separator=" " - local ext regex tar untar + case "$opt" in + --*) + ;; + -\?) + return ;; + -*) + opttype=short + opt=${opt##-} + separator= + ;; + *) + echo >&2 "not an option $opt" + return 1 + ;; + esac + + # Remove arguments. + opt=${opt//\[*/} + opt=${opt//=*/=} + + # Basic sanity. + opt=${opt//\"*/} + opt=${opt//\'*/} + opt=${opt//\;*/} + + optvar=$opttype'_arg_'$arg + + eval "$optvar=\"\$$optvar$separator\"\"$opt\"" +} - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) ) + +__gtar_parse_help_line() +{ + local i + + for i in $1; do + case "$i" in + # regular options + --*|-*) + __gtar_parse_help_opt "$i" "$2" + ;; + + # end once there is single non-option word + *) + break + esac + done +} + + +__gnu_tar_parse_help() +{ + local str line arg + while IFS= read line; do + # Ok, this requires some comment probably. The GNU help output prints + # options on lines beginning with spaces. After that, there is one + # or more options separated by ', ' separator string. We are matching + # like this then: ^<spaces>(<separator>?<option>)+<whatever>$ + if [[ "$line" =~ \ + ^[[:blank:]]{1,10}(((,[[:blank:]])?(--?([\]\[a-zA-Z0-9?=-]+))(,[[:space:]])?)+).*$ ]]; then + + line=${BASH_REMATCH[1]} + str="${line//,/ }" + + # Detect that all options on this line accept arguments (and whether + # the arguments are required or not). Note that only long option + # description in GNU help output mentions arguments. So the $line + # variable may contain e.g. '-X, --XXX[=NAME], -XXX2[=NAME]'. + arg=none + if [[ "$line" =~ --[A-Za-z0-9-]+(\[?)= ]]; then + [[ -n "${BASH_REMATCH[1]}" ]] && arg=opt || arg=req + fi + + __gtar_parse_help_line "$str" "$arg" + fi + done <<<"$(tar --help)" + + long_opts="\ + $long_arg_none\ + $long_arg_opt\ + $long_arg_req" + + short_opts="$short_arg_none$short_arg_opt$short_arg_req" +} + + +# Hack: parse --warning keywords from tar's error output +__gtar_parse_warnings() +{ + local line + 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)" +} + + +# Helper to obtain last character of string. +__tar_last_char() +{ + echo "${1: $(( ${#1} - 1))}" +} + + +__tar_parse_old_opt() +{ + local first_word char + + # current word is the first word + [[ "$cword" -eq 1 && -n "$cur" && "${cur:0:1}" != '-' ]] \ + && old_opt_progress=1 + + # check that first argument does not begin with "-" + first_word=${words[1]} + [[ -n "$first_word" && "${first_word:0:1}" != "-" ]] \ + && old_opt_used=1 + + # parse the old option (if present) contents to allow later code expect + # corresponding arguments + if [[ $old_opt_used -eq 1 ]]; then + char=${first_word:0:1} + while [[ -n "$char" ]]; do + if __tar_is_argreq "$char"; then + old_opt_parsed+=("$char") + fi + first_word=${first_word##$char} + char=${first_word:0:1} + done + fi +} + + +# Make the analysis of whole command line. +__tar_preparse_cmdline() +{ + local first_arg my_args tmparg i modes="ctxurdA" + + shift # progname + + __tar_parse_old_opt + + first_arg=1 + for i in "$@"; do + case "$i" in + --delete|--test-label) + tar_mode=${i:2:100} + tar_mode_arg=$i + break + ;; + --*) + # skip + ;; + -*[$modes]*) + tar_mode=${i//[^$modes]/} + tar_mode=${tar_mode:0:1} + tar_mode_arg=$i + break + ;; + *[$modes]*) + # Only the first arg may be "MODE" without leading dash + if [[ $first_arg -eq 1 ]]; then + tar_mode=${i//[^$modes]/} + tar_mode=${tar_mode:0:1} + tar_mode_arg=$i + fi + ;; + esac + first_arg=0 + done +} + + +# Generate completions for -f/--file. +__tar_file_option() +{ + local ext="$1" + + case "$tar_mode" in + c) + # no need to advise user to re-write existing tarball + _filedir -d + ;; + *) + _filedir "$ext" + ;; + esac +} + + +# Returns truth if option requires argument. No equal sign must be pasted. +# Accepts option in format: 'c', '-c', '--create' +__tar_is_argreq() +{ + local opt + opt=$1 + case "$opt" in + -[A-Za-z0-9?]) + [[ "$short_arg_req" =~ ${opt##-} ]] && return 0 + ;; + [A-Za-z0-9?]) + [[ "$short_arg_req" =~ ${opt} ]] && return 0 + ;; + --*) + [[ "$long_arg_req" =~ [[:blank:]]$opt=[[:blank:]] ]] && return 0 + ;; + esac + + return 1 +} + + +# Called only for short parameter +__tar_complete_mode() +{ + local short_modes has_mode rawopt generated \ + allshort_raw_unused allshort_raw \ + filler i + + short_modes="ctx" + [[ -z "$basic_tar" ]] && short_modes="ctxurdA" + + # Remove prefix when needed + rawopt=${cur#-} + + # -c -z -x ... => czx + allshort_raw=${short_opts//[- ]/} + + # init the 'mode' option if no option is in ${cur} + if [[ "$tar_mode" == none ]]; then + + # when user passed something like 'tar cf' do not put the '-' before + filler= + if [[ -z "$cur" && -z "$basic_tar" ]]; then + filler=- + fi + + generated="" + for (( i=0 ; 1; i++ )); do + local c="${short_modes:$i:1}" + [[ -z "$c" ]] && break + generated+=" $filler$cur$c" + done + + COMPREPLY=( $(compgen -W "$generated" ) ) return 0 fi + # The last short option requires argument, like '-cf<TAB>'. Cut the + # completion here to enforce argument processing. + if [[ "$old_opt_progress" -eq 0 ]] \ + && __tar_is_argreq "$(__tar_last_char "$cur")"; then + COMPREPLY=( "$cur" ) && return 0 + fi + + allshort_raw_unused=${allshort_raw//[$rawopt]/} + if [[ "$tar_mode" != none ]]; then + allshort_raw_unused=${allshort_raw_unused//[$short_modes]} + fi + + generated= + for (( i=0 ; 1; i++ )); do + local c="${allshort_raw_unused:$i:1}" + [[ -z "$c" ]] && break + generated+=" $cur$c" + done + + COMPREPLY=( $( compgen -W "$generated" ) ) + + return 0 +} + + +__gtar_complete_lopts() +{ + local rv + COMPREPLY=( $( compgen -W "$long_opts" -- "$cur" ) ) + rv=$? + [[ $COMPREPLY == *= ]] && compopt -o nospace + return $rv +} + + +__gtar_complete_sopts() +{ + local generated short_mode_opts i c + short_mode_opts="ctxurdA" + generated=${short_opts//[$short_mode_opts]/} + + for (( i=0 ; 1; i++ )); do + c="${allshort_raw_unused:$i:1}" + [[ -z "$c" ]] && break + generated+=" $cur$c" + done + + COMPREPLY=( $( compgen -W "$generated" -- "$cur" ) ) +} + + +__tar_try_mode() +{ + case "$cur" in + --*) + # posix tar does not support long opts + [[ -n "$basic_tar" ]] && return 0 + __gtar_complete_lopts + return $? + ;; + + -*) + # posix tar does not support short optios + [[ -n "$basic_tar" ]] && return 0 + + __tar_complete_mode && return 0 + ;; + + *) + if [[ "$cword" -eq 1 || "$tar_mode" == none ]]; then + __tar_complete_mode && return 0 + fi + ;; + esac + return 1 +} + + +__tar_adjust_PREV_from_old_option() +{ + # deal with old style arguments here + # $ tar cfTC # expects this sequence of arguments: + # $ tar cfTC ARCHIVE_FILE PATTERNS_FILE CHANGE_DIR + if [[ "$old_opt_used" -eq 1 && "$cword" -gt 1 \ + && "$cword" -lt $(( ${#old_opt_parsed[@]} + 2 )) ]]; + then + # make e.g. 'C' option from 'cffCT' + prev="-${old_opt_parsed[ $cword - 2 ]}" + fi +} + + +__tar_extract_like_mode() +{ + local i + for i in x d t delete; do + [[ "$tar_mode" == "$i" ]] && return 0 + done + return 1 +} + + +__tar_try_list_archive() +{ + local tarball tarbin untar + + __tar_extract_like_mode || return 1 + + # This all is just to approach directory completion from "virtual" + # directory structure in tarball (for which the _filedir is unusable) + + set -- "${words[@]}" + tarbin=$1 + untar="tf" + shift + + read tarball <<<"$(printf -- '%s\n' "$@" \ + | command sed -n "/^.\{1,\}$regex\$/p")" + if [[ -n "$tarball" ]]; then + local IFS=$'\n' + COMPREPLY=($(compgen -o filenames -W "$( + while read line; do + printf "%q\n" "$(printf %q"\n" "$line")" + done <<<"$($tarbin $untar "$tarball" 2>/dev/null)" + )" -- "$(printf "%q\n" "$cur")")) + return 0 + fi +} + +__tar_cleanup_prev() +{ + if [[ "$prev" =~ ^-[a-zA-Z0-9?]*$ ]]; then + # transformate '-caf' ~> '-f' + prev="-$(__tar_last_char "$prev")" + fi +} + +__tar_detect_ext() +{ local tars='@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma)))|t@([abglx]z|b?(z)2))' + ext="$tars" + regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\)\?\)\)\?\|t\([abglx]z\|bz\?2\)\)' - case ${words[1]} in + case "$tar_mode_arg" in --*) + # Should never happen? ;; ?(-)*[cr]*f) - if [[ $cword -eq 2 ]]; then - ext='@(tar|gem|spkg)' - case ${words[1]} in - *a*) ext="$tars" ;; - *z*) ext='t?(ar.)gz' ;; - *Z*) ext='ta@(r.Z|z)' ;; - *[jy]*) ext='t@(?(ar.)bz?(2)|b2)' ;; - *J*) ext='t?(ar.)xz' ;; - esac - _filedir $ext - else - _filedir - fi - return 0 + ext='@(tar|gem|spkg)' + case ${words[1]} in + *a*) ext="$tars" ;; + *z*) ext='t?(ar.)gz' ;; + *Z*) ext='ta@(r.Z|z)' ;; + *[jy]*) ext='t@(?(ar.)bz?(2)|b2)' ;; + *J*) ext='t?(ar.)xz' ;; + esac ;; +([^ZzJjy])f) ext="$tars" @@ -49,84 +467,265 @@ _tar() ext='@(@(tar|gem|spkg).@(lzma|xz)|t[lx]z)' regex='\(\(tar\|gem\|spkg\)\.\(lzma\|xz\)\|t[lx]z\)' ;; - *) - _filedir - return 0 - ;; esac +} - case $prev in - *${ext:-$tars}) - # complete on files in tar file - # - # get name of tar file from command line - tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"${words[@]}" ) - # devise how to untar and list it - untar=t${words[1]//[^Jzjyf]/} - - local IFS=$'\n' - COMPREPLY=( $( compgen -W "$( printf '%s\n' $( tar $untar $tar \ - 2>/dev/null ) )" -- "$cur" ) ) - return 0 - ;; - -C|--directory) - _filedir -d - return 0 - ;; - --atime-preserve) - COMPREPLY=( $( compgen -W 'replace system' -- "$cur" ) ) - return 0 - ;; - --group) - COMPREPLY=( $( compgen -g -- "$cur" ) ) - return 0 - ;; - --owner) - COMPREPLY=( $( compgen -u -- "$cur" ) ) - return 0 - ;; - -F|--info-script|--new-volume-script|--rmt-command|--rsh-command|\ - -I|--use-compress-program) - compopt -o filenames - COMPREPLY=( $( compgen -c -- "$cur" ) ) - return 0 - ;; - --volno-file|--add-file|-T|--files-from|-X|--exclude-from|--index-file) + +_gtar() +{ + local long_opts short_opts \ + long_arg_none long_arg_opt long_arg_req \ + short_arg_none short_arg_opt short_arg_req \ + tar_mode tar_mode_arg old_opt_progress=0 \ + old_opt_used=0 old_opt_parsed=() + + # Main mode, e.g. -x or -c (extract/creation) + local tar_mode=none + + # The mode argument, e.g. -cpf or -c + # FIXME: handle long options + local tar_mode_arg= + + if [[ "$_TAR_OPT_DEBUG" == 1 ]]; then + set -x + PS4="\$BASH_SOURCE:\$LINENO: " + fi + + local cur prev words cword split + + _init_completion -s || return + + # Fill the {long,short}_{opts,arg*} + __gnu_tar_parse_help + + __tar_preparse_cmdline "${words[@]}" + + local ext regex tar untar + + __tar_detect_ext + + while true; do # just-for-easy-break while, not looping + __tar_adjust_PREV_from_old_option + __tar_posix_prev_handle && break + __tar_cleanup_prev + + # Handle all options *REQUIRING* argument. Optional arguments are up to + # 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) + _filedir -d + break + ;; + --atime-preserve) + COMPREPLY=( $( compgen -W 'replace system' -- "$cur" ) ) + break + ;; + --group) + COMPREPLY=( $( compgen -g -- "$cur" ) ) + break + ;; + --owner) + COMPREPLY=( $( compgen -u -- "$cur" ) ) + break + ;; + -F|--info-script|--new-volume-script|--rmt-command|--rsh-command|\ + -I|--use-compress-program) + compopt -o filenames + COMPREPLY=( $( compgen -c -- "$cur" ) ) + break + ;; + --volno-file|--add-file|-T|--files-from|-X|--exclude-from|\ + --index-file|--listed-incremental|-g) + _filedir + break + ;; + -H|--format) + 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" ) ) + break + ;; + --totals) + COMPREPLY=( $( compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \ + -- "$cur" ) ) + break + ;; + --warning) + COMPREPLY=( $( compgen -W "$(__gtar_parse_warnings)" -- "$cur" ) ) + break + ;; + --file|-f|-!(-*)f) + __tar_file_option "$ext" + break + ;; + --*) + # parameter with required argument but no completion yet + [[ " $long_arg_req " =~ \ $prev=\ ]] && break + + # parameter with optional argument passed with =, something like + # --occurrence=*<TAB> which is not handled above + [[ " $long_arg_opt " =~ \ $prev\ ]] && break + + # if there is some unknown option with '=', for example + # (literally) user does --nonexistent=<TAB>, we do not want + # continue also + $split && break + + # Most probably, when code goes here, the PREV variable contains + # some string from "$long_arg_none" and we want continue. + ;; + -[a-zA-Z0-9?]) + # argument required but no completion yet + [[ "$short_arg_req" =~ ${prev##-} ]] && break + ;; + esac + + # safety belts + case "$cur" in + -[a-zA-Z0-9]=*) + # e.g. 'tar -c -f=sth' does not what user could expect + break + ;; + esac + + # Handle the main operational mode of tar. We should do it as soon as + # possible. + __tar_try_mode && break + + # handle others + case "$cur" in + --*) + __gtar_complete_lopts + break + ;; + -*) + # called only if it is *not* first parameter + __gtar_complete_sopts + break + ;; + esac + + # the first argument must be "mode" argument or --param, if any of those + # was truth - the 'break' statement would have been already called + [[ "$cword" -eq 1 ]] && break + + __tar_try_list_archive && break + + # file completion on relevant files + if [[ $tar_mode != none ]]; then _filedir + fi + + break + done # just-for-easy-break while + + if [[ "$_TAR_OPT_DEBUG" == 1 ]]; then + set +x + unset PS4 + fi +} + + +__tar_posix_prev_handle() +{ + case "$prev" in + -f) + __tar_file_option "$ext" return 0 ;; - -H|--format) - COMPREPLY=( $( compgen -W 'gnu oldgnu pax posix ustar v7' \ - -- "$cur" ) ) - return 0 - ;; - --quoting-style) - COMPREPLY=( $( compgen -W 'literal shell shell-always c c-maybe - escape locale clocale' -- "$cur" ) ) - return 0 - ;; - --totals) - COMPREPLY=( $( compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \ - -- "$cur" ) ) - return 0 - ;; - --occurrence|--sparse-version|--to-command|--mode|--mtime|\ - --tape-length|-b|--blocking-factor|--record-size|-V|--text|--backup|\ - --exclude|--exclude-tag*|-K|--starting-file|-N|--newer|--after-date|\ - --suffix|--strip-components|--transform|--xform|--checkpoint|\ - --checkpoint-action|--no-quote-chars|--quote-chars|--warnings) + -b) return 0 - ;; esac - $split && return 0 + return 1 +} + + +_posix_tar() +{ + local long_opts short_opts basic_tar \ + long_arg_none long_arg_opt long_arg_req \ + short_arg_none short_arg_opt short_arg_req \ + tar_mode tar_mode_arg old_opt_progress=0 \ + old_opt_used=1 old_opt_parsed=() + + # Main mode, e.g. -x or -c (extract/creation) + local tar_mode=none + + # The mode argument, e.g. -cpf or -c + local tar_mode_arg= + + local cur prev words cword split + + _init_completion -s || return + + basic_tar=yes + tar_mode=none + + # relatively compatible modes are {c,t,x} + # relatively compatible options {b,f,m,v,w} + short_arg_req="fb" + short_arg_none="wmv" + short_opts="$short_arg_req$short_arg_none" + + __tar_preparse_cmdline "${words[@]}" + + local ext regex tar untar + + __tar_detect_ext + + __tar_adjust_PREV_from_old_option + + __tar_posix_prev_handle && return + + __tar_try_mode && return + + __tar_try_list_archive && return # file completion on relevant files - _filedir "$ext" + _filedir +} - return 0 + +_tar() +{ + local cmd=${COMP_WORDS[0]} func line + read line <<<"$($cmd --version 2>/dev/null)" + case "$line" in + *GNU*) + func=_gtar + ;; + *) + func=_posix_tar + ;; + esac + $func "$@" + + # Install real completion for subsequent completions + if [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ]; then + complete -F $func -o dirnames tar + else + complete -F $func tar + fi + unset -f _tar } -[ -n "${COMP_TAR_INTERNAL_PATHS:-}" ] && complete -F _tar -o dirnames tar || - complete -F _tar tar -# ex: ts=4 sw=4 et filetype=sh + +if [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ]; then + complete -F _tar -o dirnames tar + complete -F _gtar -o dirnames gtar + complete -F _posix_tar -o dirnames bsdtar + complete -F _posix_tar -o dirnames star +else + complete -F _tar tar + complete -F _gtar gtar + complete -F _posix_tar bsdtar + complete -F _posix_tar star +fi + +# ex: filetype=sh diff --git a/completions/tcpdump b/completions/tcpdump index 7b4b4ea8..44b0afa7 100644 --- a/completions/tcpdump +++ b/completions/tcpdump @@ -8,32 +8,32 @@ _tcpdump() case $prev in -r|-w|-F) _filedir - return 0 + return ;; -i) _available_interfaces -a - return 0 + return ;; -m) _filedir mib - return 0 + return ;; -T) COMPREPLY=( $( compgen -W 'aodv cnfp rpc rtp rtcp snmp tftp vat wb' -- "$cur" ) ) - return 0 + return ;; -z) compopt -o filenames COMPREPLY=( $( compgen -c -- "$cur" ) ) - return 0 + return ;; -Z) _allowed_users - return 0 + return ;; -B|-c|-C|-D|-E|-G|-M|-s|-W|-y) - return 0 + return ;; esac @@ -44,4 +44,4 @@ _tcpdump() } && complete -F _tcpdump tcpdump -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/tcpkill b/completions/tcpkill index 4a753326..a25fedae 100644 --- a/completions/tcpkill +++ b/completions/tcpkill @@ -8,7 +8,7 @@ _tcpkill() case $prev in -i) _available_interfaces -a - return 0 + return ;; esac @@ -19,4 +19,4 @@ _tcpkill() } && complete -F _tcpkill tcpkill -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/tcpnice b/completions/tcpnice index 49b89258..9fdae9ba 100644 --- a/completions/tcpnice +++ b/completions/tcpnice @@ -8,7 +8,7 @@ _tcpnice() case $prev in -i) _available_interfaces -a - return 0 + return ;; esac @@ -19,4 +19,4 @@ _tcpnice() } && complete -F _tcpnice tcpnice -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/timeout b/completions/timeout new file mode 100644 index 00000000..ccc66ae7 --- /dev/null +++ b/completions/timeout @@ -0,0 +1,38 @@ +# timeout(1) completion -*- shell-script -*- + +_timeout() +{ + local cur prev words cword split i found=false + _init_completion -s || return + + for (( i=1; i <= COMP_CWORD; i++ )); do + if [[ ${COMP_WORDS[i]} != -* && ${COMP_WORDS[i-1]} != = ]]; then + if $found; then + _command_offset $i + return + fi + found=true + fi + [[ ${COMP_WORDS[i]} == -@(k|-kill-after|s|-signal) ]] && ((i++)) + done + + case $prev in + --help|--version|-k|--kill-after) + return + ;; + -s|--signal) + _signals + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + fi +} && +complete -F _timeout timeout + +# ex: filetype=sh diff --git a/completions/tipc b/completions/tipc new file mode 100644 index 00000000..3523a295 --- /dev/null +++ b/completions/tipc @@ -0,0 +1,285 @@ +# tipc(8) completion -*- shell-script -*- + +_tipc_media() { + local optind=$1 + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'media' -- $cur) ) + return 0 + elif [[ $cword -eq $optind+1 ]]; then + COMPREPLY=( $( compgen -W 'udp eth ib' -- $cur) ) + return 0 + fi + + return 1 +} + +_tipc_bearer() { + local optind=$1 + local media i + + if _tipc_media $optind; then + return + fi + + for ((i = 0; i < $cword; i++)); do + if [[ ${words[$i]} == 'media' ]]; then + media=${words[$(($i + 1))]} + fi + done + + if [[ $cword -eq $optind+2 ]]; then + case "$media" in + "udp") + COMPREPLY=( $( compgen -W 'name' -- $cur) ) + ;; + "eth" | "ib") + 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) ) + ;; + "eth") + local interfaces=$(command ls /sys/class/net/) + COMPREPLY=( $( compgen -W '$interfaces' -- $cur ) ) + ;; + esac + fi +} + +_tipc_link_opts() { + COMPREPLY=( $( compgen -W 'priority tolerance window' -- $cur) ) +} + +_tipc_link() { + local optind=$1 + local filter=$2 + + if [[ $cword -eq $optind ]]; then + 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 | \ + awk '{print substr($1, 0, length($1))}') + if [[ $filter == "peers" ]]; then + links=$(command sed '/broadcast-link/d' <<<"$links") + fi + COMPREPLY=( $( compgen -W '$links' -- $cur ) ) + fi +} + +_tipc() +{ + local cur prev words cword optind i p + _init_completion || return + + optind=1 + COMPREPLY=() + + # Flags can be placed anywhere in the commandline + case "$cur" in + -*) + COMPREPLY=( $( compgen -W '-h --help' -- $cur ) ) + return + ;; + esac + + if [[ $cword -eq 1 ]]; then + COMPREPLY=( $( compgen -W 'bearer link media nametable node socket' -- $cur ) ) + return + fi + + case "${words[$optind]}" in + bearer) + let optind++ + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'enable disable set get list' -- $cur ) ) + return + fi + + case "${words[$optind]}" in + enable) + local media params + let optind++ + + if [[ $cword -lt $optind+4 ]]; then + _tipc_bearer $optind + return + fi + + for ((i = 0; i < $cword; i++)); do + if [[ ${words[$i]} == 'media' ]]; then + media=${words[$(($i + 1))]} + fi + done + case "$media" in + "udp") + declare -a params=("localip" "localport" "remoteip" + "remoteport" "domain" "priority") + ;; + "eth" | "ib") + declare -a params=("domain" "priority") + ;; + *) + return + ;; + esac + + # 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 + 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 + if [[ $p == $i ]]; then + params=( "${params[@]/$i}" ) + fi + done + done + + COMPREPLY=( $( compgen -W '${params[@]}' -- $cur) ) + ;; + disable) + let optind++ + + _tipc_bearer $optind + ;; + get) + let optind++ + + if [[ $cword -eq $optind ]]; then + _tipc_link_opts + elif [[ $cword -ge $optind+1 ]]; then + _tipc_bearer $(($optind + 1)) + fi + ;; + set) + let optind++ + + if [[ $cword -eq $optind ]]; then + _tipc_link_opts + elif [[ $cword -ge $optind+2 ]]; then + _tipc_bearer $(($optind + 2)) + fi + ;; + esac + ;; + link) + let optind++ + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'get set list statistics' -- $cur ) ) + return + fi + + case "${words[$optind]}" in + get) + let optind++ + + if [[ $cword -eq $optind ]]; then + _tipc_link_opts + elif [[ $cword -ge $optind+1 ]]; then + _tipc_link $(($optind + 1)) "peers" + fi + ;; + set) + let optind++ + + if [[ $cword -eq $optind ]]; then + _tipc_link_opts + elif [[ $cword -ge $optind+2 ]]; then + _tipc_link $(($optind + 2)) "peers" + fi + ;; + statistics) + let optind++ + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'show reset' -- $cur) ) + return + fi + + case "${words[$optind]}" in + show|reset) + _tipc_link $(($optind + 1)) + ;; + esac + ;; + esac + ;; + media) + let optind++ + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'get set list' -- $cur ) ) + return + fi + + case "${words[$optind]}" in + get) + let optind++ + + if [[ $cword -eq $optind ]]; then + _tipc_link_opts + elif [[ $cword -ge $optind+1 ]]; then + _tipc_media $(($optind + 1)) + fi + ;; + set) + let optind++ + + if [[ $cword -eq $optind ]]; then + _tipc_link_opts + elif [[ $cword -ge $optind+2 ]]; then + _tipc_media $(($optind + 2)) + fi + ;; + esac + ;; + nametable) + let optind++ + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'show' -- $cur ) ) + fi + ;; + node) + let optind++ + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'list get set' -- $cur ) ) + return + fi + + case "${words[$optind]}" in + get|set) + let optind++ + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'address netid' -- $cur ) ) + fi + esac + ;; + socket) + let optind++ + + if [[ $cword -eq $optind ]]; then + COMPREPLY=( $( compgen -W 'list' -- $cur ) ) + fi + ;; + esac +} && +complete -F _tipc tipc + +# ex: filetype=sh diff --git a/completions/tracepath b/completions/tracepath index 1861b6a2..06455cb5 100644 --- a/completions/tracepath +++ b/completions/tracepath @@ -20,4 +20,4 @@ _tracepath() } && complete -F _tracepath tracepath tracepath6 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/tshark b/completions/tshark index 32f853f2..34d93a0d 100644 --- a/completions/tshark +++ b/completions/tshark @@ -52,7 +52,7 @@ _tshark() -O) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," COMPREPLY=( $( compgen -P "$prefix" -W \ - "$( "$1" -G protocols 2>&1 | cut -d$'\t' -f 3 )" \ + "$( "$1" -G protocols 2>&1 | cut -f 3 )" \ -- "${cur##*,}" ) ) return ;; @@ -86,13 +86,13 @@ _tshark() return ;; -G) - COMPREPLY=( $( compgen -W "$( "$1" -G ? | \ + COMPREPLY=( $( compgen -W "$( "$1" -G ? 2>/dev/null | \ awk '/^[ \t]*-G / \ - { sub("^[[]","",$2); sub("[]]$","",$2); print $2 }' )" \ + { sub("^[[]","",$2); sub("[]]$","",$2); print $2 }' )" \ -- "$cur" ) ) return ;; - + esac if [[ "$cur" == -* ]]; then @@ -102,4 +102,4 @@ _tshark() } && complete -F _tshark tshark -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/tune2fs b/completions/tune2fs index ee88b45d..3695fea1 100644 --- a/completions/tune2fs +++ b/completions/tune2fs @@ -7,41 +7,42 @@ _tune2fs() case $prev in -c|-C|-E|-i|-J|-L|-m|-r|-T) - return 0 + return ;; -e) COMPREPLY=( $( compgen -W 'continue remount-ro panic' -- "$cur" ) ) - return 0 + return ;; -g) _gids COMPREPLY=( $( compgen -g -W '${COMPREPLY[@]}' -- "$cur" ) ) - return 0 + return ;; -M) _filedir -d + return ;; -o) local -a opts=(^debug ^bsdgroups ^user_xattr ^acl ^uid16 ^journal_data ^journal_data_ordered ^journal_data_writeback) COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" ) ) - return 0 + return ;; -O) local -a opts=(^dir_index ^dir_nlink ^extent ^extra_isize ^filetype ^flex_bg ^has_journal ^huge_file ^large_file ^resize_inode ^sparse_super ^uninit_bg) COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" ) ) - return 0 + return ;; -u) _uids COMPREPLY=( $( compgen -u -W '${COMPREPLY[@]}' -- "$cur" ) ) - return 0 + return ;; -U) COMPREPLY=( $( compgen -W 'clear random time' -- "$cur" ) ) - return 0 + return ;; esac @@ -55,4 +56,4 @@ _tune2fs() } && complete -F _tune2fs tune2fs -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/umount b/completions/umount index 6c15182b..6d4b3c8f 100644 --- a/completions/umount +++ b/completions/umount @@ -18,4 +18,4 @@ _umount() } && complete -F _umount -o dirnames umount -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/umount.linux b/completions/umount.linux index 9bc9fcc1..28bfc9c9 100644 --- a/completions/umount.linux +++ b/completions/umount.linux @@ -18,8 +18,8 @@ _reply_compgen_array() # We also have to add another round of escaping to $cur. local ecur="$cur" - ecur="${ecur//\\/\\\\}" - ecur="${ecur//\'/\'}" + ecur=${ecur//\\/\\\\} + ecur=${ecur//\'/\\\'} # Actually generate completions. local oldifs=$IFS @@ -29,7 +29,7 @@ _reply_compgen_array() # Unescape strings in the linux fstab(5) format (with octal escapes). __linux_fstab_unescape() { - eval $1="'${!1//\'/\047}'" + eval $1="'${!1//\'/\\047}'" eval $1="'${!1/%\\/\\\\}'" eval "$1=$'${!1}'" } @@ -46,7 +46,7 @@ _linux_fstab() 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 [[ $fs_spec == [#]* ]]; then continue; fi if [[ $1 == -L ]]; then local fs_label=${fs_spec/#LABEL=} if [[ $fs_label != "$fs_spec" ]]; then @@ -59,8 +59,8 @@ _linux_fstab() __linux_fstab_unescape fs_spec __linux_fstab_unescape fs_file IFS=$'\0' - [[ $fs_spec = */* ]] && COMPREPLY+=("$fs_spec") - [[ $fs_file = */* ]] && COMPREPLY+=("$fs_file") + [[ $fs_spec == */* ]] && COMPREPLY+=("$fs_spec") + [[ $fs_file == */* ]] && COMPREPLY+=("$fs_file") IFS=$oldifs fi done @@ -74,8 +74,8 @@ _linux_fstab() if [[ $realcur ]]; then local dirrealcur= dircur= basecur if [[ $cur == */* ]]; then - dirrealcur="${realcur%/*}/" - dircur="${cur%/*}/" + dirrealcur="${realcur%/*}/" + dircur="${cur%/*}/" fi basecur=${cur#"$dircur"} local i n=${#COMPREPLY[@]} @@ -137,4 +137,4 @@ _umount() } && complete -F _umount -o dirnames umount -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/unace b/completions/unace index 369417ce..0f8963e0 100644 --- a/completions/unace +++ b/completions/unace @@ -17,4 +17,4 @@ _unace() } && complete -F _unace unace -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/unpack200 b/completions/unpack200 index fe058c64..1c97ecbe 100644 --- a/completions/unpack200 +++ b/completions/unpack200 @@ -7,16 +7,16 @@ _unpack200() case $prev in '-?'|-h|--help|-V|--version|-J) - return 0 + return ;; -H|--deflate-hint) COMPREPLY=( $( compgen -W 'true false keep' -- "$cur" ) ) - return 0 + return ;; -l|--log-file) COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) _filedir log - return 0 + return ;; esac @@ -45,4 +45,4 @@ _unpack200() } && complete -F _unpack200 unpack200 -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/unrar b/completions/unrar index f2a8a182..3340d24c 100644 --- a/completions/unrar +++ b/completions/unrar @@ -20,4 +20,4 @@ _unrar() } && complete -F _unrar unrar -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/unshunt b/completions/unshunt index 6e208d0c..8815f843 100644 --- a/completions/unshunt +++ b/completions/unshunt @@ -6,7 +6,7 @@ _unshunt() _init_completion || return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--help' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) else _filedir -d fi @@ -14,4 +14,4 @@ _unshunt() } && complete -F _unshunt unshunt -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/update-alternatives b/completions/update-alternatives index e421db86..43cc3229 100644 --- a/completions/update-alternatives +++ b/completions/update-alternatives @@ -24,10 +24,10 @@ _update_alternatives() case $prev in --altdir|--admindir) _filedir -d - return 0 + return ;; --help|--usage|--version) - return 0 + return ;; esac @@ -89,4 +89,4 @@ _update_alternatives() } && complete -F _update_alternatives update-alternatives alternatives -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/update-rc.d b/completions/update-rc.d index 9a16385a..85c9a5a4 100644 --- a/completions/update-rc.d +++ b/completions/update-rc.d @@ -19,7 +19,7 @@ _update_rc_d() if [[ $cword -eq 1 || "$prev" == -* ]]; then valid_options=( $( \ tr " " "\n" <<<"${words[@]} ${options[@]}" \ - | sed -ne "/$( sed "s/ /\\|/g" <<<"${options[@]}" )/p" \ + | command sed -ne "/$( command sed "s/ /\\|/g" <<<"${options[@]}" )/p" \ | sort | uniq -u \ ) ) COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \ @@ -57,9 +57,7 @@ _update_rc_d() else COMPREPLY=() fi - - return 0 } && complete -F _update_rc_d update-rc.d -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/upgradepkg b/completions/upgradepkg index f9fa23ab..2a4b9845 100644 --- a/completions/upgradepkg +++ b/completions/upgradepkg @@ -23,7 +23,8 @@ _upgradepkg() return fi - _filedir "t[bglx]z" -} && complete -F _upgradepkg upgradepkg + _filedir 't[bglx]z' +} && +complete -F _upgradepkg upgradepkg -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/urlsnarf b/completions/urlsnarf index e9ccd8f9..b6bf069c 100644 --- a/completions/urlsnarf +++ b/completions/urlsnarf @@ -8,7 +8,7 @@ _urlsnarf() case $prev in -i) _available_interfaces -a - return 0 + return ;; esac @@ -19,4 +19,4 @@ _urlsnarf() } && complete -F _urlsnarf urlsnarf -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/uscan b/completions/uscan new file mode 100644 index 00000000..fc05d2e8 --- /dev/null +++ b/completions/uscan @@ -0,0 +1,39 @@ +# uscan completion -*- shell-script -*- + +_uscan() +{ + local cur prev split + _init_completion -s || return + + case $prev in + --package) + COMPREPLY=( $( _xfunc apt-cache _apt_cache_src_packages )) + return + ;; + --watchfile) + _filedir + return + ;; + --destdir) + _filedir -d + return + ;; + --timeout|--upstream-version|--download-version|--check-dirname-level|--check-dirname-regex) + COMPREPLY=( ) + return + ;; + esac + + $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" ) ) +} && +complete -F _uscan uscan + +# ex: filetype=sh diff --git a/completions/useradd b/completions/useradd index 12c29365..9ed2f9f6 100644 --- a/completions/useradd +++ b/completions/useradd @@ -11,36 +11,34 @@ _useradd() case $prev in -c|--comment|-h|--help|-e|--expiredate|-f|--inactive|-K|--key|\ -p|--password|-u|--uid|-Z|--selinux-user) - return 0 + return ;; -b|--base-dir|-d|--home-dir|-k|--skel|-R|--root) _filedir -d - return 0 + return ;; -g|--gid) _gids COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \ -- "$cur" ) ) - return 0 + return ;; -G|--groups) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur##*,}" ) ) - return 0 + return ;; -s|--shell) _shells - return 0 + return ;; esac - $split && return 0 + $split && return - if [[ "$cur" == -* ]]; then + [[ "$cur" == -* ]] && \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 - fi } && complete -F _useradd useradd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/userdel b/completions/userdel index 090203ac..05bc2f75 100644 --- a/completions/userdel +++ b/completions/userdel @@ -17,11 +17,11 @@ _userdel() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _userdel userdel -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/usermod b/completions/usermod index 0d1f497b..03cc89fe 100644 --- a/completions/usermod +++ b/completions/usermod @@ -11,39 +11,39 @@ _usermod() case $prev in -c|--comment|-d|--home|-e|--expiredate|-f|--inactive|-h|--help|\ -l|--login|-p|--password|-u|--uid|-Z|--selinux-user) - return 0 + return ;; -g|--gid) _gids COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \ -- "$cur" ) ) - return 0 + return ;; -G|--groups) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur##*,}" ) ) - return 0 + return ;; -R|--root) _filedir -d - return 0 + return ;; -s|--shell) _shells - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then # TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _usermod usermod -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/valgrind b/completions/valgrind index 08950998..97e4cc59 100644 --- a/completions/valgrind +++ b/completions/valgrind @@ -34,7 +34,7 @@ _valgrind() COMPREPLY=( $( compgen -W '$( for f in /usr{,/local}/lib{,64}/valgrind/*; do [[ $f != *.so && -x $f ]] && - sed -ne "s/^.*\/\(.*\)-\([^-]*\)-\([^-]*\)/\1/p" <<<$f + command sed -ne "s/^.*\/\(.*\)-\([^-]*\)-\([^-]*\)/\1/p" <<<$f done )' -- "$cur" ) ) return ;; @@ -70,7 +70,7 @@ _valgrind() # generic cases parsed from --help output --+([-A-Za-z0-9_])) local value=$( $1 --help-debug $tool 2>/dev/null | \ - sed -ne "s|^[$' \t']*$prev=\([^$' \t']\{1,\}\).*|\1|p" ) + command sed -ne "s|^[[:blank:]]*$prev=\([^[:blank:]]\{1,\}\).*|\1|p" ) case $value in \<file*\>) _filedir @@ -107,4 +107,4 @@ _valgrind() } && complete -F _valgrind valgrind -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/vipw b/completions/vipw index 2220f2e8..cb54a840 100644 --- a/completions/vipw +++ b/completions/vipw @@ -7,11 +7,11 @@ _vipw() case $prev in -h|--help) - return 0 + return ;; -R|--root) _filedir -d - return 0 + return ;; esac @@ -19,4 +19,4 @@ _vipw() } && complete -F _vipw vipw vigr -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/vmstat b/completions/vmstat index 1d3ebb32..769620a7 100644 --- a/completions/vmstat +++ b/completions/vmstat @@ -6,10 +6,10 @@ _vmstat() _init_completion || return case $prev in - -V|-c|-M|-N|-n|-w|-p) + -h|--help|-V|--version|-c|-M|-N|-n|-w|-p|--partition) return ;; - -S) + -S|--unit) [[ $OSTYPE == *linux* ]] && \ COMPREPLY=( $( compgen -W 'k K m M' -- "$cur" ) ) return @@ -24,4 +24,4 @@ _vmstat() } && complete -F _vmstat vmstat -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/vncviewer b/completions/vncviewer index a1c16d69..4a3f2abd 100644 --- a/completions/vncviewer +++ b/completions/vncviewer @@ -24,16 +24,16 @@ _tightvncviewer() case $prev in -passwd) _filedir - return 0 + return ;; -encodings) COMPREPLY=( $( compgen -W 'copyrect tight hextile zlib corre rre raw' -- "$cur" ) ) - return 0 + return ;; -via) _known_hosts_real "$cur" - return 0 + return ;; esac @@ -63,17 +63,17 @@ _xvnc4viewer() # -passwd, -PasswordFile -[pP][aA][sS][sS][wW][dD]|-[pP][aA][sS][sS][wW][oO][rR][dD][fF][iI][lL][eE]) _filedir - return 0 + 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" ) ) - return 0 + return ;; # -via -[vV][iI][aA]) _known_hosts_real "$cur" - return 0 + return ;; esac @@ -87,16 +87,15 @@ _xvnc4viewer() WMDecorationWidth ZlibLevel ) [[ "$cur" == --* ]] && dash=-- || dash=- - local option oldNoCaseMatch=$(shopt -p nocasematch) - shopt -s nocasematch + local option reset=$( shopt -p nocasematch ); shopt -s nocasematch COMPREPLY=( $( for option in "${options[@]}"; do [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option done ) ) - eval "$oldNoCaseMatch" 2>/dev/null + $reset else _known_hosts_real "$cur" fi } && complete -F _xvnc4viewer xvnc4viewer -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/vpnc b/completions/vpnc index 143798de..4e1fa81e 100644 --- a/completions/vpnc +++ b/completions/vpnc @@ -9,44 +9,44 @@ _vpnc() --help|--long-help|--version|--id|--username|--domain|--ifname|\ --application-version|--local-addr|--local-port|--udp-port|--dpd-idle|\ --target-network) - return 0 + return ;; --gateway) _known_hosts_real "$cur" - return 0 + return ;; --vendor) COMPREPLY=( $( compgen -W 'cisco netscreen' -- "$cur" ) ) - return 0 + return ;; --natt-mode) COMPREPLY=( $( compgen -W 'natt none force-natt cisco-udp' \ -- "$cur" ) ) - return 0 + return ;; --script|--pid-file|--ca-file) _filedir - return 0 + return ;; --dh) COMPREPLY=( $( compgen -W 'dh1 dh2 dh5' -- "$cur" ) ) - return 0 + return ;; --pfs) COMPREPLY=( $( compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur" ) ) - return 0 + return ;; --debug) COMPREPLY=( $( compgen -W '0 1 2 3 99' -- "$cur" ) ) - return 0 + return ;; --auth-mode) COMPREPLY=( $( compgen -W 'psk cert hybrid' -- "$cur" ) ) - return 0 + return ;; --ca-dir) _filedir -d - return 0 + return ;; esac @@ -59,4 +59,4 @@ _vpnc() } && complete -F _vpnc vpnc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/watch b/completions/watch index c2832dd8..bcc356f8 100644 --- a/completions/watch +++ b/completions/watch @@ -51,4 +51,4 @@ _watch() } && complete -F _watch watch -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/webmitm b/completions/webmitm index 68440631..a8484ca1 100644 --- a/completions/webmitm +++ b/completions/webmitm @@ -14,4 +14,4 @@ _webmitm() } && complete -F _webmitm webmitm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/wget b/completions/wget index 1fc5c955..b1878fdb 100644 --- a/completions/wget +++ b/completions/wget @@ -6,6 +6,9 @@ _wget() _init_completion -s || return case $prev in + -V|--version|-h|--help) + return + ;; --progress) COMPREPLY=( $( compgen -W 'bar dot' -- "$cur" ) ) return @@ -100,7 +103,7 @@ _wget() ;; -Q|--quota|--limit-rate|--warc-max-size) # expect size - if [[ $cur == *@(k|m) ]]; then + if [[ $cur == *[km] ]]; then COMPREPLY=( $( compgen -W "$cur" ) ) elif [[ $cur ]]; then COMPREPLY=( $( compgen -P "$cur" -W "{0..9} k m" ) ) @@ -112,7 +115,7 @@ _wget() return ;; --user|--http-user|--proxy-user|--ftp-user) - COMPREPLY=( $( compgen -W "$( sed -n \ + COMPREPLY=( $( compgen -W "$( command sed -n \ '/^login/s/^[[:blank:]]*login[[:blank:]]//p' ~/.netrc \ 2>/dev/null )" -- "$cur" ) ) return @@ -134,19 +137,24 @@ _wget() --local-encoding|--remote-encoding) type -P xauth &>/dev/null && \ COMPREPLY=( $( compgen -W '$( iconv -l 2>/dev/null | \ - sed -e "s@/*\$@@" -e "s/[,()]//g" 2>/dev/null )' -- "$cur" ) ) + command sed -e "s@/*\$@@" -e "s/[,()]//g" 2>/dev/null )' -- "$cur" ) ) return ;; -e|--execute) return # TODO base=STR ;; - -nv|--report-speed) + --report-speed) COMPREPLY=( $( compgen -W 'bits' -- "$cur" ) ) return ;; + --regex-type) + 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|-I|--include-directories|-X|--exclude-directories) + --accept|-R|--reject|--accept-regex|--reject-regex|-I|\ + --include-directories|-X|--exclude-directories) # argument required but no completions available return ;; @@ -159,6 +167,7 @@ _wget() [[ $COMPREPLY == *= ]] && compopt -o nospace fi -} && complete -F _wget wget +} && +complete -F _wget wget -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/wine b/completions/wine index 8cdc9146..be299755 100644 --- a/completions/wine +++ b/completions/wine @@ -17,4 +17,4 @@ _wine() } && complete -F _wine wine -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/withlist b/completions/withlist index 4aaad602..913e410b 100644 --- a/completions/withlist +++ b/completions/withlist @@ -15,4 +15,4 @@ _withlist() } && complete -F _withlist withlist -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/wodim b/completions/wodim index b6ce2aa6..7380166b 100644 --- a/completions/wodim +++ b/completions/wodim @@ -52,7 +52,7 @@ _cdrecord() COMPREPLY=( $( compgen -W '{25..95}' -- "$cur" ) ) ;; esac - return 0 + return fi generic_options=( -version -v -V -d -silent -force -immed -dummy -clone \ @@ -92,4 +92,4 @@ _cdrecord() } && complete -F _cdrecord cdrecord wodim -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/wol b/completions/wol index ce1b7c50..50653385 100644 --- a/completions/wol +++ b/completions/wol @@ -7,34 +7,34 @@ _wol() case $prev in -V|--version|--help|-p|--port|--passwd|-w|--wait) - return 0 + return ;; -h|--host|-i|--ipaddr) # Broadcast addresses local PATH=$PATH:/sbin COMPREPLY=( $( { ip addr show || ifconfig -a; } 2>/dev/null | \ - sed -ne 's/.*[[:space:]]Bcast:\([^[:space:]]*\).*/\1/p' -ne \ + 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' ) ) _known_hosts_real "$cur" - return 0 + return ;; -f|--file) _filedir - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi _mac_addresses } && complete -F _wol wol -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/wsimport b/completions/wsimport index 91504844..d53a17fb 100644 --- a/completions/wsimport +++ b/completions/wsimport @@ -46,4 +46,4 @@ _wsimport() } && complete -F _wsimport wsimport -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/wtf b/completions/wtf index cc8352f4..26a0d4b8 100644 --- a/completions/wtf +++ b/completions/wtf @@ -3,11 +3,15 @@ _wtf() { - local cur prev words cword + local cur prev words cword addf _init_completion || return - [[ $prev == -f ]] && _filedir && return 0 - [[ $cur == -* ]] && COMPREPLY=( -f ) && return 0 + [[ $prev == -f ]] && _filedir && return + [[ ${words[@]} == *\ -f* ]] && addf= || addf=-f + if [[ $cur == -* ]]; then + COMPREPLY=( $addf ) + return + fi local db @@ -18,10 +22,19 @@ _wtf() fi shift done - [[ -z $db ]] && db=${ACRONYMDB:-/usr/share/misc/acronyms*} - COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur^^}" ) ) + if [[ -z "$db" ]]; then + local f + for f in "$ACRONYMDB" /usr/share/misc/acronyms \ + /usr/share/games/bsdgames/acronyms; do + [[ -f "$f" ]] && db="$f" && break + done + [[ -z "$db" ]] && return + fi + + COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db* 2>/dev/null ) $addf" \ + -- "${cur^^}" ) ) } && complete -F _wtf wtf -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/wvdial b/completions/wvdial index da2dbfb3..e456f1b1 100644 --- a/completions/wvdial +++ b/completions/wvdial @@ -8,7 +8,7 @@ _wvdial() case $prev in --config) _filedir - return 0 + return ;; esac @@ -33,7 +33,7 @@ _wvdial() done # parse config files for sections and # remove default section - COMPREPLY=( $( 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// /\\ } @@ -43,4 +43,4 @@ _wvdial() } && complete -F _wvdial wvdial -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xfreerdp b/completions/xfreerdp index f0188446..9ca7ac81 100644 --- a/completions/xfreerdp +++ b/completions/xfreerdp @@ -7,21 +7,21 @@ _xfreerdp() case $prev in -k) - COMPREPLY=( $( compgen -W "$(xfreerdp --kbd-list | \ - awk '/^0x/ {print $1}')" -- "$cur" ) ) - return 0 + COMPREPLY=( $( compgen -W "$($1 --kbd-list | \ + awk '/^0x/ {print $1}')" -- "$cur" ) ) + return ;; -a) COMPREPLY=( $( compgen -W '8 15 16 24 32' -- "$cur" ) ) - return 0 + return ;; -x) COMPREPLY=( $( compgen -W 'b broadband m modem l lan' -- "$cur" ) ) - return 0 + return ;; --plugin) COMPREPLY=( $( compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur" ) ) - return 0 + return ;; esac @@ -29,10 +29,11 @@ _xfreerdp() COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -t -g -a -z -f -x -O -o -k --kbd-list -h --plugin --data' -- "$cur" ) ) else - _known_hosts_real "$cur" + COMPREPLY=( $( compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \ + 2>/dev/null)" -- "$cur" ) ) fi } && complete -F _xfreerdp xfreerdp -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xgamma b/completions/xgamma index c5b8a76b..eda46d62 100644 --- a/completions/xgamma +++ b/completions/xgamma @@ -7,7 +7,7 @@ _xgamma() case "$prev" in -screen) - local screens=$( xrandr --query 2>/dev/null | sed -n \ + 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 @@ -30,7 +30,7 @@ _xgamma() compopt -o nospace elif [[ "$cur" == :*.* ]]; then # local screen numbers - local t screens=$( xrandr --query 2>/dev/null | sed -ne \ + 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" -- \ @@ -53,6 +53,7 @@ _xgamma() [[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY ]] && return fi -} && complete -F _xgamma xgamma +} && +complete -F _xgamma xgamma -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xhost b/completions/xhost index 22839e4f..8f605a90 100644 --- a/completions/xhost +++ b/completions/xhost @@ -13,4 +13,4 @@ _xhost () } && complete -F _xhost xhost -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xm b/completions/xm index e3ae9796..93852f61 100644 --- a/completions/xm +++ b/completions/xm @@ -184,7 +184,7 @@ _xm() case $prev in -d) _xen_domain_names - return 0 + return ;; esac ;; @@ -198,11 +198,11 @@ _xm() case $prev in -f|-F|--defconfig|--config) _filedir - return 0 + return ;; --path) _filedir -d - return 0 + return ;; esac @@ -216,9 +216,7 @@ _xm() esac fi fi - - return 0 } && complete -F _xm xm -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xmllint b/completions/xmllint index 928a5b67..e9a35d06 100644 --- a/completions/xmllint +++ b/completions/xmllint @@ -8,38 +8,38 @@ _xmllint() case $prev in -o|--output) _filedir - return 0 + return ;; --path|--dtdvalidfpi|--maxmem|--encode|--pattern) # argument required but no completions available - return 0 + return ;; --dtdvalid) _filedir 'dtd?(.gz)' - return 0 + return ;; --relaxng) _filedir 'rng?(.gz)' - return 0 + return ;; --schema) _filedir 'xsd?(.gz)' - return 0 + return ;; --schematron) _filedir 'sch?(.gz)' - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( "${COMPREPLY[@]%:}" ) - return 0 + return fi - _filedir '@(*ml|htm|svg?(z)|xs[dl]|rng|wsdl|jnlp|tld)?(.gz)' + _filedir '@(*ml|htm|svg?(z)|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)?(.gz)' } && complete -F _xmllint xmllint -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xmlwf b/completions/xmlwf index 15206134..dd7a5457 100644 --- a/completions/xmlwf +++ b/completions/xmlwf @@ -8,25 +8,25 @@ _xmlwf() case $prev in -d) _filedir -d - return 0 + return ;; -e) COMPREPLY=( $( compgen -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1' \ -- "$cur" ) ) - return 0 + return ;; -v) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) - return 0 + return fi - _filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp|tld)' + _filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)' } && complete -F _xmlwf xmlwf -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xmms b/completions/xmms index 7d849568..88e65bd4 100644 --- a/completions/xmms +++ b/completions/xmms @@ -24,4 +24,4 @@ _xmms() } && complete -F _xmms xmms -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xmodmap b/completions/xmodmap index 243563d3..4db899b1 100644 --- a/completions/xmodmap +++ b/completions/xmodmap @@ -7,18 +7,18 @@ _xmodmap() case $prev in -display|-e) - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-display -help -grammar -verbose -quiet -n -e -pm -pk -pke -pp' -- "$cur" ) ) - return 0 + return fi _filedir } && complete -F _xmodmap xmodmap -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xrandr b/completions/xrandr index cef0941e..841904a5 100644 --- a/completions/xrandr +++ b/completions/xrandr @@ -12,7 +12,7 @@ _xrandr() return ;; --output|--left-of|--right-of|--above|--below|--same-as) - local outputs=$( xrandr | awk '/connected/ {print $1}' ) + local outputs=$( "$1" | awk '/connected/ {print $1}' ) COMPREPLY=( $( compgen -W "$outputs" -- "$cur" ) ) return ;; @@ -25,7 +25,7 @@ _xrandr() fi done if [[ $output ]]; then - local modes=$( xrandr | 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" ) ) @@ -45,11 +45,18 @@ _xrandr() 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" ) ) + # TODO 2nd arg needed, is that a provider as well? + return + ;; esac COMPREPLY=( $( compgen -W '$( "$1" -help 2>&1 | - sed -e "s/ or / /g" -e "s/<[^>]*>]//g" | _parse_help - )' -- "$cur" ) ) + command sed -e "s/ or / /g" -e "s/<[^>]*>]//g" | _parse_help - )' -- "$cur" ) ) } && complete -F _xrandr xrandr -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xrdb b/completions/xrdb index 7a6eefe6..1f517cb3 100644 --- a/completions/xrdb +++ b/completions/xrdb @@ -7,21 +7,21 @@ _xrdb() case $prev in -backup|-display|-help) - return 0 + return ;; -cpp|-edit) _filedir - return 0 + return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) - return 0 + return fi _filedir } && complete -F _xrdb xrdb -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xsltproc b/completions/xsltproc index 7c38591f..98d3e72a 100644 --- a/completions/xsltproc +++ b/completions/xsltproc @@ -6,44 +6,44 @@ _xsltproc() _init_completion || return case $prev in - --output|-o) + --output|-o) _filedir - return 0 + return ;; # TODO : number only --maxdepth) - return 0 + return ;; --encoding) # some aliases removed - COMPREPLY=( $( compgen -W "$( iconv -l | sed -e '/^UTF[1378]/d' \ + COMPREPLY=( $( compgen -W "$( iconv -l | command sed -e '/^UTF[1378]/d' \ -e '/^ISO[0-9_]/d' -e '/^8859/d' -e 's/\/.*//')" -- "$cur" ) ) - return 0 + return ;; --param|--stringparam) - return 0 + return ;; # not really like --writesubtree --path) _filedir -d - return 0 + return ;; --writesubtree) _filedir -d - return 0 + return ;; esac - [[ $cword -gt 2 && `_get_cword '' 2` == --?(string)param ]] && \ - return 0 + [[ $cword -gt 2 && `_get_cword '' 2` == --?(string)param ]] && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( "${COMPREPLY[@]%:}" ) else - _filedir '@(xsl|xslt|xml)' + # TODO: 1st file xsl|xslt, 2nd XML + _filedir '@(xsl|xslt|xml|dbk|docbook|page)' fi } && complete -F _xsltproc xsltproc -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xxd b/completions/xxd index 050a2b66..f190d75a 100644 --- a/completions/xxd +++ b/completions/xxd @@ -20,4 +20,4 @@ _xxd() } && complete -F _xxd xxd -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xz b/completions/xz index e2e1b709..53e6b398 100644 --- a/completions/xz +++ b/completions/xz @@ -13,36 +13,40 @@ _xz() ;; --files|--files0) _filedir - return 0 + return ;; -C|--check) COMPREPLY=( $( compgen -W 'crc32 crc64 sha256 none' -- "$cur" ) ) - return 0 + return ;; -F|--format) COMPREPLY=( $( compgen -W 'auto xz lzma raw' -- "$cur" ) ) - return 0 + return + ;; + -T|--threads) + 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 - return 0 + return ;; -h|--help|-H|--long-help|-V|--version|--info-memory) # all other arguments are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return - _expand || return 0 + _expand || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \ -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi local IFS=$'\n' @@ -52,4 +56,4 @@ _xz() } && complete -F _xz xz pxz -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/xzdec b/completions/xzdec index fc32492e..5475a8e2 100644 --- a/completions/xzdec +++ b/completions/xzdec @@ -8,24 +8,24 @@ _xzdec() case $prev in -M|--memory) # argument required but no completions available - return 0 + return ;; -h|--help|-V|--version) # all other arguments are noop with these - return 0 + return ;; esac - $split && return 0 + $split && return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - return 0 + return fi _filedir xz # no lzma support here as of xz 4.999.9beta } && complete -F _xzdec xzdec -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/ypmatch b/completions/ypmatch index 99d80c43..c6de48b3 100644 --- a/completions/ypmatch +++ b/completions/ypmatch @@ -7,22 +7,20 @@ _ypmatch() local map cmd=${1##*/} - [[ $cmd == ypcat && $cword -gt 1 ]] && return 0 - [[ $cmd == ypmatch && $cword -gt 2 ]] && return 0 + [[ $cmd == ypcat && $cword -gt 1 ]] && return + [[ $cmd == ypmatch && $cword -gt 2 ]] && return 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" ) ) else - [[ $cmd == ypmatch && $cword -ne 2 ]] && return 0 + [[ $cmd == ypmatch && $cword -ne 2 ]] && return COMPREPLY=( $( compgen -W \ '$( printf "%s\n" $(ypcat -x 2>/dev/null | \ cut -d"\"" -f 2) )' -- "$cur" ) ) fi - - return 0 } && complete -F _ypmatch ypmatch ypcat -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/yum-arch b/completions/yum-arch index 8c217373..9dac178e 100644 --- a/completions/yum-arch +++ b/completions/yum-arch @@ -13,4 +13,4 @@ _yum_arch() } && complete -F _yum_arch yum-arch -# ex: ts=4 sw=4 et filetype=sh +# ex: filetype=sh diff --git a/completions/zopfli b/completions/zopfli new file mode 100644 index 00000000..23da6dbf --- /dev/null +++ b/completions/zopfli @@ -0,0 +1,31 @@ +# bash completion for zopfli -*- shell-script -*- + +_zopfli() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h) + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W \ + '$( _parse_help "$1" -h | command sed -e "s/#$//" )' -- "$cur" ) ) + [[ $COMPREPLY == --i ]] && compopt -o nospace + return + fi + + local IFS=$'\n' xspec="*.@(gz|t[ag]z)" + + _expand || return + + compopt -o filenames + COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ + $( compgen -d -- "$cur" ) ) +} && +complete -F _zopfli zopfli + +# ex: filetype=sh diff --git a/completions/zopflipng b/completions/zopflipng new file mode 100644 index 00000000..88ddbe68 --- /dev/null +++ b/completions/zopflipng @@ -0,0 +1,39 @@ +# bash completion for zopflipng -*- shell-script -*- + +_zopflipng() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help) + return + ;; + --splitting) + COMPREPLY=( $( compgen -W '{0..3}' -- "$cur" ) ) + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( _parse_help "$1" -h ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]%:}' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + if [[ ${words[@]} != *\ --prefix=* ]]; then + # 2 png args only if --prefix not given + local args + _count_args + [[ $args -lt 3 ]] && _filedir png + else + # otherwise arbitrary number of png args + _filedir png + fi +} && +complete -F _zopflipng zopflipng + +# ex: filetype=sh |