aboutsummaryrefslogtreecommitdiffstats
path: root/qcd.bash-completion
blob: 569d05036566df74af40f6bf4690257748e1db25 (plain)
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
# Bash completion for the qcd() function

# Copyright © 2016 Teddy Wing
# This file is licensed under the GNU GPLv3+. Please see COPYING
# for more information.

_qcd () {
	local cur
	local shortcuts=$(awk '{ print $1 }' $QCD_DATABASE_FILE)

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

	case "$COMP_CWORD" in
		1|2)
			COMPREPLY=( $( compgen -W "$shortcuts" -- $cur ) )
			;;
		3)
			COMPREPLY=()
			;;
	esac

	return 0
}

complete -o default -F _qcd qcd