-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzshrc
More file actions
181 lines (152 loc) · 5.08 KB
/
zshrc
File metadata and controls
181 lines (152 loc) · 5.08 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
# ==============================
# Shell Prompt Setup
# ==============================
# Ensure core system binaries are always available, even if PATH was inherited in a bad state.
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${PATH}"
# Print system summary before instant prompt to avoid p10k console I/O warnings.
if [[ -o interactive ]] && command -v fastfetch >/dev/null 2>&1; then
fastfetch
fi
# Prompt backend selector.
# Set PROMPT_BACKEND=starship to force Starship.
PROMPT_BACKEND="${PROMPT_BACKEND:-p10k}"
if [[ "$PROMPT_BACKEND" == "p10k" ]]; then
[[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]] && source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
[[ -f ~/.powerlevel10k/powerlevel10k.zsh-theme ]] && source ~/.powerlevel10k/powerlevel10k.zsh-theme
if [[ -f ~/.p10k.zsh ]]; then
source ~/.p10k.zsh
elif [[ -f ~/.dotfiles/p10k.zsh ]]; then
source ~/.dotfiles/p10k.zsh
fi
elif command -v starship >/dev/null 2>&1; then
eval "$(starship init zsh)"
fi
# ==============================
# 🎨 Dircolors (ls colors)
# ==============================
eval "$(dircolors -b ~/.dotfiles/dircolors)"
# ==============================
# 🔹 Load Custom Aliases
# ==============================
[[ -f ~/.aliases ]] && source ~/.aliases
alias icat='kitten icat'
alias icat-clear='kitten icat --clear'
# ==============================
# 🛠 Custom Environment Variables
# ==============================
export HSA_OVERRIDE_GFX_VERSION=10.3.0
export DRUSH_LAUNCHER_FALLBACK="/srv/http/drupal"
export PIP_REQUIRE_VIRTUALENV=false
# ==============================
# 🚀 PATH Configuration
# ==============================
# Keep PATH unique and stable across repeated shell loads.
typeset -U path PATH
export PYENV_ROOT="$HOME/.pyenv"
export RBENV_ROOT="$HOME/.rbenv"
export BUN_INSTALL="$HOME/.bun"
export NVM_DIR="$HOME/.nvm"
path=(
"$HOME/.local/bin"
"$HOME/scripts"
"$HOME/.config/composer/vendor/bin"
"$RBENV_ROOT/bin"
"$PYENV_ROOT/bin"
"$BUN_INSTALL/bin"
$path
)
# Initialize version managers once per shell to avoid duplicate hook setup on re-source.
if [[ -z "${__PYENV_INIT_DONE:-}" ]] && command -v pyenv >/dev/null 2>&1; then
eval "$(pyenv init - zsh)"
__PYENV_INIT_DONE=1
fi
if [[ -z "${__RBENV_INIT_DONE:-}" ]] && command -v rbenv >/dev/null 2>&1; then
eval "$(rbenv init - zsh)"
__RBENV_INIT_DONE=1
fi
# Load NVM during startup when it's installed so a default Node version is available.
if [[ -z "${__NVM_INIT_DONE:-}" ]] && [[ -s "$NVM_DIR/nvm.sh" ]]; then
source "$NVM_DIR/nvm.sh"
[[ -s "$NVM_DIR/bash_completion" ]] && source "$NVM_DIR/bash_completion"
__NVM_INIT_DONE=1
fi
# ==============================
# ⚙️ Zsh Behavior & Input Settings
# ==============================
# Shell history settings
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.zsh_history
# Shell options
setopt correct # Auto-correct minor typos in commands
setopt nocaseglob # Enable case-insensitive globbing
autoload -Uz compinit
zcompdump_file="${XDG_CACHE_HOME:-$HOME/.cache}/zcompdump-$ZSH_VERSION"
zcompdump_mtime="$(stat -c %Y "$zcompdump_file" 2>/dev/null || echo 0)"
# Use cached completions for fast startup; refresh once per day.
if [[ -f "$zcompdump_file" ]] && (( EPOCHSECONDS - zcompdump_mtime < 86400 )); then
compinit -C -d "$zcompdump_file"
else
compinit -d "$zcompdump_file"
fi
# Keybindings (Vi-style editing)
bindkey -v
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
# ==============================
# 🎯 Vi Mode Prompt Indicator
# ==============================
# Keep this lightweight indicator only for Starship.
# p10k has native vi mode support in its own config.
if [[ "$PROMPT_BACKEND" == "starship" ]]; then
: "${ORIGINAL_PROMPT:=$PROMPT}"
function zle-keymap-select {
case $KEYMAP in
vicmd)
PROMPT="%F{green}[NORMAL]%f $ORIGINAL_PROMPT"
;;
main|viins)
PROMPT="%F{blue}[INSERT]%f $ORIGINAL_PROMPT"
;;
esac
zle reset-prompt
}
zle -N zle-keymap-select
fi
[ -f "$HOME/.ghcup/env" ] && . "$HOME/.ghcup/env" # ghcup-env
export EDITOR=nvim
export VISUAL=nvim
export SYSTEMD_EDITOR=nvim
# bun completions
[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# SDKMAN is lazy-loaded on first use to keep startup fast and avoid reload edge cases.
export SDKMAN_DIR="$HOME/.sdkman"
_sdkman_lazy_load() {
if [[ -n "${__SDKMAN_INIT_DONE:-}" ]]; then
return 0
fi
if [[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ]]; then
source "$SDKMAN_DIR/bin/sdkman-init.sh"
__SDKMAN_INIT_DONE=1
return 0
fi
echo "SDKMAN init script not found: $SDKMAN_DIR/bin/sdkman-init.sh" >&2
return 1
}
sdk() {
local -a _sdk_args=("$@")
_sdkman_lazy_load || return 1
if [[ -n "${__SDKMAN_WRAPPER_BYPASS:-}" ]]; then
echo "SDKMAN failed to initialize correctly." >&2
return 1
fi
__SDKMAN_WRAPPER_BYPASS=1
sdk "${_sdk_args[@]}"
local _sdk_rc=$?
unset __SDKMAN_WRAPPER_BYPASS
return $_sdk_rc
}
# opencode
export PATH=$HOME/.opencode/bin:$PATH
export PATH="$HOME/.local/bin:$PATH"