-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompletion.sh
44 lines (39 loc) · 1.06 KB
/
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
#!/bin/bash
# i have no idea what i'm doing
_y() {
local cur prev opts
COMREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="do done procrastinate proc superprocrastinate prio prioritize vanish rm later feierabend"
case "${prev}" in
done|procrastinate|superprocrastinate|proc|prio|prioritize)
IFS=$'\n' tmp=( $(compgen -W "$(ls ~/y/data/today)" -- "${COMP_WORDS[$COMP_CWORD]}" ))
COMPREPLY=( "${tmp[@]// /\ }" )
return 0
;;
do)
IFS=$'\n' tmp=( $(compgen -W "$(ls ~/y/data/today && ls ~/y/data/tomorrow)" -- "${COMP_WORDS[$COMP_CWORD]}" ))
COMPREPLY=( "${tmp[@]// /\ }" )
return 0
;;
vanish) # extremely ghetto
opts="today tomorrow later"
case "${prev}" in
today)
IFS=$'\n' tmp=( $(compgen -W "$(ls ~/y/data/today)" -- "${COMP_WORDS[$COMP_CWORD]}" ))
COMPREPLY=( "${tmp[@]// /\ }" )
return 0
;;
"")
return 1
;;
esac
;;
*)
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
# return 0
}
complete -F _y y