File: cmus.bash-completion

package info (click to toggle)
cmus 2.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,404 kB
  • sloc: ansic: 40,498; sh: 1,642; makefile: 255; python: 157
file content (75 lines) | stat: -rw-r--r-- 1,448 bytes parent folder | download | duplicates (6)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# bash completion for cmus-remote and cmus

_cmus-remote()
{
	local cur prev longopts shortopts
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"
	# maybe we'll differentiate between $cur starting with - or --
	longopts="--server --passwd --help --version --play --pause --stop
		--next --prev --file --repeat --shuffle --volume --seek
		--library --playlist --queue --clear --raw"
	shortopts="-p -u -s -n -r -f -R -S -v -k -Q -l -P -q -c -C"

	COMPREPLY=()

	case "${prev}" in
		--server) # can be a hostname[:port] or a filename
			compopt -o nospace
			_known_hosts_real -c "${cur}"
			;&
		--file|-f)
			_filedir
			return 0
			;;
		--passwd) # do not attempt to complete anything
			;&
		--volume|-v)
			;&
		--seek|-k)
			;&
		--raw|-C)
		# supporting completion for raw commands would be nice (TODO)
			return 0
			;;
		*)
			;;
	esac

	if [[ ${cur} == -* ]]; then
		COMPREPLY=(
			$(compgen -W "${shortopts[*]} ${longopts[*]}" -- ${cur})
		)
	else
		_filedir
	fi
}

_cmus()
{
	local cur prev opts
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"
	opts="--listen --plugins --show-cursor --help --version"

	COMPREPLY=()

	case "${prev}" in
		--listen)
			compopt -o nospace
			_ip_addresses
			_filedir
			return 0;
			;;
		--plugins|--help|--version)
			return 0;
			;;
		*)
			;;
	esac

	COMPREPLY=($(compgen -W "${opts[*]}" -- ${cur}))
}

complete -F _cmus-remote cmus-remote
complete -F _cmus cmus