diff --git a/CHANGES b/CHANGES index db9b9231..1c76d6a1 100644 --- a/CHANGES +++ b/CHANGES @@ -58,6 +58,7 @@ bash-completion (2.x) * Split mount and umount completion into contrib/mount. * Split service completion into contrib/service. * Split chown, chgrp, and id completions into contrib/coreutils. + * Split kill, look, and renice completions into contrib/util-linux. * Do basic HTML file completion with Firefox and Chrome and friends, and Epiphany. * Do basic diff/patch completion with cdiff and kompare. diff --git a/Makefile.am b/Makefile.am index 7e03d5c8..645df14c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -145,6 +145,7 @@ bashcomp_DATA = contrib/abook \ contrib/unace \ contrib/unrar \ contrib/update-alternatives \ + contrib/util-linux \ contrib/vncviewer \ contrib/vpnc \ contrib/wireless-tools \ diff --git a/bash_completion b/bash_completion index bfba066b..4d89fc95 100644 --- a/bash_completion +++ b/bash_completion @@ -1081,58 +1081,6 @@ _dvd_devices() [ $UNAME = FreeBSD ] && complete -W 'index search fetch fetch-list extract \ patch configure build install reinstall deinstall clean clean-depends \ kernel buildworld' make - - -# renice(8) completion -# -_renice() -{ - local command cur curopt i - - COMPREPLY=() - cur=`_get_cword` - command=$1 - - i=0 - # walk back through command line and find last option - while [[ $i -le $COMP_CWORD && ${#COMPREPLY[@]} -eq 0 ]]; do - curopt=${COMP_WORDS[COMP_CWORD-$i]} - case "$curopt" in - -u) - COMPREPLY=( $( compgen -u -- "$cur" ) ) - ;; - -g) - _pgids - ;; - -p|$command) - _pids - ;; - esac - i=$(( ++i )) - done -} -complete -F _renice renice - - -# kill(1) completion -# -_kill() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then - # return list of available signals - _signals - else - # return list of available PIDs - _pids - fi -} -complete -F _kill kill - # killall(1) (Linux and FreeBSD) and pkill(1) completion. # [[ $UNAME == Linux || $UNAME == FreeBSD ]] || have pkill && @@ -1648,22 +1596,6 @@ for i in env netstat seq uname units; do done unset i -# look(1) completion -# -have look && -_look() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - if [ $COMP_CWORD = 1 ]; then - COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) ) - fi -} && -complete -F _look -o default look - _filedir_xspec() { local IFS cur xspec diff --git a/contrib/util-linux b/contrib/util-linux new file mode 100644 index 00000000..1ac900fa --- /dev/null +++ b/contrib/util-linux @@ -0,0 +1,76 @@ +# Completions for tools included in util-linux (not necessarily Linux specific) + +# renice(8) completion +# +have renice && +_renice() +{ + local command cur curopt i + + COMPREPLY=() + cur=`_get_cword` + command=$1 + + i=0 + # walk back through command line and find last option + while [[ $i -le $COMP_CWORD && ${#COMPREPLY[@]} -eq 0 ]]; do + curopt=${COMP_WORDS[COMP_CWORD-$i]} + case "$curopt" in + -u) + COMPREPLY=( $( compgen -u -- "$cur" ) ) + ;; + -g) + _pgids + ;; + -p|$command) + _pids + ;; + esac + i=$(( ++i )) + done +} && +complete -F _renice renice + +# kill(1) completion +# +have kill && +_kill() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then + # return list of available signals + _signals + else + # return list of available PIDs + _pids + fi +} && +complete -F _kill kill + +# look(1) completion +# +have look && +_look() +{ + local cur + + COMPREPLY=() + cur=`_get_cword` + + if [ $COMP_CWORD = 1 ]; then + COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) ) + fi +} && +complete -F _look -o default look + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh