-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzshrc
More file actions
100 lines (81 loc) · 2.95 KB
/
Copy pathzshrc
File metadata and controls
100 lines (81 loc) · 2.95 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
source ~/.aliases
# Auto-source all sourced_* dotfiles
# (local/ is for non-shell configs like gitconfig — consumed by their own tools)
for f in ~/.sourced_*; do
[[ -f "$f" ]] && source "$f"
done
# Homebrew (ensures brew-installed tools like fzf work in non-login shells/tmux)
if [[ -x "/opt/homebrew/bin/brew" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# fzf config + helpers loaded via ~/.sourced_* auto-source above
export PATH="$HOME/.local/bin:$PATH"
# zsh history
export HISTFILESIZE=1000000000
export HISTSIZE=1000000000
export HISTFILE=~/.zsh_history
setopt HIST_FIND_NO_DUPS
setopt INC_APPEND_HISTORY # following should be turned off, if sharing history via setopt SHARE_HISTORY
setopt EXTENDED_HISTORY
setopt HIST_IGNORE_ALL_DUPS
# gpg
export GPG_TTY=$(tty)
# OpenSSL
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
# NPM
export PATH=~/.npm-global/bin:$PATH
# NVM
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/shims:$PATH"
export PATH="$PYENV_ROOT/bin:$PATH"
# eval "$(pyenv init -)"
# Poetry
export PATH="$HOME/.poetry/bin:$PATH"
# Heroku: autocomplete
HEROKU_AC_ZSH_SETUP_PATH=/Users/ng/Library/Caches/heroku/autocomplete/zsh_setup && test -f $HEROKU_AC_ZSH_SETUP_PATH && source $HEROKU_AC_ZSH_SETUP_PATH;
## Show Git branch
## Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
## Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '%b'
## Set up the prompt (with git branch name)
setopt PROMPT_SUBST
PROMPT='%(?.%F{green}.%F{red})%n%f@%T: %F{blue}%1~%F{green}[${vcs_info_msg_0_}]%f$ '
# pnpm
export PNPM_HOME="$HOME/.pnpm-global"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
# Configure direnv
eval "$(direnv hook zsh)"
# Auto-switch Node version on cd when a .nvmrc is present (nvm deeper-shell-integration).
# Placed last so nvm's PATH entry wins over Homebrew node / other prepends above.
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
nvm use
fi
elif [ "$(nvm version)" != "$(nvm version default)" ]; then
# No .nvmrc here — fall back to the nvm default (so every shell uses it, not just project dirs)
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc