-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzshrc
More file actions
224 lines (170 loc) · 6.17 KB
/
zshrc
File metadata and controls
224 lines (170 loc) · 6.17 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
#
# Simple, clean Zsh config with:
# - Minimal prompt: just a colored ">" and a space
# - Built-in command prediction (no external plugins)
# - Nice completion and history behavior
#
##### Basics #####
export EDITOR="nano"
setopt NO_BEEP
setopt AUTO_MENU # automatically show completion menu when pressing Tab repeatedly
setopt AUTO_LIST # show list of choices on ambiguous completion
setopt COMPLETE_IN_WORD
setopt INTERACTIVE_COMMENTS
# Quality-of-life options
setopt AUTO_CD # "cd" into a directory by just typing its name
setopt AUTO_PUSHD # maintain a directory stack when changing dirs
setopt PUSHD_IGNORE_DUPS # don't store the same directory multiple times
setopt EXTENDED_GLOB # more powerful filename matching (e.g. ^pattern)
##### History #####
HISTFILE=~/.zsh_history
HISTSIZE=5000
SAVEHIST=5000
setopt SHARE_HISTORY
setopt INC_APPEND_HISTORY # write each command to history immediately
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_REDUCE_BLANKS
##### Completion system #####
autoload -Uz compinit
compinit
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'r:|[._-]=* r:|=*'
##### Colors #####
autoload -Uz colors
colors
##### Optional plugins #####
for plugin_file in \
/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh \
/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh \
/opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh \
/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
do
if [ -f "$plugin_file" ]; then
source "$plugin_file"
break
fi
done
for plugin_file in \
/usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh \
/usr/share/zsh-history-substring-search/zsh-history-substring-search.zsh \
/opt/homebrew/share/zsh-history-substring-search/zsh-history-substring-search.zsh \
/usr/local/share/zsh-history-substring-search/zsh-history-substring-search.zsh
do
if [ -f "$plugin_file" ]; then
source "$plugin_file"
break
fi
done
##### Prompt (only "> " and nothing else) #####
setopt PROMPT_SUBST
# Just a colored "❯" and a space, no directory/user/host
PROMPT='%F{#8B4100}❯%f '
##### Command prediction (built-in zsh/predict) #####
if zmodload -i zsh/predict 2>/dev/null; then
autoload -Uz predict-on predict-off
# Turn prediction on by default
predict-on
# Optional: toggle prediction with Ctrl-P if you ever want to
bindkey '^P' predict-toggle
fi
##### Useful keybindings #####
bindkey -e # Emacs-style keybindings
# Up/Down search history by the prefix you've typed
if typeset -f history-substring-search-up >/dev/null 2>&1; then
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
else
bindkey '^[[A' history-beginning-search-backward
bindkey '^[[B' history-beginning-search-forward
fi
##### Aliases & helpers #####
# Navigation
alias ..='cd ..'
alias ...='cd ../..'
mkcd() { mkdir -p "$1" && cd "$1"; }
# Clearing
alias c='clear'
alias clr='clear'
# Git shortcuts
alias gs='git status -sb'
alias gl='git log --oneline --graph --decorate'
alias ga='git add'
alias gc='git commit'
alias gco='git checkout'
alias gp='git push'
alias ginit='git init'
# Open remote repo in browser at current branch
if command -v open >/dev/null 2>&1; then
alias gop='open "$(git remote get-url origin | sed -e "s|git@\(.*\):\(.*\)\.git|https://\1/\2|" -e "s|\.git$||")/tree/$(git rev-parse --abbrev-ref HEAD)"'
elif command -v xdg-open >/dev/null 2>&1; then
alias gop='xdg-open "$(git remote get-url origin | sed -e "s|git@\(.*\):\(.*\)\.git|https://\1/\2|" -e "s|\.git$||")/tree/$(git rev-parse --abbrev-ref HEAD)" >/dev/null 2>&1'
fi
# ESP-IDF
if [ -f "$HOME/esp/esp-idf/export.sh" ]; then
alias get_idf='. "$HOME/esp/esp-idf/export.sh"'
fi
# Vivado
alias vivado-env='[ -n "${VIVADO_ROOT:-}" ] && [ -f "$VIVADO_ROOT/settings64.sh" ] && . "$VIVADO_ROOT/settings64.sh"'
# Always open VS Code in the next Hyprland workspace.
code() {
if [ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ] && command -v hyprctl >/dev/null 2>&1; then
local current_ws target_ws
if command -v jq >/dev/null 2>&1; then
current_ws="$(hyprctl -j activeworkspace 2>/dev/null | jq -r '.id // empty' 2>/dev/null)"
if [[ "$current_ws" == <-> ]] && (( current_ws > 0 )); then
target_ws=$((current_ws + 1))
fi
fi
if [[ "$target_ws" == <-> ]] && (( target_ws > 0 )); then
hyprctl dispatch workspace "$target_ws" >/dev/null 2>&1 || true
else
hyprctl dispatch workspace r+1 >/dev/null 2>&1 || true
fi
fi
command code --new-window "$@"
}
##### Colored ls / lsd #####
# Keep macOS ls colors available as a fallback
export CLICOLOR=1
export LSCOLORS=ExFxBxDxExbxbxabababab
export LS_COLORS='no=38;2;192;202;245:fi=38;2;192;202;245:di=38;2;122;162;247:ln=38;2;187;154;247:pi=38;2;125;207;255:so=38;2;125;207;255:bd=38;2;224;175;104:cd=38;2;224;175;104:or=38;2;247;118;142:mi=38;2;247;118;142:ex=38;2;158;206;106:tw=38;2;158;206;106:ow=38;2;158;206;106:st=38;2;158;206;106:'
# Prefer lsd (modern ls) if installed, otherwise fall back to classic ls.
unalias ls 2>/dev/null
unfunction ls 2>/dev/null
if command -v lsd >/dev/null 2>&1; then
alias ls='lsd'
alias ll='lsd -alF'
alias la='lsd -a'
else
alias ls='ls -FGx'
alias ll='ls -FGhl'
alias la='ls -FGhla'
fi
# rbenv (Homebrew)
if command -v rbenv >/dev/null 2>&1; then
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
fi
if [ -f "$HOME/.local/bin/env" ]; then
. "$HOME/.local/bin/env"
fi
export PATH="$HOME/.cargo/bin:$PATH"
if command -v brew >/dev/null 2>&1; then
export SSL_CERT_FILE="$(brew --prefix)/etc/ca-certificates/cert.pem"
fi
# >>> juliaup initialize >>>
# !! Contents within this block are managed by juliaup !!
path=("$HOME/.juliaup/bin" $path)
export PATH
# <<< juliaup initialize <<<
# opencode
export PATH="$HOME/.opencode/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
alias btop="btop --force-utf"
if command -v ruby >/dev/null 2>&1; then
export PATH="$(ruby -r rubygems -e 'print Gem.user_dir')/bin:$PATH"
else
print -u2 "ruby is not installed; install ruby to enable gem bin PATH setup"
fi
alias get_idf='. /home/lazybanana/esp/esp-idf/export.sh'