UNPKG

1.19 kBapplication/x-shView Raw
1###-begin-pm2-completion-###
2### credits to npm for the completion file model
3#
4# Installation: pm2 completion >> ~/.bashrc (or ~/.zshrc)
5#
6
7COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
8COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
9export COMP_WORDBREAKS
10
11if 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
22elif 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
39fi
40###-end-pm2-completion-###