watch: New completion (Linux only for now).

This commit is contained in:
Ville Skyttä 2011-10-11 21:06:36 +03:00
parent ec5762cba9
commit 049b60ec61
3 changed files with 69 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1 @@
assert_source_completions watch

View File

@ -0,0 +1,18 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "watch -"
sync_after_int
teardown