File: bash_completion

package info (click to toggle)
bins 1.1.29-16
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 5,836 kB
  • ctags: 2,351
  • sloc: perl: 5,161; xml: 2,536; sh: 314; makefile: 177
file content (63 lines) | stat: -rw-r--r-- 1,314 bytes parent folder | download | duplicates (5)
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
# bins completion for bash
#-*- mode: shell-script;-*-
_bins()
{
	local cur prev tempdir

	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	case "$prev" in
		-f)
			_filedir
			return 0
			;;
		-o)
			COMPREPLY=( $( compgen -W 'scaled copied custom' -- $cur ) )
			return 0
			;;
		-c)
			conffile=$HOME/.bins/binsrc
			for (( i=1; i < COMP_CWORD; i++ )); do
				if [[ "${COMP_WORDS[i]}" == -f ]]; then
					conffile=${COMP_WORDS[i+1]}
					break
				fi
			done
			COMPREPLY=( \
				$( awk -F'"' '/<colors style="/ {print $2}' $conffile | grep "^$cur" ) \
				$( awk -F"'" "/<colors style='/ {print $2}" $conffile | grep "^$cur" ) \
				)
			return 0
			;;
		-t)
			_filedir -d
			return 0
			;;
		-r)
			COMPREPLY=( $( compgen -W 'dirs pictures dirs,pictures' -- $cur ) )
			return 0
			;;
		-s)
			tempdir=/usr/share/bins
			for (( i=1; i < COMP_CWORD; i++ )); do
				if [[ "${COMP_WORDS[i]}" == -t ]]; then
					tempdir=${COMP_WORDS[i+1]}
					break
				fi
			done
			COMPREPLY=( $( find $tempdir -type d -maxdepth 1 -name templates.* | \
				sed -e "s|$tempdir/templates.||" | grep "^$cur" ) )
			return 0
			;;
	esac

	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $( compgen -W '-f -o -d -c -s -t -p -r -e -i -n -v -h' -- $cur ) )
	else
		_filedir -d
	fi

}
complete -F _bins bins