-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzshrc
More file actions
184 lines (156 loc) · 6.09 KB
/
zshrc
File metadata and controls
184 lines (156 loc) · 6.09 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
# =============================================================================
# Environment Variables
# =============================================================================
export LANG=en_US.UTF-8
export EDITOR=nvim
export XDG_CONFIG_HOME="$HOME/.config"
export RIPGREP_CONFIG_PATH=~/.ripgreprc
export HOMEBREW_NO_AUTO_UPDATE=1
# Load secrets (API keys, etc.) from a separate file that is not committed
if [[ -f "$HOME/.zsh_secrets" ]]; then
source "$HOME/.zsh_secrets"
fi
# =============================================================================
# Path Configuration
# =============================================================================
# Only add paths if they exist
path_append() {
for dir in "$@"; do
[[ -d "$dir" ]] || continue
# Remove existing occurrence and append
PATH="${PATH//:$dir:/:}"
PATH="${PATH#$dir:}"
PATH="${PATH%:$dir}"
export PATH="$PATH:$dir"
done
}
path_prepend() {
for dir in "$@"; do
[[ -d "$dir" ]] || continue
# Remove existing occurrence and prepend
PATH="${PATH//:$dir:/:}"
PATH="${PATH#$dir:}"
PATH="${PATH%:$dir}"
export PATH="$dir:$PATH"
done
}
path_prepend "/opt/homebrew/bin" "/opt/homebrew/sbin" "$HOME/.local/bin" "$HOME/.cargo/bin" "/opt/homebrew/opt/llvm/bin"
path_append "/usr/local/bin" "/usr/local/sbin"
# LLVM Configuration
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
export CMAKE_PREFIX_PATH="/opt/homebrew/opt/llvm"
# =============================================================================
# Version Managers
# =============================================================================
eval "$(fnm env)"
# =============================================================================
# Zsh Performance & Behavior
# =============================================================================
# History
HISTFILE="$HOME/.zsh_history"
HISTSIZE=100000
SAVEHIST=100000
setopt HIST_IGNORE_ALL_DUPS # Store only one copy of each command
setopt HIST_SAVE_NO_DUPS # Don't save duplicates to disk
setopt HIST_REDUCE_BLANKS # Remove extra blanks from history
setopt INC_APPEND_HISTORY # Write to history file immediately
setopt SHARE_HISTORY # Share history across sessions
# Completion
setopt MENU_COMPLETE # Press Tab twice to cycle
setopt AUTO_LIST # Automatically list choices
setopt COMPLETE_IN_WORD # Allow completion from middle of word
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case-insensitive completion
# Speed
zmodload zsh/terminfo
zmodload zsh/datetime
setopt AUTO_CD # cd by typing folder name
setopt INTERACTIVE_COMMENTS # Allow comments in CLI
# =============================================================================
# Oh My Zsh & Plugins
# =============================================================================
export ZSH="$HOME/.oh-my-zsh"
# Performance: Only load plugins we actually need
# zsh-defer handles the heavy ones (autosuggestions, syntax-highlighting)
plugins=(
colored-man-pages
copyfile
copypath
extract
eza
fnm
fzf
git
git-commit
history-substring-search
starship
z
)
source $ZSH/oh-my-zsh.sh
# =============================================================================
# FZF Configuration (The Game Changer)
# =============================================================================
# Use fd instead of find for speed and respect .gitignore
export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d --strip-cwd-prefix --hidden --follow --exclude .git'
# Visual previews for files and directories
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border --color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8,fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc,marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8"
export FZF_CTRL_T_OPTS="--preview 'bat --style=numbers --color=always --line-range :500 {}'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
# Advanced FZF functions
# 'fe' to open files in nvim with fuzzy find
fe() {
local files
files=$(fzf --query="$1" --multi --select-1 --exit-0)
[[ -n "$files" ]] && ${EDITOR:-nvim} "${(f)files[@]}"
}
# --- Zsh Defer (Lazy Loading for Instant Startup) ---
source ~/xsh/zsh-defer/zsh-defer.plugin.zsh
# Defer these to make terminal startup near-instant
zsh-defer source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
zsh-defer source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# Bindings for history-substring-search
zsh-defer bindkey '^[[A' history-substring-search-up
zsh-defer bindkey '^[[B' history-substring-search-down
# Completion init
function zsh-completions-init() {
if [[ -d "/opt/homebrew/share/zsh-completions" ]]; then
FPATH="/opt/homebrew/share/zsh-completions:$FPATH"
autoload -Uz compinit && compinit -i
fi
}
zsh-defer zsh-completions-init
# =============================================================================
# Aliases
# =============================================================================
alias vi="nvim"
alias vim="nvim"
alias ls="eza --icons --group-directories-first"
alias l="eza -lh --icons --group-directories-first"
alias la="eza -lah --icons --group-directories-first"
alias cat="bat --style=plain --paging=never"
alias lg="lazygit"
alias g="git"
alias ..="cd .."
alias ...="cd ../.."
source ~/xsh/git-auto-perf.zsh
# --- Cursor Fix ---
# Force cursor to be a blinking block everywhere
# This fixes the issue where the cursor reverts to a bar in Zsh
_fix_cursor() {
printf '\033[1 q'
}
precmd_functions+=(_fix_cursor)
zle-line-init() {
_fix_cursor
}
zle -N zle-line-init
zle-keymap-select() {
_fix_cursor
}
zle -N zle-keymap-select
export PATH="/Applications/Antigravity.app/Contents/Resources/app/bin:$PATH"
alias agy='antigravity'
export SDKMAN_DIR=$(brew --prefix sdkman-cli)/libexec
[[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh"