shosei

zshenv

May 10th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.94 KB | None | 0 0
  1. #!/bin/zsh
  2. #
  3. # .zshenv
  4. # for zsh 3.1.6 and newer (may work OK with earlier versions)
  5. # Best viewed in emacs folding mode (folding.el).
  6. # (That's what all the # {{{ and # }}} are for.)
  7. #
  8. # This gets run even for non-interactive shells;
  9. # keep it as fast as possible.
  10. #
  11. # N.B. This is for zsh-specific environment stuff.  Put generic,
  12. # portable environment settings in .shared_env instead, so that they
  13. # take effect for bash and ksh.
  14.  
  15. # Allow disabling of entire environment suite
  16. [ -n "$INHERIT_ENV" ] && return 0
  17.  
  18. # Stop bad system-wide scripts interfering.
  19. setopt NO_global_rcs
  20.  
  21. # {{{ What version are we running?
  22.  
  23. shell=zsh
  24.  
  25. ZSH_VERSION_TYPE=new
  26.  
  27. # }}}
  28.  
  29. # {{{ zdotdir
  30.  
  31. # ZDOTDIR is a zsh-ism but it's a good concept so we generalize it to
  32. # the other shells.
  33.  
  34. # This allows us to have a good set of .*rc files etc. in one place
  35. # and to be able to reuse that from a different account (e.g. root).
  36.  
  37. # We have to do some of this both here and in .shared_env to avoid
  38. # a chicken and egg thing when looking for the right .shared_env.
  39.  
  40. zdotdir=${ZDOTDIR:-$HOME}
  41. export ZDOTDIR="$zdotdir"
  42.  
  43. # }}}
  44.  
  45. [[ -e $zdotdir/.shared_env ]] && . $zdotdir/.shared_env
  46.  
  47. sh_load_status ".zshenv already started before .shared_env"
  48.  
  49. setopt extended_glob
  50.  
  51. sh_load_status "search paths"
  52.  
  53. # {{{ prevent duplicates in path variables
  54.  
  55. # path and manpath are special - "hardcoded" tie with $(MAN)PATH
  56. typeset -U path
  57. typeset -U manpath
  58. export MANPATH
  59.  
  60. typeset -TU LD_LIBRARY_PATH ld_library_path
  61. typeset -TU PERL5LIB perl5lib
  62.  
  63. # }}}
  64. # {{{ Ruby libraries
  65.  
  66. typeset -TU RUBYLIB rubylib
  67. export RUBYLIB
  68. rubylib=(
  69.           ~/lib/[r]uby{/site_ruby,}{/1.*,}{/i?86*,}(N)
  70.           ~/lib/[r]uby(N)
  71.           $rubylib
  72.          )
  73.  
  74. # }}}
  75. # {{{ Python libraries
  76.  
  77. typeset -TU PYTHONPATH pythonpath
  78. export PYTHONPATH
  79. pythonpath=(
  80.           ~/{local/,}lib/[p]ython*{/site-packages,}(N)
  81.           $pythonpath
  82.          )
  83.  
  84. # }}}
  85.  
  86. # {{{ fpath/autoloads
  87.  
  88. sh_load_status "fpath/autoloads"
  89.  
  90. fpath=(
  91.        $zdotdir/{.[z]sh/$ZSH_VERSION/*.zwc,{.[z]sh,[l]ib/zsh}/{functions{,.local,.$HOST},scripts}}(N)
  92.  
  93.        $fpath
  94.  
  95.        # very old versions
  96.        /usr/doc/zsh*/[F]unctions(N)
  97.       )
  98.  
  99. # Autoload shell functions from all directories in $fpath.  Restrict
  100. # functions from $zdotdir/.zsh to ones that have the executable bit
  101. # on.  (The executable bit is not necessary, but gives you an easy way
  102. # to stop the autoloading of a particular shell function).
  103. #
  104. # The ':t' is a history modifier to produce the tail of the file only,
  105. # i.e. dropping the directory path.  The 'x' glob qualifier means
  106. # executable by the owner (which might not be the same as the current
  107. # user).
  108.  
  109. for dirname in $fpath; do
  110.   case "$dirname" in
  111.     $zdotdir/.zsh*) fns=( $dirname/*~*~(-N.x:t) ) ;;
  112.                  *) fns=( $dirname/*~*~(-N.:t)  ) ;;
  113.   esac
  114.   (( $#fns )) && autoload "$fns[@]"
  115. done
  116.  
  117. # }}}
  118.  
  119. # {{{ Specific to hosts
  120.  
  121. run_hooks .zshenv.d
  122.  
  123. # }}}
Advertisement
Add Comment
Please, Sign In to add comment