_bower 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Credits to npm's awesome completion utility.
  2. #
  3. # Bower completion script, based on npm completion script.
  4. ###-begin-bower-completion-###
  5. #
  6. # Installation: bower completion >> ~/.bashrc (or ~/.zshrc)
  7. # Or, maybe: bower completion > /usr/local/etc/bash_completion.d/bower
  8. #
  9. COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
  10. COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
  11. export COMP_WORDBREAKS
  12. if type complete &>/dev/null; then
  13. _bower_completion () {
  14. local si="$IFS"
  15. IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
  16. COMP_LINE="$COMP_LINE" \
  17. COMP_POINT="$COMP_POINT" \
  18. bower completion -- "${COMP_WORDS[@]}" \
  19. 2>/dev/null)) || return $?
  20. IFS="$si"
  21. }
  22. complete -F _bower_completion bower
  23. elif type compdef &>/dev/null; then
  24. _bower_completion() {
  25. si=$IFS
  26. compadd -- $(COMP_CWORD=$((CURRENT-1)) \
  27. COMP_LINE=$BUFFER \
  28. COMP_POINT=0 \
  29. bower completion -- "${words[@]}" \
  30. 2>/dev/null)
  31. IFS=$si
  32. }
  33. compdef _bower_completion bower
  34. elif type compctl &>/dev/null; then
  35. _bower_completion () {
  36. local cword line point words si
  37. read -Ac words
  38. read -cn cword
  39. let cword-=1
  40. read -l line
  41. read -ln point
  42. si="$IFS"
  43. IFS=$'\n' reply=($(COMP_CWORD="$cword" \
  44. COMP_LINE="$line" \
  45. COMP_POINT="$point" \
  46. bower completion -- "${words[@]}" \
  47. 2>/dev/null)) || return $?
  48. IFS="$si"
  49. }
  50. compctl -K _bower_completion bower
  51. fi
  52. ###-end-bower-completion-###