[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-450-ga6c9c61
Ville Skyttä
ville.skytta at iki.fi
Tue Oct 11 18:11:21 UTC 2011
The following commit has been merged in the master branch:
commit 049b60ec61bebfd82e88eba3bc1df6fc138c38e5
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Tue Oct 11 21:06:36 2011 +0300
watch: New completion (Linux only for now).
diff --git a/completions/procps b/completions/procps
index 076e2b7..b12b936 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 0000000..9bb0644
--- /dev/null
+++ b/test/completion/watch.exp
@@ -0,0 +1 @@
+assert_source_completions watch
diff --git a/test/lib/completions/a2ps.exp b/test/lib/completions/watch.exp
similarity index 79%
copy from test/lib/completions/a2ps.exp
copy to test/lib/completions/watch.exp
index 77cd07f..02ae8f1 100644
--- a/test/lib/completions/a2ps.exp
+++ b/test/lib/completions/watch.exp
@@ -11,9 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "a2ps "
-
-
+assert_complete_any "watch -"
sync_after_int
--
bash-completion
More information about the Bash-completion-commits
mailing list