-
Notifications
You must be signed in to change notification settings - Fork 0
/
watchmon-completion
50 lines (41 loc) · 1.07 KB
/
watchmon-completion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# watchmon completion -*- shell-script -*-
__get_battery_devices()
{
find /sys/class/power_supply -name 'BAT*' | xargs basename
}
_watchmon_completions()
{
local cur prev OPTS
_init_completion || return
subcmd="${COMP_WORDS[1]}"
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-bat')
COMPREPLY=( $(compgen -W "$(__get_battery_devices)" -- $cur) )
return 0
;;
'-output')
COMPREPLY=( $(compgen -W "plain yaml json" -- $cur) )
return 0
;;
esac
case $subcmd in
'measure')
COMPREPLY=( $(compgen -W "-bat -output" -- $cur) )
return 0
;;
'completions')
return 0
;;
esac
case $cur in
*)
OPTS="measure completions init"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
return 0
}
complete -o bashdefault -F _watchmon_completions watchmon