npm.plugin.zsh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (( $+commands[npm] )) && {
  2. rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
  3. _npm_completion() {
  4. local si=$IFS
  5. compadd -- $(COMP_CWORD=$((CURRENT-1)) \
  6. COMP_LINE=$BUFFER \
  7. COMP_POINT=0 \
  8. npm completion -- "${words[@]}" \
  9. 2>/dev/null)
  10. IFS=$si
  11. }
  12. compdef _npm_completion npm
  13. }
  14. # Install dependencies globally
  15. alias npmg="npm i -g "
  16. # npm package names are lowercase
  17. # Thus, we've used camelCase for the following aliases:
  18. # Install and save to dependencies in your package.json
  19. # npms is used by https://www.npmjs.com/package/npms
  20. alias npmS="npm i -S "
  21. # Install and save to dev-dependencies in your package.json
  22. # npmd is used by https://github.com/dominictarr/npmd
  23. alias npmD="npm i -D "
  24. # Force npm to fetch remote resources even if a local copy exists on disk.
  25. alias npmF='npm i -f'
  26. # Execute command from node_modules folder based on current directory
  27. # i.e npmE gulp
  28. alias npmE='PATH="$(npm bin)":"$PATH"'
  29. # Check which npm modules are outdated
  30. alias npmO="npm outdated"
  31. # Update all the packages listed to the latest version
  32. alias npmU="npm update"
  33. # Check package versions
  34. alias npmV="npm -v"
  35. # List packages
  36. alias npmL="npm list"
  37. # List top-level installed packages
  38. alias npmL0="npm ls --depth=0"
  39. # Run npm start
  40. alias npmst="npm start"
  41. # Run npm test
  42. alias npmt="npm test"
  43. # Run npm scripts
  44. alias npmR="npm run"
  45. # Run npm publish
  46. alias npmP="npm publish"
  47. # Run npm init
  48. alias npmI="npm init"
  49. # Run npm info
  50. alias npmi="npm info"
  51. # Run npm search
  52. alias npmSe="npm search"