1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | if type complete &>/dev/null; then
|
11 | __karma_completion () {
|
12 | local si="$IFS"
|
13 | IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
|
14 | COMP_LINE="$COMP_LINE" \
|
15 | COMP_POINT="$COMP_POINT" \
|
16 | karma completion -- "${COMP_WORDS[@]}" \
|
17 | 2>/dev/null)) || return $?
|
18 | IFS="$si"
|
19 | }
|
20 | complete -F __karma_completion karma
|
21 | elif type compdef &>/dev/null; then
|
22 | __karma_completion() {
|
23 | si=$IFS
|
24 | compadd -- $(COMP_CWORD=$((CURRENT-1)) \
|
25 | COMP_LINE=$BUFFER \
|
26 | COMP_POINT=0 \
|
27 | karma completion -- "${words[@]}" \
|
28 | 2>/dev/null)
|
29 | IFS=$si
|
30 | }
|
31 | compdef __karma_completion karma
|
32 | elif type compctl &>/dev/null; then
|
33 | __karma_completion () {
|
34 | local cword line point words si
|
35 | read -Ac words
|
36 | read -cn cword
|
37 | let cword-=1
|
38 | read -l line
|
39 | read -ln point
|
40 | si="$IFS"
|
41 | IFS=$'\n' reply=($(COMP_CWORD="$cword" \
|
42 | COMP_LINE="$line" \
|
43 | COMP_POINT="$point" \
|
44 | karma completion -- "${words[@]}" \
|
45 | 2>/dev/null)) || return $?
|
46 | IFS="$si"
|
47 | }
|
48 | compctl -K __karma_completion karma
|
49 | fi
|
50 |
|