aboutsummaryrefslogtreecommitdiffstats
path: root/timetasker.bash-completion
blob: 75f7f1bebd70199e0047827d671deab1d660ad46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Bash completion for timetasker

_timetasker () {
	local cur
	local previous
	local config_file=~/.config/timetasker/config.toml
	local projects=$(sed -n -e 's/\]//' -e 's/\[projects\.//p' "$config_file")

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

	if [ "$previous" == '-p' ]; then
		COMPREPLY=( $(compgen -W "$projects" -- $cur) )
	fi

	return 0
}

complete -o default -F _timetasker timetasker