-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathzshrc
More file actions
145 lines (115 loc) · 4.53 KB
/
Copy pathzshrc
File metadata and controls
145 lines (115 loc) · 4.53 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
# Zsh configuration
# All settings in a single file with section separators
# ── Environment ────────────────────────────────────────────
# Global environment (moved from zshenv)
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-${HOME}/.config}
export DOTRCDIR=${DOTRCDIR:-$XDG_CONFIG_HOME/dotrc}
# Hardcode to avoid forking `brew` on every startup (Apple Silicon default, Intel fallback)
if [[ -z ${HOMEBREW_PREFIX} ]]; then
[[ -d /opt/homebrew ]] && export HOMEBREW_PREFIX=/opt/homebrew || export HOMEBREW_PREFIX=/usr/local
fi
# Ensure path arrays do not contain duplicates.
typeset -gU path fpath
# Set the list of directories that zsh searches for commands.
# (N) drops missing paths, so no existence checks are needed.
path=(
${HOME}/{,s}bin(N)
${HOME}/.local/{,s}bin(N)
${HOME}/.amp/bin(N)
/opt/{homebrew,local}/{,s}bin(N)
/usr/local/{,s}bin(N)
$path
"${HOME}/Library/Application Support/JetBrains/Toolbox/scripts"(N)
/Applications/Obsidian.app/Contents/MacOS(N)
${HOME}/.lmstudio/bin(N)
)
## ENV
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# ── History ────────────────────────────────────────────────
setopt HIST_IGNORE_ALL_DUPS
# ── Plugins ────────────────────────────────────────────────
# zimfw
ZIM_HOME=${XDG_CONFIG_HOME}/zim
ZIM_CONFIG_FILE=${DOTRCDIR}/zimrc
zstyle ':zim:zim:zim' use 'degit'
## Initialize zimfw (installed via Homebrew)
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZIM_CONFIG_FILE} ]]; then
source ${HOMEBREW_PREFIX}/opt/zimfw/share/zimfw.zsh init
fi
source ${ZIM_HOME}/init.zsh
## zsh-autosuggestions
ZSH_AUTOSUGGEST_MANUAL_REBIND=1
## zsh-syntax-highlighting
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
## zsh-history-substring-search
zmodload -F zsh/terminfo +p:terminfo
# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
for key ('^[[A' '^P' ${terminfo[kcuu1]}) bindkey ${key} history-substring-search-up
for key ('^[[B' '^N' ${terminfo[kcud1]}) bindkey ${key} history-substring-search-down
for key ('k') bindkey -M vicmd ${key} history-substring-search-up
for key ('j') bindkey -M vicmd ${key} history-substring-search-down
unset key
# ── Tools ──────────────────────────────────────────────────
# mise — shims mode: skips the per-prompt hook; version auto-switch is resolved by
# the shims at call time. No [env]/[hooks] in config, so nothing is lost here.
if [[ -x "${HOME}/.local/bin/mise" ]]; then
eval "$("${HOME}/.local/bin/mise" activate --shims zsh)"
fi
# starship
if (( $+commands[starship] )); then
eval "$(starship init zsh)"
fi
# fzf
if (( $+commands[fzf] )); then
source <(fzf --zsh)
fi
# zoxide
if (( $+commands[zoxide] )); then
eval "$(zoxide init zsh)"
fi
# ── Aliases ────────────────────────────────────────────────
# System update function
function update_system() {
brew update --auto-update
brew upgrade --greedy -y
zimfw update && zimfw upgrade
brew cleanup
mise self-update -y && mise up
# gh ext upgrade --all
}
# Benchmark Zsh startup time
function benchmark_zsh() {
${DOTRCDIR}/scripts/benchmark.sh "$@"
}
# Profile Zsh startup (show timing per module)
function profile_zsh() {
${DOTRCDIR}/scripts/profile-startup.zsh
}
# Update alias
alias update=update_system
# Zsh optimization aliases
alias zbench=benchmark_zsh
alias zprofile=profile_zsh
# Homebrew aliases
alias bws="brew search"
alias bwi="brew install"
# Modern CLI tool aliases (guarded so a fresh machine keeps working defaults)
if (( $+commands[eza] )); then
alias ls="eza --icons=auto --group-directories-first --git"
alias ll="eza -l --git --icons=auto"
alias lt="eza -l --tree --icons=auto"
fi
if (( $+commands[bat] )); then
alias cat="bat"
fi
alias vi="vim"
# ── Local ──────────────────────────────────────────────────
# Work-specific config (gitignored)
if [[ -f ${HOME}/.zshrc.work ]]; then
source ${HOME}/.zshrc.work
fi
# 1Password CLI plugins
if [[ -f ${XDG_CONFIG_HOME}/op/plugins.sh ]]; then
source ${XDG_CONFIG_HOME}/op/plugins.sh
fi