File: bashrc

package info (click to toggle)
cdcd 0.6.6-13.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 1,532 kB
  • sloc: ansic: 4,892; sh: 2,142; makefile: 29
file content (47 lines) | stat: -rw-r--r-- 707 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
# put this in your bashrc for bash tab completion with cdcd
# $ cat cdcd-bashrc >> ~/.bashrc

ismember ()
{
	local elm="${1}"; shift
	local pivot

	for pivot in ${*}
	do
		if [ "${pivot}" = "${elm}" ]
		then
			return 0
		fi
	done

	return 1
}

 _cdcd_complete_func ()
{
	cur="${COMP_WORDS[COMP_CWORD]}"
	first="${COMP_WORDS[1]}"
	second="${COMP_WORDS[2]}"

	commands="$(cdcd help | grep -v 'For more')"
	commands="${commands#Commands: }"
	commands="${commands//,/}"
	commands="${commands/./}"

	if ismember "${first}" ${commands}
	then
		COMPREPLY=""

		return 0
	fi

	case "${first}" in
	*)
		COMPREPLY="($(compgen -W "${commands}" ${cur}))"

		return 0
		;;
	esac
}

complete -F _cdcd_complete_func cdcd