bower.plugin.zsh 792 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. alias bi="bower install"
  2. alias bl="bower list"
  3. alias bs="bower search"
  4. bower_package_list=''
  5. _bower ()
  6. {
  7. local curcontext="$curcontext" state line
  8. typeset -A opt_args
  9. _arguments -C \
  10. ':command:->command' \
  11. '*::options:->options'
  12. case $state in
  13. (command)
  14. local -a subcommands
  15. subcommands=(${=$(bower help | grep help | sed -e 's/,//g')})
  16. _describe -t commands 'bower' subcommands
  17. ;;
  18. (options)
  19. case $line[1] in
  20. (install)
  21. if [ -z "$bower_package_list" ];then
  22. bower_package_list=$(bower search | awk 'NR > 2' | cut -d '-' -f 2 | cut -d ' ' -f 2 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
  23. fi
  24. compadd "$@" $(echo $bower_package_list)
  25. ;;
  26. esac
  27. ;;
  28. esac
  29. }
  30. compdef _bower bower