-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzshrc
More file actions
207 lines (132 loc) · 4.15 KB
/
zshrc
File metadata and controls
207 lines (132 loc) · 4.15 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Start Profiling
export PROFILING_MODE=0
if [ $PROFILING_MODE -ne 0 ]; then
zmodload zsh/zprof
zsh_start_time=$(gdate +%s%3N)
fi
# Compile zsh file, and source them. Initial run is slower.
zsource() {
local file=$1
# Skip zcompile for non-regular files (e.g. process substitution /dev/fd/...)
if [[ ! -f "$file" || "$file" == /dev/* || "$file" == /proc/* ]]; then
source "$file"
return
fi
local zwc="${file}.zwc"
if [[ ! -f "$zwc" || "$file" -nt "$zwc" ]]; then
zcompile "$file"
fi
source "$file"
}
## ZSH Options
unsetopt correct_all
# Required for prompt command substitution — normally set by OMZ lib/theme-and-appearance.zsh
setopt prompt_subst
# Skip OMZ's compinit — we run it ourselves later
skip_global_compinit=1
## Environment
PATH=/usr/local/bin:/usr/local/sbin:$HOME/.bin:$PATH
## Completion (must run before plugins that call compdef)
autoload -Uz compinit
ZSH_COMPDUMP="$HOME/.zcompdump"
compinit -C -d "$ZSH_COMPDUMP"
## Antidote ZSH Plugin Manager (static loading)
# Pre-set $ZSH so use-omz skips its `antidote path ohmyzsh/ohmyzsh` subprocess call
export ZSH="$HOME/Library/Caches/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-ohmyzsh-SLASH-ohmyzsh"
# Only source antidote when the static plugin file needs regenerating
if [[ ! -f ~/.zsh_plugins.zsh || ~/.zsh_plugins.txt -nt ~/.zsh_plugins.zsh ]]; then
source /opt/homebrew/opt/antidote/share/antidote/antidote.zsh
antidote bundle < ~/.zsh_plugins.txt > ~/.zsh_plugins.zsh
fi
zsource ~/.zsh_plugins.zsh
# GPG agent — local replacement for ohmyzsh/ohmyzsh path:plugins/gpg-agent.
# The OMZ version runs `gpgconf --list-options gpg-agent` on every shell start (~45ms).
# Our version skips that subprocess since enable-ssh-support is not enabled.
zsource $HOME/.dotfiles/zsh/gpg-agent.zsh
## FZF ctrl+r (cached)
FZF_CACHE="$HOME/.fzf-init.zsh"
if [[ ! -f "$FZF_CACHE" ]]; then
fzf --zsh > "$FZF_CACHE"
fi
zsource "$FZF_CACHE"
## Text Editor
export EDITOR=nvim
## Aliases
zsource $HOME/.dotfiles/zsh/aliases
## Functions
# Show contents of directory after cd-ing into it
chpwd() {
ls -la
}
## Tooling
# FNM - Fast Node Manager - (https://github.com/Schniz/fnm)
FNM_PATH="$HOME/.fnm"
if [ -d "$FNM_PATH" ]; then
export PATH="$HOME/.fnm:$PATH"
eval "`fnm env`"
fi
# Run this once, then comment out
# fnm completions --shell=zsh > ~/.config/zsh/completions/_fnm
fpath+=~/.config/zsh/completions/_fnm
autoload -U add-zsh-hook
# place default node version under $HOME/.node-version
load-nvmrc() {
DEFAULT_NODE_VERSION="22"
if [[ -f .nvmrc && -r .nvmrc ]] || [[ -f .node-version && -r .node-version ]]; then
fnm use --silent-if-unchanged
else
fnm use $DEFAULT_NODE_VERSION --silent-if-unchanged
fi
}
add-zsh-hook chpwd load-nvmrc
# Only run load-nvmrc at startup if we're actually in a project directory;
# otherwise the chpwd hook will handle it on first cd.
if [[ -f .nvmrc || -f .node-version ]]; then
load-nvmrc
fi
# Python
export PATH=$PATH:$HOME/.local/bin
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
# Android Studio
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
# bun
[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# Rustup
. "$HOME/.cargo/env"
# Go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$HOME/.local/bin:$PATH
# Yarn Switch
# source "~/.yarn/switch/env"
# pyenv
#
# Initial setup:
#
# ln -sf "$PYENV_ROOT/shims/python" ~/.local/bin/python
# ln -sf "$PYENV_ROOT/shims/pip" ~/.local/bin/pip
# ln -sf "$PYENV_ROOT/shims/python3" ~/.local/bin/python3
# ln -sf "$PYENV_ROOT/shims/pip3" ~/.local/bin/pip3
export PYENV_ROOT="$HOME/.pyenv"
pyenv() {
unset -f pyenv
eval "$(command pyenv init --path)"
eval "$(command pyenv init -)"
pyenv "$@"
}
# NX
export NX_TUI=false
# Secrets
source ~/.secrets
# End Profiling
if [ $PROFILING_MODE -ne 0 ]; then
zsh_end_time=$(gdate +%s%3N)
zprof
echo "Shell init time: $((zsh_end_time - zsh_start_time)) ms"
fi