zprofile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #
  2. # Executes commands at login pre-zshrc.
  3. #
  4. # Authors:
  5. # Sorin Ionescu <sorin.ionescu@gmail.com>
  6. #
  7. #
  8. # Browser
  9. #
  10. append_to_path() {
  11. if [[ -d "$1" ]]; then
  12. path=(
  13. "$1"
  14. $path
  15. )
  16. # Ensure path array does not contain duplicates.
  17. typeset -gU path
  18. else
  19. return 1
  20. fi
  21. }
  22. if [[ -z "$BROWSER" && "$OSTYPE" == darwin* ]]; then
  23. export BROWSER='open'
  24. fi
  25. #
  26. # Editors
  27. #
  28. export EDITOR="emacsclient -c"
  29. export ALTERNATE_EDITOR=emacs
  30. export VISUAL="emacsclient -c -nw"
  31. export GIT_EDITOR="emacsclient -c"
  32. #
  33. # Language
  34. #
  35. if [[ -z "$LANG" ]]; then
  36. export LANG='en_US.UTF-8'
  37. fi
  38. #
  39. # Paths
  40. #
  41. local_zsh_completions="${XDG_DATA_HOME:-$HOME/.local/share}/.zsh/site-functions"
  42. if [[ -d $local_zsh_completions ]]; then
  43. fpath=($local_zsh_completions $fpath)
  44. fi
  45. # Ensure path arrays do not contain duplicates.
  46. typeset -gU cdpath fpath mailpath path
  47. # Set the list of directories that cd searches.
  48. # cdpath=(
  49. # $cdpath
  50. # )
  51. # Set the list of directories that Zsh searches for programs.
  52. if (( $+commands[luarocks] )); then
  53. eval `luarocks path --bin`
  54. fi
  55. if (( $+commands[go] )); then
  56. [[ -z $GOPATH ]] && [[ -d ~/code/golang ]] && export GOPATH=~/code/golang
  57. append_to_path $GOPATH/bin
  58. fi
  59. append_to_path "${HOME}/.local/bin"
  60. append_to_path "${HOME}/bin"
  61. path=(
  62. $HOME/{,s}bin(N)
  63. /opt/{homebrew,local}/{,s}bin(N)
  64. /usr/local/{,s}bin(N)
  65. $path
  66. )
  67. typeset -gU path
  68. #
  69. # Less
  70. #
  71. # Set the default Less options.
  72. # Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
  73. # Remove -X to enable it.
  74. if [[ -z "$LESS" ]]; then
  75. export LESS='-g -i -M -R -S -w -X -z-4'
  76. fi
  77. # lesspipe potentially harmful
  78. unset LESSPIPE
  79. unset LESSOPEN
  80. unset LESSCLOSE
  81. #
  82. # Temporary Files
  83. #
  84. #
  85. # Set TMPDIR if the variable is not set/empty or the directory doesn't exist
  86. if [[ -z "${TMPDIR}" ]]; then
  87. export TMPDIR="/tmp/zsh-${UID}"
  88. fi
  89. if [[ ! -d "${TMPDIR}" ]]; then
  90. mkdir -m 700 "${TMPDIR}"
  91. fi
  92. TMPPREFIX="${TMPDIR%/}/zsh"
  93. #
  94. # Nix
  95. #
  96. [[ -e "${XDG_STATE_HOME-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh" ]] && . "${XDG_STATE_HOME-$HOME/.local/state}/nix/profile/etc/profile.d/nix.sh"
  97. if [[ -d "${XDG_STATE_HOME-$HOME/.local/state}/nix/profile/share/zsh/site-functions" ]]; then
  98. fpath=(${XDG_STATE_HOME-$HOME/.local/state}/nix/profile/share/zsh/site-functions/ $fpath)
  99. typeset -gU fpath
  100. fi
  101. # Local Variables:
  102. # mode: sh
  103. # End: