diff --git a/completions/Makefile.am b/completions/Makefile.am index 507a6b73..03165cf4 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -321,6 +321,7 @@ bashcomp_DATA = a2x \ usermod \ valgrind \ vipw \ + vmstat \ vncviewer \ vpnc \ watch \ diff --git a/completions/vmstat b/completions/vmstat new file mode 100644 index 00000000..1d3ebb32 --- /dev/null +++ b/completions/vmstat @@ -0,0 +1,27 @@ +# vmstat(8) completion -*- shell-script -*- + +_vmstat() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -V|-c|-M|-N|-n|-w|-p) + return + ;; + -S) + [[ $OSTYPE == *linux* ]] && \ + COMPREPLY=( $( compgen -W 'k K m M' -- "$cur" ) ) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY ]] || \ + COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) + fi +} && +complete -F _vmstat vmstat + +# ex: ts=4 sw=4 et filetype=sh diff --git a/test/completion/vmstat.exp b/test/completion/vmstat.exp new file mode 100644 index 00000000..e55f28e3 --- /dev/null +++ b/test/completion/vmstat.exp @@ -0,0 +1 @@ +assert_source_completions vmstat diff --git a/test/lib/completions/vmstat.exp b/test/lib/completions/vmstat.exp new file mode 100644 index 00000000..f749322a --- /dev/null +++ b/test/lib/completions/vmstat.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup +assert_complete_any "vmstat -" + + +sync_after_int + + +teardown