init.zsh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #
  2. # Enables local Perl module installation on macOS and defines aliases.
  3. #
  4. # Authors:
  5. # Sorin Ionescu <sorin.ionescu@gmail.com>
  6. #
  7. # Return if requirements are not found.
  8. if (( ! $+commands[perl] )); then
  9. return 1
  10. fi
  11. # Load dependencies.
  12. pmodload 'helper'
  13. #
  14. # Load Perlbrew or plenv
  15. #
  16. # Load Perlbrew into the shell session.
  17. if [[ -s "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/bashrc" ]]; then
  18. source "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/bashrc"
  19. # Load Perlbrew completion.
  20. if [[ -s "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/perlbrew-completion.bash" ]]; then
  21. source "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/perlbrew-completion.bash"
  22. fi
  23. # Load manually installed plenv into the shell session.
  24. elif [[ -s "$HOME/.plenv/bin/plenv" ]]; then
  25. path=("$HOME/.plenv/bin" $path)
  26. eval "$(plenv init - --no-rehash zsh)"
  27. # Load package manager installed plenv into the shell session.
  28. elif (( $+commands[plenv] )); then
  29. eval "$(plenv init - --no-rehash zsh)"
  30. fi
  31. #
  32. # Local Module Installation
  33. #
  34. if is-darwin; then
  35. # Perl is slow; cache its output.
  36. cache_file="${XDG_CACHE_HOME:-$HOME/.cache}/prezto/perl-cache.zsh"
  37. perl_path="$HOME/Library/Perl/5.12"
  38. if [[ -f "$perl_path/lib/perl5/local/lib.pm" ]]; then
  39. if [[ "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" || ! -s "$cache_file" ]]; then
  40. mkdir -p "$cache_file:h"
  41. perl -I$perl_path/lib/perl5 -Mlocal::lib=$perl_path >! "$cache_file"
  42. fi
  43. source "$cache_file"
  44. fi
  45. unset cache_file perl_path
  46. fi
  47. #
  48. # Aliases
  49. #
  50. if ! zstyle -t ':prezto:module:perl:alias' skip; then
  51. # General
  52. alias pl='perl'
  53. alias pld='perldoc'
  54. alias ple='perl -wlne'
  55. # Perlbrew
  56. if (( $+commands[perlbrew] )); then
  57. alias plb='perlbrew'
  58. alias plba='perlbrew available'
  59. alias plbi='perlbrew install'
  60. alias plbl='perlbrew list'
  61. alias plbo='perlbrew off'
  62. alias plbO='perlbrew switch-off'
  63. alias plbs='perlbrew switch'
  64. alias plbu='perlbrew use'
  65. alias plbx='perlbrew uninstall'
  66. elif (( $+commands[plenv] )); then
  67. alias plv='plenv'
  68. alias plvc='plenv commands'
  69. alias plvl='plenv local'
  70. alias plvg='plenv global'
  71. alias plvs='plenv shell'
  72. alias plvi='plenv install'
  73. alias plvu='plenv uninstall'
  74. alias plvr='plenv rehash'
  75. alias plvv='plenv version'
  76. alias plvV='plenv versions'
  77. alias plvw='plenv which'
  78. alias plvW='plenv whence'
  79. alias plvm='plenv list-modules'
  80. alias plvM='plenv migrate-modules'
  81. alias plvI='plenv install-cpanm'
  82. fi
  83. fi