init.zsh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #
  2. # Configures Node local installation, loads version managers, and defines
  3. # variables and aliases.
  4. #
  5. # Authors:
  6. # Sorin Ionescu <sorin.ionescu@gmail.com>
  7. # Zeh Rizzatti <zehrizzatti@gmail.com>
  8. # Indrajit Raychaudhuri <irc@indrajit.com>
  9. #
  10. # Possible lookup locations for manually installed nodenv and nvm.
  11. local_nodenv_paths=({$NODENV_ROOT,{$XDG_CONFIG_HOME/,$HOME/.}nodenv}/bin/nodenv(N))
  12. local_nvm_paths=({$NVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}nvm}/nvm.sh(N))
  13. # Load manually installed or package manager installed nodenv into the shell
  14. # session.
  15. if (( $#local_nodenv_paths || $+commands[nodenv] )); then
  16. # Ensure manually installed nodenv is added to path when present.
  17. [[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path)
  18. eval "$(nodenv init - zsh)"
  19. # Load manually installed nvm into the shell session.
  20. elif (( $#local_nvm_paths )); then
  21. source "$local_nvm_paths[1]" --no-use
  22. # Load package manager installed nvm into the shell session.
  23. elif (( $+commands[brew] )) \
  24. && [[ -d "${nvm_path::="$(brew --prefix 2> /dev/null)"/opt/nvm}" ]]; then
  25. source "$nvm_path/nvm.sh" --no-use
  26. fi
  27. unset local_n{odenv,vm}_paths nvm_path
  28. # Return if requirements are not found.
  29. if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] )); then
  30. return 1
  31. fi
  32. #
  33. # Variables
  34. #
  35. N_PREFIX="${XDG_CONFIG_HOME:-$HOME/.config}/n" # The path to 'n' cache.
  36. #
  37. # Aliases
  38. #
  39. if ! zstyle -t ':prezto:module:node:alias' skip; then
  40. # npm
  41. alias npmi='npm install'
  42. alias npml='npm list'
  43. alias npmo='npm outdated'
  44. alias npmp='npm publish'
  45. alias npmP='npm prune'
  46. alias npmr='npm run'
  47. alias npms='npm search'
  48. alias npmt='npm test'
  49. alias npmu='npm update'
  50. alias npmx='npm uninstall'
  51. alias npmci='npm ci'
  52. alias npmcit='npm cit'
  53. alias npmit='npm it'
  54. fi