-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zprofile
More file actions
67 lines (56 loc) · 2.5 KB
/
dot_zprofile
File metadata and controls
67 lines (56 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# While typically zsh recommends storing environment variables such as `PATH` in
# `.zshenv`, in MacOS, `/etc/zprofile` calls the `path_helper` utility to set
# the `PATH`. Hence, it is necessary to set `PATH` in a zsh configuration file
# that is sourced after `/etc/zprofile`, often `.zshrc` (interactive) or
# `.zprofile` (login).
#
# x-man-page://path_helper
# https://github.com/apple-oss-distributions/shell_cmds/blob/main/path_helper/path_helper.8
# https://zsh.sourceforge.io/Doc/Release/Files.html -- Startup/Shutdown Files
OS="$(uname -s)"
# Default Homebrew installation paths for macOS and Linux
# https://docs.brew.sh/FAQ#why-should-i-install-homebrew-in-the-default-location
if [[ "${OS}" == "Darwin" ]]; then
if [[ "${CPUTYPE}" == "arm64" ]]; then
HOMEBREW_PREFIX="/opt/homebrew"
elif [[ "${CPUTYPE}" == "x86_64" ]]; then
HOMEBREW_PREFIX="/usr/local"
fi
elif [[ "${OS}" == "Linux" ]]; then
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
fi
source <("${HOMEBREW_PREFIX}/bin/brew" shellenv)
source <(nodenv init -)
source <(pyenv init -)
brew nodenv-sync
brew pyenv-sync
# https://specifications.freedesktop.org/basedir-spec/latest/#variables
export XDG_CACHE_HOME="${HOME}/.cache"
export XDG_CONFIG_HOME="${HOME}/.config"
export XDG_DATA_HOME="${HOME}/.local/share"
export XDG_STATE_HOME="${HOME}/.local/state"
# Setting `PATH` variable in zsh with `$path` array
# https://zsh.sourceforge.io/Guide/zshguide02.html#l24
# Remove duplicate entries in `$path` and `$fpath`
typeset -U path fpath
path=(
"${HOME}/.local/bin" # User-specific executable files may be stored in "${HOME}/.local/bin"
"${path[@]}"
)
fpath=(
"${XDG_CONFIG_HOME}/oh-my-zsh/functions" # Custom functions
"${HOMEBREW_PREFIX}/share/zsh-completions" # `zsh-completions`
"${fpath[@]}"
)
# Autoload custom functions using `ksh`-style function definitions
# https://zsh.sourceforge.io/Doc/Release/Functions.html#index-autoloading-functions
# https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html#index-autoload
autoload -Uk "${XDG_CONFIG_HOME}/oh-my-zsh/functions/"*
# Manually set some environment variables to XDG Base Directory Specification
export COREPACK_HOME="${XDG_CACHE_HOME}/node/corepack"
export NODE_REPL_HISTORY="${XDG_DATA_HOME}/node_repl_history"
export NPM_CONFIG_USERCONFIG="${XDG_CONFIG_HOME}/npm/npmrc"
export PYTHON_HISTORY="${XDG_STATE_HOME}/python/history"
export PYTHONPYCACHEPREFIX="${XDG_CACHE_HOME}/python"
export PYTHONUSERBASE="${XDG_DATA_HOME}/python"
export WGETRC="${XDG_CONFIG_HOME}/wget/wgetrc"