-
Notifications
You must be signed in to change notification settings - Fork 2
/
fab-complete
42 lines (37 loc) · 894 Bytes
/
fab-complete
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
_check() {
SKIP=false
# Fab in the path?
[[ -n `/usr/bin/which fab` ]] || SKIP=true
# Fabfile in this folder?
[[ -e fabfile.py ]] || SKIP=true
}
_fab_completion_0() {
COMPREPLY=()
_check
if [ "$SKIP" != "true" ]
then
tasks=$(fab -l 2>/dev/null | grep "^ " | awk '{print $1;}')
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
fi
}
_fab_completion_1() {
COMPREPLY=()
_check
if [ "$SKIP" != "true" ]
then
tasks=$(fab --shortlist)
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
fi
}
if [[ -n `/usr/bin/which fab` ]]
then
if [[ `fab --help|grep -c shortlist` -gt 0 ]]
then
complete -F _fab_completion_1 fab
else
# fab < 1.0
complete -F _fab_completion_0 fab
fi
fi