-
Notifications
You must be signed in to change notification settings - Fork 40
/
shell_completion.sh
51 lines (45 loc) · 1.19 KB
/
shell_completion.sh
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
#
# Phil Adams http://philadams.net
# habitica: commandline interface for http://habitica.com
# http://github.com/philadams/habitica
#
# habitica shell completion script
# copy to /etc/bash_completion.d/
# or source in .bashrc/.zshrc
#
_habitica()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
#
# The basic options we'll complete.
#
opts="status habits dailies todos server home --help --version --verbose --debug"
#
# Complete the arguments to some of the basic commands.
#
case "${prev}" in
habits)
local habitsopt="up down"
COMPREPLY=( $(compgen -W "${habitsopt}" -- ${cur}) )
return 0
;;
dailies)
local dailiesopt="done undo"
COMPREPLY=( $(compgen -W "${dailiesopt}" -- ${cur}) )
return 0
;;
todos)
local todosopt="done add delete"
COMPREPLY=( $(compgen -W "${todosopt}" -- ${cur}) )
return 0
;;
*)
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
}
complete -F _habitica habitica