1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
|
8 | COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
|
9 | export COMP_WORDBREAKS
|
10 |
|
11 | if type complete &>/dev/null; then
|
12 | _pm2_completion () {
|
13 | local si="$IFS"
|
14 | IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
|
15 | COMP_LINE="$COMP_LINE" \
|
16 | COMP_POINT="$COMP_POINT" \
|
17 | pm2 completion -- "${COMP_WORDS[@]}" \
|
18 | 2>/dev/null)) || return $?
|
19 | IFS="$si"
|
20 | }
|
21 | complete -o default -F _pm2_completion pm2
|
22 | elif type compctl &>/dev/null; then
|
23 | _pm2_completion () {
|
24 | local cword line point words si
|
25 | read -Ac words
|
26 | read -cn cword
|
27 | let cword-=1
|
28 | read -l line
|
29 | read -ln point
|
30 | si="$IFS"
|
31 | IFS=$'\n' reply=($(COMP_CWORD="$cword" \
|
32 | COMP_LINE="$line" \
|
33 | COMP_POINT="$point" \
|
34 | pm2 completion -- "${words[@]}" \
|
35 | 2>/dev/null)) || return $?
|
36 | IFS="$si"
|
37 | }
|
38 | compctl -K _pm2_completion + -f + pm2
|
39 | fi
|
40 |
|