diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-12-27 21:52:58 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-12-27 21:52:58 +0200 |
commit | 59a8a9c41b222d8bff2b053d7a95227ef512b2e1 (patch) | |
tree | a08d25ae92a2b53507f6a28c123094638f5ad564 | |
parent | 5fcaad875665e9378e661ee398358908a4ef99f8 (diff) | |
download | bash-completion-59a8a9c41b222d8bff2b053d7a95227ef512b2e1.tar.gz |
pgrep, pkill, killall: Base pkill on pgrep, add more option completions.
-rw-r--r-- | completions/Makefile.am | 8 | ||||
-rw-r--r-- | completions/killall | 19 | ||||
-rw-r--r-- | completions/pgrep | 19 | ||||
-rw-r--r-- | test/lib/completions/killall.exp | 2 |
4 files changed, 30 insertions, 18 deletions
diff --git a/completions/Makefile.am b/completions/Makefile.am index 70cc7cad..ba3cfb03 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -643,10 +643,6 @@ symlinks: rm -f $(targetdir)/$$file && \ $(LN_S) java $(targetdir)/$$file ; \ done - for file in pkill ; do \ - rm -f $(targetdir)/$$file && \ - $(LN_S) killall $(targetdir)/$$file ; \ - done for file in arm-koji ppc-koji s390-koji sparc-koji ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) koji $(targetdir)/$$file ; \ @@ -713,6 +709,10 @@ symlinks: 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 ; \ diff --git a/completions/killall b/completions/killall index d2f6dd47..ed502f97 100644 --- a/completions/killall +++ b/completions/killall @@ -1,4 +1,6 @@ -# killall(1) and pkill(1) completion -*- shell-script -*- +# killall(1) completion -*- shell-script -*- + +[[ $OSTYPE == *@(linux|freebsd|darwin)* ]] || return 1 _killall() { @@ -10,7 +12,7 @@ _killall() return ;; -s|--signal) - [[ $1 == *killall ]] && _signals + _signals return ;; -u|--user) @@ -21,15 +23,14 @@ _killall() $split && return - if [[ $cword -eq 1 && "$cur" == -* ]]; then - _signals - - else - _pnames + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $cword -eq 1 ]] && _signals - + return fi - return 0 + _pnames } && -complete -F _killall pkill -[[ $OSTYPE == *@(linux|freebsd|darwin)* ]] && complete -F _killall killall || : +complete -F _killall killall # ex: ts=4 sw=4 et filetype=sh diff --git a/completions/pgrep b/completions/pgrep index 87df1a1f..0a1c862f 100644 --- a/completions/pgrep +++ b/completions/pgrep @@ -1,4 +1,4 @@ -# pgrep(1) completion -*- shell-script -*- +# pgrep(1) and pkill(1) completion -*- shell-script -*- _pgrep() { @@ -6,13 +6,21 @@ _pgrep() _init_completion || return case $prev in - -d|-g|-s|-t) + -c|-d|-g|-J|-M|-N|-s|-t|-T|-z) + return + ;; + -F) + _filedir return ;; -G) _gids return ;; + -j) + COMPREPLY=( $( compgen -W 'any none' -- "$cur" ) ) + return + ;; -P) _pids return @@ -24,12 +32,15 @@ _pgrep() esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( "$1" --usage 2>&1 | + sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//" | + _parse_usage - )' -- "$cur" ) ) + [[ $cword -eq 1 && $1 == *pkill ]] && _signals - return fi _pnames } && -complete -F _pgrep pgrep +complete -F _pgrep pgrep pkill # ex: ts=4 sw=4 et filetype=sh diff --git a/test/lib/completions/killall.exp b/test/lib/completions/killall.exp index 1ee3ade8..feec9337 100644 --- a/test/lib/completions/killall.exp +++ b/test/lib/completions/killall.exp @@ -17,7 +17,7 @@ assert_complete_any "killall " sync_after_int -assert_complete [get_signals -] "killall -" +assert_complete [get_signals] "killall --signal " sync_after_int |