-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc
More file actions
327 lines (275 loc) · 11.1 KB
/
dot_zshrc
File metadata and controls
327 lines (275 loc) · 11.1 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
[[ $- != *i* ]] && return
export PATH="$HOME/.local/share/gem/ruby/3.3.0/bin:$PATH"
export EDITOR='nvim'
export BROWSER='google-chrome-stable'
export HISTORY_IGNORE="(ls|cd|pwd|exit|sudo reboot|history|cd -|cd ..)"
export SUDO_PROMPT="Deploying root access for %u. Password pls: "
export BAT_THEME="base16"
export JAVA_HOME=/usr/lib/jvm/jdk-23.0.2
export PATH=$JAVA_HOME/bin:$PATH
export SD_SERVER_PORT=39999
export WEB_SERVER_PORT=10003
export CONTROLLER_PORT=40000
export CONTROLLER_URL=http://0.0.0.0:$CONTROLLER_PORT
export SD_WORKER_URL=http://0.0.0.0:$SD_SERVER_PORT
if [ -d "$HOME/.local/bin" ] ;
then PATH="$HOME/.local/bin:$PATH"
fi
# ┬ ┌─┐┌─┐┌┬┐ ┌─┐┌┐┌┌─┐┬┌┐┌┌─┐
# │ │ │├─┤ ││ ├┤ ││││ ┬││││├┤
# ┴─┘└─┘┴ ┴─┴┘ └─┘┘└┘└─┘┴┘└┘└─┘
autoload -Uz compinit
# Detect AUR wrapper
if pacman -Qi yay &>/dev/null; then
aurhelper="yay"
elif pacman -Qi paru &>/dev/null; then
aurhelper="paru"
fi
for dump in ~/.config/zsh/zcompdump(N.mh+24); do
compinit -d ~/.config/zsh/zcompdump
done
compinit -C -d ~/.config/zsh/zcompdump
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
precmd () { vcs_info }
_comp_options+=(globdots)
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} 'ma=48;5;197;1'
zstyle ':completion:*' matcher-list \
'm:{a-zA-Z}={A-Za-z}' \
'+r:|[._-]=* r:|=*' \
'+l:|=*'
zstyle ':completion:*:warnings' format "%B%F{red}No matches for:%f %F{magenta}%d%b"
zstyle ':completion:*:descriptions' format '%F{yellow}[-- %d --]%f'
zstyle ':vcs_info:*' formats ' %B%s-[%F{magenta}%f %F{yellow}%b%f]-'
# ┬ ┬┌─┐┬┌┬┐┬┌┐┌┌─┐ ┌┬┐┌─┐┌┬┐┌─┐
# │││├─┤│ │ │││││ ┬ │││ │ │ └─┐
# └┴┘┴ ┴┴ ┴ ┴┘└┘└─┘ ─┴┘└─┘ ┴ └─┘
expand-or-complete-with-dots() {
echo -n "\e[31m…\e[0m"
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
# ┬ ┬┬┌─┐┌┬┐┌─┐┬─┐┬ ┬
# ├─┤│└─┐ │ │ │├┬┘└┬┘
# ┴ ┴┴└─┘ ┴ └─┘┴└─ ┴
HISTFILE=~/.config/zsh/zhistory
HISTSIZE=5000
SAVEHIST=5000
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups
# ┌─┐┌─┐┬ ┬ ┌─┐┌─┐┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
# ┌─┘└─┐├─┤ │ │ ││ ││ │ │├─┘ │ ││ ││││└─┐
# └─┘└─┘┴ ┴ └─┘└─┘└─┘┴─┘ └─┘┴ ┴ ┴└─┘┘└┘└─┘
setopt AUTOCD # change directory just by typing its name
setopt PROMPT_SUBST # enable command substitution in prompt
setopt MENU_COMPLETE # Automatically highlight first element of completion menu
setopt LIST_PACKED # The completion menu takes less space.
setopt AUTO_LIST # Automatically list choices on ambiguous completion.
setopt COMPLETE_IN_WORD # Complete from both ends of a word.
# ┌┬┐┬ ┬┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┌┬┐
# │ ├─┤├┤ ├─┘├┬┘│ ││││├─┘ │
# ┴ ┴ ┴└─┘ ┴ ┴└─└─┘┴ ┴┴ ┴
# In case a command is not found, try to find the package that has it
function command_not_found_handler {
local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m'
printf 'zsh: command not found: %s\n' "$1"
local entries=( ${(f)"$(/usr/bin/pacman -F --machinereadable -- "/usr/bin/$1")"} )
if (( ${#entries[@]} )) ; then
printf "${bright}$1${reset} may be found in the following packages:\n"
local pkg
for entry in "${entries[@]}" ; do
local fields=( ${(0)entry} )
if [[ "$pkg" != "${fields[2]}" ]]; then
printf "${purple}%s/${bright}%s ${green}%s${reset}\n" "${fields[1]}" "${fields[2]}" "${fields[3]}"
fi
printf ' /%s\n' "${fields[4]}"
pkg="${fields[2]}"
done
fi
return 127
}
# Detect AUR wrapper
if pacman -Qi yay &>/dev/null; then
aurhelper="yay"
elif pacman -Qi paru &>/dev/null; then
aurhelper="paru"
fi
function in {
local -a inPkg=("$@")
local -a arch=()
local -a aur=()
for pkg in "${inPkg[@]}"; do
if pacman -Si "${pkg}" &>/dev/null; then
arch+=("${pkg}")
else
aur+=("${pkg}")
fi
done
if [[ ${#arch[@]} -gt 0 ]]; then
sudo pacman -S "${arch[@]}"
fi
if [[ ${#aur[@]} -gt 0 ]]; then
${aurhelper} -S "${aur[@]}"
fi
}
# yazi
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
# the fuck
eval $(thefuck --alias fuck)
# zoxide
eval "$(zoxide init zsh --cmd cd)"
eval "$(starship init zsh)"
# The plugin will auto execute this zvm_after_select_vi_mode function
function zvm_config() {
ZVM_CURSOR_STYLE_ENABLED=true
ZVM_VI_INSERT_ESCAPE_BINDKEY=jk
}
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey '^[[3~' delete-char
# ┌─┐┬ ┬┌─┐┌┐┌┌─┐┌─┐ ┌┬┐┌─┐┬─┐┌┬┐┬┌┐┌┌─┐┬ ┌─┐ ┌┬┐┬┌┬┐┬ ┌─┐
# │ ├─┤├─┤││││ ┬├┤ │ ├┤ ├┬┘│││││││├─┤│ └─┐ │ │ │ │ ├┤
# └─┘┴ ┴┴ ┴┘└┘└─┘└─┘ ┴ └─┘┴└─┴ ┴┴┘└┘┴ ┴┴─┘└─┘ ┴ ┴ ┴ ┴─┘└─┘
function xterm_title_precmd () {
print -Pn -- '\e]2;%n@%m %~\a'
[[ "$TERM" == 'screen'* ]] && print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-}\e\\'
}
function xterm_title_preexec () {
print -Pn -- '\e]2;%n@%m %~ %# ' && print -n -- "${(q)1}\a"
[[ "$TERM" == 'screen'* ]] && { print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-} %# ' && print -n -- "${(q)1}\e\\"; }
}
if [[ "$TERM" == (kitty*|alacritty*|tmux*|screen*|xterm*) ]]; then
add-zsh-hook -Uz precmd xterm_title_precmd
add-zsh-hook -Uz preexec xterm_title_preexec
fi
export FZF_DEFAULT_OPTS=" \
--color=bg+:#ccd0da,bg:#eff1f5,spinner:#dc8a78,hl:#d20f39 \
--color=fg:#4c4f69,header:#d20f39,info:#8839ef,pointer:#dc8a78 \
--color=marker:#7287fd,fg+:#4c4f69,prompt:#8839ef,hl+:#d20f39 \
--color=selected-bg:#bcc0cc \
--multi"
function sesh-sessions() {
{
exec </dev/tty
exec <&1
local session
session=$(sesh list -t -c | fzf --height 40% --reverse --border-label ' sesh ' --border --prompt '⚡ CHOOSE A SESSION ')
zle reset-prompt > /dev/null 2>&1 || true
[[ -z "$session" ]] && return
sesh connect $session
}
}
zle -N sesh-sessions
bindkey -M emacs '\el' sesh-sessions
bindkey -M vicmd '\el' sesh-sessions
bindkey -M viins '\el' sesh-sessions
# ┌─┐┬ ┬┌─┐┌─┐
# ├─┤│ │├─┤└─┐
# ┴ ┴┴─┘┴┴ ┴└─┘
alias mirrors="sudo reflector --verbose --latest 5 --country 'United States' --age 6 --sort rate --save /etc/pacman.d/mirrorlist"
alias update="paru -Syu --nocombinedupgrade"
alias grub-update="sudo grub-mkconfig -o /boot/grub/grub.cfg"
alias music="ncmpcpp"
alias cat="bat --theme=base16"
alias l='eza -lh --icons=always --color=always' # long list
alias ls='eza --icons=always --color=always -h' # short list
alias la='eza --icons=always --color=always -ah'
alias ll='eza -lha --icons=always --color=always --sort=name --group-directories-first' # long list all
alias ld='eza -lhD --icons=always --color=always' # long list dirs
alias lt='eza --icons=always --color=always --tree' # list folder as tree
alias lg='lazygit'
alias dc='docker'
alias pow='chmod +x'
alias off='poweroff'
alias rb='reboot'
alias q='exit'
alias c='clear'
alias cl='clear'
alias v='nvim'
alias vim='nvim'
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'
alias un='$aurhelper -Rns' # uninstall package
alias up='$aurhelper -Syu' # update system/package/aur
alias pl='$aurhelper -Qs' # list installed package
alias pa='$aurhelper -Ss' # list available package
alias pc='$aurhelper -Sc' # remove unused cache
alias po='$aurhelper -Qtdq | $aurhelper -Rns -' # remove unused packages, also try > $aurhelper -Qqd | $aurhelper -Rsu --print -
alias kitty='GLFW_IM_MODULE=ibus kitty'
alias t='tmux'
alias tn='tmux new -s'
alias ta='tmux a'
alias tA='tmux a -t'
alias tk='tmux kill-server'
alias tK='tmux kill-session -t'
alias tl='tmux ls'
alias tf='sesh connect $(sesh list | fzf)'
alias dot='chezmoi'
# ┌─┐┬ ┬┌┬┐┌─┐ ┌─┐┌┬┐┌─┐┬─┐┌┬┐
# ├─┤│ │ │ │ │ └─┐ │ ├─┤├┬┘ │
# ┴ ┴└─┘ ┴ └─┘ └─┘ ┴ ┴ ┴┴└─ ┴
$HOME/.local/bin/colorscript -r
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/tdy/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/tdy/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/tdy/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/tdy/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# ┌─┐┬ ┬ ┬┌─┐┬┌┐┌┌─┐
# ├─┘│ │ ││ ┬││││└─┐
# ┴ ┴─┘└─┘└─┘┴┘└┘└─┘
### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
print -P "%F{33} %F{34}Installation successful.%f%b" || \
print -P "%F{160} The clone has failed.%f%b"
fi
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zdharma-continuum/zinit-annex-as-monitor \
zdharma-continuum/zinit-annex-bin-gem-node \
zdharma-continuum/zinit-annex-patch-dl \
zdharma-continuum/zinit-annex-rust
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-history-substring-search
zinit wait lucid for \
atload"zle -N fzf-history-widget; bindkey -M viins '^R' fzf-history-widget" \
jeffreytse/zsh-vi-mode
zinit light Aloxaf/fzf-tab
### End of Zinit's installer chunk
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh