watch: New completion (Linux only for now).
This commit is contained in:
parent
ec5762cba9
commit
049b60ec61
@ -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
|
||||
|
1
test/completion/watch.exp
Normal file
1
test/completion/watch.exp
Normal file
@ -0,0 +1 @@
|
||||
assert_source_completions watch
|
18
test/lib/completions/watch.exp
Normal file
18
test/lib/completions/watch.exp
Normal file
@ -0,0 +1,18 @@
|
||||
proc setup {} {
|
||||
save_env
|
||||
}
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
assert_complete_any "watch -"
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
Loading…
x
Reference in New Issue
Block a user