completion.sh 1.2 KB

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