-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzshrc
More file actions
executable file
·564 lines (479 loc) · 19.7 KB
/
zshrc
File metadata and controls
executable file
·564 lines (479 loc) · 19.7 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# Source common definitions
__zshrc_main() {
local SH_SOURCE_FILE SH_SOURCE_DIR SH_SOURCE_FILE_ESCAPED
if [ -n "$ZSH_VERSION" ]; then
SH_SOURCE_FILE=${(%):-%x}
elif [[ -n "$BASH_VERSION" ]]; then
SH_SOURCE_FILE=${BASH_SOURCE[0]}
fi
while [[ -L "$SH_SOURCE_FILE" ]]; do
SH_SOURCE_FILE=$(readlink "$SH_SOURCE_FILE")
done
SH_SOURCE_DIR=$(dirname "$SH_SOURCE_FILE")
SH_SOURCE_DIR=$(
cd "$SH_SOURCE_DIR" >/dev/null
pwd
)
SH_SOURCE_FILE=$(basename "$SH_SOURCE_FILE")
SH_SOURCE_FILE_ESCAPED=${SH_SOURCE_FILE// /_}
# SH_SOURCE_DIR is a full path to the location of this script
eval "$(
cat <<EOF
__get_${SH_SOURCE_FILE_ESCAPED}_dir() {
echo $SH_SOURCE_DIR
}
__get_${SH_SOURCE_FILE_ESCAPED}_file() {
echo $SH_SOURCE_FILE
}
__get_sh_scripts_dir() {
echo "$SH_SOURCE_DIR"
}
__get_sh_scripts_file() {
echo "$SH_SOURCE_FILE"
}
EOF
)"
local SH_COLOR_DEFS
if [[ -e "$SH_SOURCE_DIR/configure_colors" ]]; then
SH_COLOR_DEFS=$(cat "$SH_SOURCE_DIR/configure_colors")
fi
local SH_OS_DEFS
if [[ -e "$SH_SOURCE_DIR/configure_os" ]]; then
SH_OS_DEFS=$(cat "$SH_SOURCE_DIR/configure_os")
fi
eval "$(
cat <<EOF
__sh_color_definitions() {
echo "$SH_COLOR_DEFS"
}
__sh_os_definitions() {
echo "$SH_OS_DEFS"
}
EOF
)"
eval "$(__sh_color_definitions)"
eval "$(__sh_os_definitions)"
local SH_INTERACTIVE
case $- in
*i*)
# interactive shell
SH_INTERACTIVE=1
;;
esac
. "${SH_SOURCE_DIR}/shrc_helpers"
# Ghostty terminfo fallback (must be before tmux auto-attach)
if [[ "$TERM" == "xterm-ghostty" ]]; then
if ! infocmp xterm-ghostty >/dev/null 2>&1; then
export TERM=xterm-256color
fi
fi
# Show MOTD on SSH login (Linux; inside tmux the pre-attach output is lost)
if [[ $SH_INTERACTIVE && -n $SSH_CONNECTION && $SH_OS_TYPE == Linux && -f /run/motd.dynamic && -z $MOTD_SHOWN ]]; then
export MOTD_SHOWN=1
cat /run/motd.dynamic
fi
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'Configuring environment for '$COLOR_GREEN_BOLD'Zsh '$COLOR_YELLOW_BOLD${ZSH_VERSION}$COLOR_NONE' on '$COLOR_GREEN_BOLD$SH_OS_DISTRO$COLOR_NONE' '$COLOR_YELLOW_BOLD$SH_OS_RELEASE$COLOR_NONE' ('$COLOR_GREEN_BOLD$SH_OS_TYPE$COLOR_NONE')'
# Homebrew (early, before tmux auto-attach needs it on PATH)
if [[ $SH_OS_TYPE == OSX ]]; then
if [[ -f /opt/homebrew/bin/brew ]]; then
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'Configuring '$COLOR_GREEN_BOLD'Homebrew'$COLOR_NONE
export HOMEBREW_NO_ENV_HINTS=1
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
elif [[ $SH_OS_TYPE == Linux ]]; then
if [[ -f /home/linuxbrew/.linuxbrew/bin/brew ]]; then
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'Configuring '$COLOR_GREEN_BOLD'Linuxbrew'$COLOR_NONE
export HOMEBREW_NO_ENV_HINTS=1
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
fi
local BREW_DIR
BREW_DIR=$(brew --prefix 2>>/dev/null)
if [ -z "$BREW_DIR" ]; then
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e $COLOR_GREEN_BOLD'Homebrew'$COLOR_NONE' not installed'
else
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e $COLOR_GREEN_BOLD'Homebrew'$COLOR_NONE' installed at '$COLOR_YELLOW_BOLD$BREW_DIR$COLOR_NONE
fi
# SSH configuration (must run before tmux auto-attach so the agent
# environment is inherited by the tmux session)
if [[ $SH_OS_TYPE == Windows ]]; then
export SSH_AUTH_SOCK=/tmp/.ssh-socket
ssh-add -l >/dev/null 2>&1
if [[ $? = 2 ]]; then
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'Creating new ssh-agent'
rm -f /tmp/.ssh-script /tmp/.ssh-agent-pid /tmp/.ssh-socket
ssh-agent -a $SSH_AUTH_SOCK > /tmp/.ssh-script
. /tmp/.ssh-script
[[ $SH_INTERACTIVE ]] && echo $SSH_AGENT_PID > /tmp/.ssh-agent-pid
fi
fi
if [[ $SH_OS_TYPE == OSX ]]; then
# Find the launchd-managed SSH agent socket (path changes each boot
# and after sleep/wake, so re-discover even inside tmux)
if [[ -z $SSH_AUTH_SOCK || ! -S $SSH_AUTH_SOCK ]]; then
local _mac_sock
# macOS 26+ moved sockets from /private/tmp to /var/run
_mac_sock=$(find /private/tmp /var/run -path "*/com.apple.launchd.*/Listeners" -user $USER 2>/dev/null | head -1)
if [[ -S "$_mac_sock" ]]; then
export SSH_AUTH_SOCK="$_mac_sock"
fi
fi
fi
if [[ $SH_OS_TYPE == Linux && -z $TMUX ]]; then
# Skip inside tmux; agent env vars are inherited from the pre-tmux shell
local _ssh_sock
_ssh_sock=$(find /tmp/ssh-* -name agent.\* 2>/dev/null | head -1)
if [[ -n "$(pgrep -u $USER ssh-agent)" && -S "$_ssh_sock" ]]; then
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'SSH agent '$COLOR_GREEN_BOLD'running'$COLOR_NONE'. Connecting...'
export SSH_AGENT_PID=$(pgrep -n -u $USER ssh-agent)
export SSH_AUTH_SOCK="$_ssh_sock"
elif [[ $SH_INTERACTIVE ]]; then
# Only kill/restart in interactive shells — non-interactive shells
# (scp, remote git, cron) must not disrupt running agents
echo
echo -e 'SSH agent '$COLOR_YELLOW_BOLD'not running'$COLOR_NONE'. Starting new one...'
pkill -u $USER ssh-agent 2>/dev/null
rm -rf /tmp/ssh-* 2>/dev/null
eval $(ssh-agent -s) >/dev/null
fi
fi
# Auto-attach to tmux on SSH login (before heavy init — tmux spawns a fresh shell).
# TMUX_AUTO_ATTACH=0 disables it.
# TMUX_AUTO_ATTACH_SESSION changes the base session (default: main).
# TMUX_AUTO_ATTACH_MODE=shared|auto|dedicated controls session sharing.
if [[ -n $SSH_CONNECTION && -z $TMUX && $- == *i* && $TMUX_AUTO_ATTACH != 0 ]]; then
if command -v tmux >/dev/null 2>&1; then
TMUX_ATTACH_SESSION=$(__tmux_auto_attach_target_session)
exec tmux new-session -As "$TMUX_ATTACH_SESSION"
fi
fi
# Add keys in all shells (not just interactive) so git commit signing works
# in non-interactive contexts like VS Code's built-in git
ssh-add >/dev/null 2>&1
if [[ -f "${HOME}/.ssh/id_rsa_personal" ]]; then
if [[ `ssh-add -l 2>/dev/null | grep -i id_rsa_personal | wc -l` -lt 1 ]]; then
if [[ $SH_OS_TYPE == OSX ]]; then
ssh-add --apple-use-keychain ${HOME}/.ssh/id_rsa_personal >/dev/null 2>&1
else
ssh-add ${HOME}/.ssh/id_rsa_personal >/dev/null 2>&1
fi
fi
fi
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# Non-interactive shells (scp, remote git commands, cron) only need
# the SSH agent and basic env above — skip the rest to avoid latency
if [[ ! $SH_INTERACTIVE ]]; then
return
fi
# Source additional global, local, and personal definitions
[[ $SH_INTERACTIVE ]] && echo
__include_files "${HOME}/.zshrc.local" "${HOME}/.zshrc_local" "${SH_SOURCE_DIR}/aliases" "${HOME}/.aliases.local" "${HOME}/.aliases_local"
# Set up prompt (matching bashrc style: green-bg user, yellow-bg host, cyan path)
local COLOR_ROOT_INVERT=$COLOR_GREEN_INVERT
if [[ "$(whoami)" == "root" ]]; then
COLOR_ROOT_INVERT=$COLOR_RED_INVERT
fi
# Git branch for prompt
__zsh_git_branch() {
if (( $+functions[__git_ps1] )); then
__git_ps1 '[git %s] '
else
local branch
branch=$(git symbolic-ref --short HEAD 2>/dev/null)
[[ -n "$branch" ]] && printf '[git %s] ' "$branch"
fi
}
setopt PROMPT_SUBST
PROMPT="%{$COLOR_BOLD%}%{$COLOR_ROOT_INVERT%}%n%{$COLOR_NONE%} %{$COLOR_BOLD$COLOR_YELLOW_INVERT%}%m%{$COLOR_NONE%} %{$COLOR_CYAN_BOLD%}%~%{$COLOR_NONE%} %{$COLOR_MAGENTA_BOLD%}\$(__zsh_git_branch)%{$COLOR_NONE%}%# "
setopt histignorealldups sharehistory auto_cd
# Keep history within the shell and save it to ~/.zsh_history:
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.zsh_history
# Color directories
if [[ $SH_OS_TYPE == OSX ]]; then
# Mac OS X settings
export LSCOLORS=GxFxCxDxBxegedabagaced
fi
if [[ $SH_OS_TYPE == Linux ]]; then
# Linux settings
export LS_COLORS='di=01;36'
fi
# Use modern completion system
# Set ZSH_DISABLE_COMPFIX at global scope to ensure it works in nested zsh sessions
export ZSH_DISABLE_COMPFIX=true
autoload -Uz compinit
compinit -u # Use -u flag to skip the insecure directories check
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
# eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:(cd|pushd):*' tag-order local-directories path-directories
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# ITerm2 integration
local ITERM2_INTEGRATION
if [[ $SH_OS_TYPE == OSX ]]; then
ITERM2_INTEGRATION=$HOME/.iterm2_shell_integration.zsh
if [[ -f "$ITERM2_INTEGRATION" ]]; then
[[ $SH_INTERACTIVE ]] && echo -e 'Loading '$COLOR_YELLOW_BOLD$ITERM2_INTEGRATION$COLOR_NONE
. "$ITERM2_INTEGRATION"
fi
fi
# Zsh completion
local ZSH_COMPLETION_INSTALLED
if [[ $SH_OS_TYPE == OSX ]]; then
if [[ -f ${BREW_DIR}/bin/brew ]]; then
if [[ -d ${BREW_DIR}/share/zsh-completions ]]; then
ZSH_COMPLETION_INSTALLED=${BREW_DIR}/share/zsh-completions
[[ $SH_INTERACTIVE ]] && echo -e 'Loading '$COLOR_YELLOW_BOLD$ZSH_COMPLETION_INSTALLED$COLOR_NONE
FPATH=$ZSH_COMPLETION_INSTALLED:$FPATH
# Already called compinit at the top level, just update FPATH
fi
fi
fi
local PATH_DIRS=( "${HOME}/bin" "${HOME}/.local/bin" "${SH_SOURCE_DIR}/scripts" )
if [[ $SH_OS_TYPE == OSX ]]; then
# Mac OS X paths, including Homebrew and MacPorts
PATH_DIRS=( "${PATH_DIRS[@]}" "/usr/local/bin" "/usr/local/sbin" "/opt/local/bin" "/opt/local/sbin" "${BREW_DIR}/bin" )
fi
if [[ $SH_OS_DISTRO == Ubuntu ]]; then
PATH_DIRS=( "${PATH_DIRS[@]}" "/snap/bin" )
fi
__add_to_path "${PATH_DIRS[@]}"
# Affects cd behavior - CDPATH needs to always be set for the cd function in aliases to work properly
__add_to_cd_path "." "${HOME}" "${HOME}/src"
# SSH client
if [[ -n $SSH_CLIENT ]]; then
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'Connected from '$COLOR_YELLOW_BOLD$(get_ssh_client_ip)$COLOR_NONE
if is_tailscale_ssh; then
[[ $SH_INTERACTIVE ]] && echo -e 'Connection via '$COLOR_GREEN_BOLD'Tailscale'$COLOR_NONE
fi
if [[ $SH_INTERACTIVE && $SH_OS_TYPE == OSX ]]; then
echo -e 'Unlocking '$COLOR_CYAN_BOLD'keychain'$COLOR_NONE'...'
security unlock-keychain
fi
fi
# Git completion and prompt
if [[ -n $(which git 2>/dev/null) ]]; then
# Load custom git completions if available
local GIT_COMPLETION
GIT_COMPLETION=$HOME/bin/git-completion.zsh
if [[ -f "$GIT_COMPLETION" ]]; then
[[ $SH_INTERACTIVE ]] && echo -e 'Loading '$COLOR_YELLOW_BOLD$GIT_COMPLETION$COLOR_NONE
. "$GIT_COMPLETION"
fi
# Load git-prompt.sh for __git_ps1 (used in prompt)
if (( ! $+functions[__git_ps1] )); then
if [[ -f /opt/homebrew/etc/bash_completion.d/git-prompt.sh ]]; then
. /opt/homebrew/etc/bash_completion.d/git-prompt.sh
fi
fi
fi
# Misc declarations
if [[ $SH_OS_TYPE == Linux ]]; then
if [[ $SH_OS_DISTRO == Ubuntu ]]; then
if [[ -z $SHELL ]]; then
# Ubuntu does not always define it for some reason
export SHELL=/usr/bin/env zsh
fi
fi
fi
export EDITOR=vim
# WSL X configuration
if [[ $SH_OS_FLAVOR == WSL ]]; then
export GDK_DPI_SCALE=2
fi
# Dev declarations
# Antigravity
if [[ -d $HOME/.antigravity/antigravity/bin ]]; then
__add_to_path "${HOME}/.antigravity/antigravity/bin"
elif [[ $SH_OS_FLAVOR == WSL ]]; then
# On WSL, Antigravity is installed under Windows user's AppData
__WSL_WIN_USER=$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r\n')
if [[ -n "$__WSL_WIN_USER" && -d "/mnt/c/Users/${__WSL_WIN_USER}/AppData/Local/Programs/Antigravity/bin" ]]; then
__add_to_path "/mnt/c/Users/${__WSL_WIN_USER}/AppData/Local/Programs/Antigravity/bin"
fi
unset __WSL_WIN_USER
fi
# Claude
if [[ -d $HOME/.claude/local ]]; then
__add_to_path "${HOME}/.claude/local"
fi
# Android SDK
if [[ -d $HOME/android-sdk ]]; then
export ANDROID_HOME=$HOME/android-sdk
fi
if [[ -d $HOME/Library/Android/sdk ]]; then
export ANDROID_HOME=$HOME/Library/Android/sdk
fi
if [[ -n $ANDROID_HOME ]]; then
__add_to_path "${ANDROID_HOME}/build-tools/$([[ -d "${ANDROID_HOME}/build-tools/" ]] && ls -1 "${ANDROID_HOME}/build-tools/" | tr -d '/' | sort -V | tail -n 1)" "${ANDROID_HOME}/platform-tools" "${ANDROID_HOME}/tools"
fi
if [[ -d $HOME/android-ndk ]]; then
export ANDROID_NDK=$HOME/android-ndk
fi
if [[ -d $ANDROID_HOME/ndk ]]; then
export ANDROID_NDK=$ANDROID_HOME/ndk
fi
if [[ -n $ANDROID_NDK ]]; then
export ANDROID_NDK_REPOSITORY=$ANDROID_NDK
export ANDROID_NDK_ROOT=$ANDROID_NDK
export NDKROOT=$ANDROID_NDK
export NDK_MODULE_PATH=$ANDROID_NDK
__add_to_path "${ANDROID_NDK}/$([[ -d "${ANDROID_NDK}/" ]] && ls -1 "${ANDROID_NDK}/" | tr -d '/' | sort -V | tail -n 1)"
fi
# Node
if [[ -d $HOME/.nvm ]]; then
export NVM_DIR="$HOME/.nvm"
fi
if [[ -d $NVM_DIR ]]; then
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
. "$NVM_DIR/nvm.sh"
fi
if [[ -s "$NVM_DIR/bash_completion" ]]; then
. "$NVM_DIR/bash_completion"
fi
fi
# Bun
if [[ -d $HOME/.bun ]]; then
export BUN_INSTALL="$HOME/.bun"
fi
if [[ -d $BUN_INSTALL ]]; then
[ -s "$BUN_INSTALL/_bun" ] && source "$BUN_INSTALL/_bun"
__add_to_path "${BUN_INSTALL}/bin"
fi
# Ruby
if [[ $SH_OS_TYPE == OSX ]]; then
local SH_BREW_RUBY SH_DEFAULT_GEM_HOME
SH_BREW_RUBY="${BREW_DIR}/opt/ruby/bin/ruby"
if [[ -x $SH_BREW_RUBY ]]; then
__add_to_path "${BREW_DIR}/opt/ruby/bin"
SH_DEFAULT_GEM_HOME=$($SH_BREW_RUBY -e 'require "rubygems"; print Gem.default_dir' 2>/dev/null)
fi
fi
if [[ -z $GEM_HOME ]]; then
if [[ -n $SH_DEFAULT_GEM_HOME && -d $SH_DEFAULT_GEM_HOME ]]; then
export GEM_HOME="$SH_DEFAULT_GEM_HOME"
elif [[ -d $HOME/.gem ]]; then
export GEM_HOME="$HOME/.gem"
elif [[ -d $HOME/gems ]]; then
export GEM_HOME="$HOME/gems"
fi
fi
if [[ -n $GEM_HOME ]]; then
__add_to_path "${GEM_HOME}/bin"
fi
# Go
if [[ $SH_OS_TYPE == OSX ]]; then
if [[ -d $HOME/go ]]; then
export GOPATH=$HOME/go
fi
fi
# Conda
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('$HOME/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then
. "$HOME/miniconda3/etc/profile.d/conda.sh"
else
__add_to_path "${HOME}/miniconda3/bin"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# uv
if [[ -f "$HOME/.local/bin/env" ]]; then
. "$HOME/.local/bin/env"
fi
# Rust
if [[ -f $HOME/.cargo/env ]]; then
. "$HOME/.cargo/env"
fi
# CUDA
if [[ -d /usr/local/cuda/bin ]]; then
__add_to_path "/usr/local/cuda/bin"
fi
# Llama.cpp
if [[ $SH_OS_DISTRO == Ubuntu ]]; then
export GGML_CUDA_ENABLE_UNIFIED_MEMORY=1
elif [[ $SH_OS_TYPE == OSX ]]; then
export OpenMP_ROOT=$BREW_DIR/opt/libomp
fi
# >>> nvwb
# Sourcing the nvwb wrapper function was added during the NVIDIA AI Workbench installation and
# is required for NVIDIA AI Workbench to function properly. When uninstalling
# NVIDIA AI Workbench, it will be removed.
if [[ -f "$HOME/.local/share/nvwb/nvwb-wrapper.sh" ]]; then
source "$HOME/.local/share/nvwb/nvwb-wrapper.sh"
fi
# >>> nvwb
# Local declarations
if [[ -n `whence __zshrc_local_run` ]]; then
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'Executing '$COLOR_YELLOW_BOLD$(__zshrc_local)$COLOR_NONE
__zshrc_local_run "$@"
fi
# Convert CDPATH (colon separated string) to cdpath (array) - zsh requires this conversion
# Unlike bash which just uses CDPATH, zsh needs the cdpath array to be properly set
cdpath=(${(s.:.)CDPATH})
# Global aliases deferred load
if [[ -n `whence __aliases_load` ]]; then
__aliases_load "$@"
fi
# Local aliases deferred load
if [[ -n `whence __aliases_local_load` ]]; then
__aliases_local_load "$@"
fi
# Global dotrc deferred load
# Node
# After local dotrc to ensure we don't pick accidentally local dotrc node version
if [[ -d $NVM_DIR ]]; then
if [[ $(nvm current) == system ]]; then
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'Switching node from '$COLOR_YELLOW_BOLD'system'$COLOR_NONE' to '$COLOR_YELLOW_BOLD'nvm default'$COLOR_NONE
nvm use default
fi
fi
if [[ -n $BREW_DIR && -f $BREW_DIR/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
if [[ -d $BREW_DIR/share/zsh-syntax-highlighting/highlighters ]]; then
export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=$BREW_DIR/share/zsh-syntax-highlighting/highlighters
fi
source $BREW_DIR/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
# Free space
local FREE_SPACE FREE_SPACE_READABLE
FREE_SPACE=`df -k / | tail -n 1 | awk '{printf $4}'`
FREE_SPACE_READABLE=`df -h / | tail -n 1 | awk '{printf $4}' | tr -d i`
FREE_SPACE_READABLE=$COLOR_YELLOW_BOLD$FREE_SPACE_READABLE$COLOR_NONE
if (( $FREE_SPACE <= 5000000 )); then
FREE_SPACE_READABLE=$FREE_SPACE_READABLE' '$COLOR_RED_BOLD'WARNING: Low free disk space!!!'$COLOR_NONE
fi
[[ $SH_INTERACTIVE ]] && echo
[[ $SH_INTERACTIVE ]] && echo -e 'Free space: '$FREE_SPACE_READABLE
[[ $SH_INTERACTIVE ]] && echo
}
__zshrc_main "$@"
unset -f __zshrc_main