-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc.tmpl
More file actions
225 lines (187 loc) · 6.47 KB
/
Copy pathdot_zshrc.tmpl
File metadata and controls
225 lines (187 loc) · 6.47 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
# =============================================================================
# ZSH Configuration
# =============================================================================
# -----------------------------------------------------------------------------
# Oh-My-Zsh Configuration
# -----------------------------------------------------------------------------
export ZSH="${HOME}/.oh-my-zsh"
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
direnv
)
source $ZSH/oh-my-zsh.sh
# Catppuccin theme for syntax highlighting
source ~/.zsh/catppuccin_mocha-zsh-syntax-highlighting.zsh
# -----------------------------------------------------------------------------
# Environment Variables
# -----------------------------------------------------------------------------
export LANG="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export VISUAL="nvim"
export EDITOR="nvim"
export XDG_CONFIG_HOME="$HOME/.config"
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
export GPG_TTY=$(tty)
export BUN_INSTALL="$HOME/.bun"
# Default OCX profile (overridable per-directory via direnv .envrc)
{{- if .work }}
export OCX_PROFILE="${OCX_PROFILE:-work-or}"
{{- else }}
export OCX_PROFILE="${OCX_PROFILE:-personal-zen}"
{{- end }}
# Default OMP profile: live env > persisted ~/.omp/active-profile > machine
# default. Overridable per-directory via direnv .envrc; `ompp` (below) switches.
if [[ -z "${OMP_PROFILE:-}" ]]; then
if [[ -r "$HOME/.omp/active-profile" ]]; then
export OMP_PROFILE="$(<"$HOME/.omp/active-profile")"
else
{{- if .work }}
export OMP_PROFILE="{{ .omp.defaults.work }}"
{{- else }}
export OMP_PROFILE="{{ .omp.defaults.personal }}"
{{- end }}
fi
fi
# ompp [name]: print/switch the active omp profile (persists to ~/.omp/active-profile)
ompp() {
local dir="$HOME/.omp/profiles"
if [[ -z "$1" ]]; then
local active="${OMP_PROFILE:-}"
for p in "$dir"/*(/N); do
p="${p:t}"
[[ "$p" == "$active" ]] && print "* $p" || print " $p"
done
return
fi
if [[ ! -d "$dir/$1" ]]; then
print -u2 "omp profile '$1' not found"
return 1
fi
export OMP_PROFILE="$1"
mkdir -p "$HOME/.omp"
print -r -- "$1" > "$HOME/.omp/active-profile"
print "switched to $1"
}
# SSH/GPG configuration
if [[ -n "$SSH_CONNECTION" ]]; then
export PINENTRY_USER_DATA="USE_CURSES=1"
# Fall back to xterm-256color if the remote lacks terminfo for exotic terminals
if ! infocmp "$TERM" &>/dev/null; then
export TERM=xterm-256color
fi
fi
# FZF configuration (Catppuccin Mocha theme)
export FZF_DEFAULT_COMMAND='fd'
export FZF_DEFAULT_OPTS="
--reverse --ansi
--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8
--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc
--color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8"
# -----------------------------------------------------------------------------
# PATH Configuration (deduplicated)
# -----------------------------------------------------------------------------
typeset -U path # Zsh: ensure unique entries
path=(
"$HOME/.local/bin"
"$HOME/bin"
"$BUN_INSTALL/bin"
"$HOME/go/bin"
"$HOME/.yarn/bin"
"$HOME/.cargo/bin"
${path[@]}
)
{{- if eq .chezmoi.os "darwin" }}
path=("/opt/homebrew/bin" ${path[@]})
{{- end }}
export PATH
# -----------------------------------------------------------------------------
# Lazy Loading Helpers
# -----------------------------------------------------------------------------
# Cache shell init scripts for faster startup
# Regenerates cache when the binary is updated
_cached_init() {
local name=$1
local cmd=$2
local cache="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/${name}.zsh"
local bin_path
# Extract binary name (first word of command, or use name)
bin_path=$(command -v "${cmd%% *}" 2>/dev/null)
if [[ ! -f "$cache" ]] || [[ -n "$bin_path" && "$bin_path" -nt "$cache" ]]; then
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/zsh"
eval "$cmd" >"$cache" 2>/dev/null || return 1
fi
source "$cache"
}
eval "$(starship init zsh)"
eval "$(zoxide init zsh --cmd cd)"
eval "$(atuin init zsh)"
# -----------------------------------------------------------------------------
# Tool Initialization (cached for speed)
# -----------------------------------------------------------------------------
# Carapace completions
export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense'
zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m'
_cached_init carapace 'carapace _carapace'
# Optional: ghcup environment
[[ -f "$HOME/.ghcup/env" ]] && source "$HOME/.ghcup/env"
{{- if eq .chezmoi.os "darwin" }}
# Bun completions
[[ -s "$HOME/.bun/_bun" ]] && source "$HOME/.bun/_bun"
{{- end }}
# -----------------------------------------------------------------------------
# Aliases
# -----------------------------------------------------------------------------
# Editor shortcuts
alias zshconfig="nvim ~/.zshrc"
alias vconf="nvim ~/.config/nvim/"
alias nup='nvim --headless "+Lazy! sync" +qa'
# Modern CLI replacements
alias ls='lsd'
alias cat='bat --style=header,grid'
# Git workflow
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'
# Misc
alias yeehaw=zally.sh
# OpenCode via ocx (resolves OCX_PROFILE from env or .envrc override)
alias oc='ocx oc'
{{- if eq .chezmoi.os "darwin" }}
alias bup="brew update && brew upgrade"
{{- end }}
# Profiling helper
alias zsh-time='for i in $(seq 1 5); do /usr/bin/time zsh -i -c exit; done'
# -----------------------------------------------------------------------------
# Functions
# -----------------------------------------------------------------------------
# Elixir test runner with fuzzy matching
function mt() {
if [[ -z "$1" ]]; then
mix test
else
local add_test=""
if rg -q --no-messages "test" -g "test/**/*_test.exs"; then
add_test="lib/**/*_test.exs"
fi
cat -p \
<(find lib test -type f -iname "*$1*_test.exs" -exec rg "test\s" --vimgrep -s {} \; | cut -d':' -f1,2) \
<(rg "(test\s|describe\s).*$1" -g "lib/**/*_test.exs" -g "$add_test" --vimgrep -s | cut -d':' -f1,2) |
xargs mix test
fi
}
# Watch mode for Elixir tests
function mtw() {
fswatch lib test | mix test --listen-on-stdin --stale
}
# IEx shortcuts
function im() {
iex -S mix
}
function imp() {
iex -S mix phx.server
}
eval "$(mise activate zsh)"
export OPENCODE_AGENT_SKILLS_SUPERPOWERS_MODE=true
export PATH="${HOME}/.local/xonsh-env/xbin:$PATH"