-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcompletion.bash
43 lines (37 loc) · 1.07 KB
/
completion.bash
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
# vim: syntax=bash
_makesure_completions() {
local i cur prev cnt makesurefile=Makesurefile
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
cnt="${#COMP_WORDS[@]}"
if [[ "$prev" == '-f' || "$prev" == '--file' ]]
then
COMPREPLY=() # use regular completion logic to facilitate file/folder selection
return 0
fi
# before we scan for targets, see if a Makesurefile name was
# specified with -f/--file
for ((i = 1; i < cnt; i++)); do
if [[ ${COMP_WORDS[i]} == '-f' || ${COMP_WORDS[i]} == '--file' ]]; then
eval "makesurefile=${COMP_WORDS[i + 1]}"
break
fi
done
COMPREPLY=($(compgen -W "$(./makesure --file "$makesurefile" -la | awk -F: '
BEGIN {
print "-f --file"
print "-l --list"
print "-la --list-all"
print "-d --resolved"
print "-D"
print "-s --silent"
print "-t --timing"
print "-x --tracing"
print "-v --version"
print "-h --help"
print "-U --selfupdate"
}
NR>1 { sub(/^ +/,"",$1); print $1 }
')" -- "$cur"))
}
complete -F _makesure_completions -o bashdefault -o default ./makesure