Debian Codegraph @

contrib/cmus.bash-completion

raw
1 # bash completion for cmus-remote and cmus
2
3 _cmus-remote()
4 {
5 local cur prev longopts shortopts
6 cur="${COMP_WORDS[COMP_CWORD]}"
7 prev="${COMP_WORDS[COMP_CWORD-1]}"
8 # maybe we'll differentiate between $cur starting with - or --
9 longopts="--server --passwd --help --version --play --pause --stop
10 --next --prev --file --repeat --shuffle --volume --seek
11 --library --playlist --queue --clear --raw"
12 shortopts="-p -u -s -n -r -f -R -S -v -k -Q -l -P -q -c -C"
13
14 COMPREPLY=()
15
16 case "${prev}" in
17 --server) # can be a hostname[:port] or a filename
18 compopt -o nospace
19 _known_hosts_real -c "${cur}"
20 ;&
21 --file|-f)
22 _filedir
23 return 0
24 ;;
25 --passwd) # do not attempt to complete anything
26 ;&
27 --volume|-v)
28 ;&
29 --seek|-k)
30 ;&
31 --raw|-C)
32 # supporting completion for raw commands would be nice (TODO)
33 return 0
34 ;;
35 *)
36 ;;
37 esac
38
39 if [[ ${cur} == -* ]]; then
40 COMPREPLY=(
41 $(compgen -W "${shortopts[*]} ${longopts[*]}" -- ${cur})
42 )
43 else
44 _filedir
45 fi
46 }
47
48 _cmus()
49 {
50 local cur prev opts
51 cur="${COMP_WORDS[COMP_CWORD]}"
52 prev="${COMP_WORDS[COMP_CWORD-1]}"
53 opts="--listen --plugins --show-cursor --help --version"
54
55 COMPREPLY=()
56
57 case "${prev}" in
58 --listen)
59 compopt -o nospace
60 _ip_addresses
61 _filedir
62 return 0;
63 ;;
64 --plugins|--help|--version)
65 return 0;
66 ;;
67 *)
68 ;;
69 esac
70
71 COMPREPLY=($(compgen -W "${opts[*]}" -- ${cur}))
72 }
73
74 complete -F _cmus-remote cmus-remote
75 complete -F _cmus cmus