diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-10-11 21:06:36 +0300 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-10-11 21:10:08 +0300 |
commit | 049b60ec61bebfd82e88eba3bc1df6fc138c38e5 (patch) | |
tree | 144d3178c38d322555a27072374c05c069ebbbc4 | |
parent | ec5762cba9ef34f6836da858560e47b196cbb6cf (diff) | |
download | bash-completion-049b60ec61bebfd82e88eba3bc1df6fc138c38e5.tar.gz |
watch: New completion (Linux only for now).
-rw-r--r-- | completions/procps | 50 | ||||
-rw-r--r-- | test/completion/watch.exp | 1 | ||||
-rw-r--r-- | test/lib/completions/watch.exp | 18 |
3 files changed, 69 insertions, 0 deletions
diff --git a/completions/procps b/completions/procps index 076e2b7a..b12b936e 100644 --- a/completions/procps +++ b/completions/procps @@ -73,6 +73,56 @@ _pwdx() } && complete -F _pwdx pwdx +[[ $UNAME == Linux ]] && have watch && +_watch() +{ + local cur prev words cword split + _init_completion -s || return + + local offset=0 i + for (( i=1; i <= cword; i++ )); do + case ${words[i]} in + -h|--help|--version) + return + ;; + -n|--interval) + (( i++ )) + continue + ;; + -*) + continue + ;; + esac + offset=$i + break + done + + if [[ $offset -gt 0 ]]; then + _command_offset $offset + return + fi + + case $prev in + -d|--differences) + [[ $cur != -* ]] && \ + COMPREPLY=( $( compgen -W 'cumulative' -- "$cur" ) ) + return + ;; + -n|--interval) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi +} && +complete -F _watch watch + # Local variables: # mode: shell-script # sh-basic-offset: 4 diff --git a/test/completion/watch.exp b/test/completion/watch.exp new file mode 100644 index 00000000..9bb0644f --- /dev/null +++ b/test/completion/watch.exp @@ -0,0 +1 @@ +assert_source_completions watch diff --git a/test/lib/completions/watch.exp b/test/lib/completions/watch.exp new file mode 100644 index 00000000..02ae8f1b --- /dev/null +++ b/test/lib/completions/watch.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "watch -" +sync_after_int + + +teardown |