-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
317 lines (277 loc) · 9.9 KB
/
dot_zshrc.tmpl
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
### 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
### End of Zinit's installer chunk
# PATH
export PATH=$HOME/bin:$PATH # Home bin Path
export PATH=/usr/local/bin:$PATH # User local Path
export PATH=$HOME/.local/bin:$PATH # Home .local Path
export PATH=$HOME/scripts:$PATH # Home custom scripts Path
export PATH=$HOME/.nimble/bin:$PATH # Nimble (Nim Package Manager) Path
export PATH=/usr/local/go/bin:$PATH # Go user Local Path
export PATH=$HOME/go/bin:$PATH # Go local path
export PATH=/usr/local/zig:$PATH # Zig user Local Path
export PATH=/usr/local/musl/bin:$PATH # Musl user Local Path
export PATH=$HOME/.emacs.d/bin:$PATH # Emacs local path
export PATH=$HOME/.cargo/bin:$PATH # Rust local path
# ~/.tmux/plugins
export PATH=$HOME/.tmux/plugins/t-smart-tmux-session-manager/bin:$PATH
# ~/.config/tmux/plugins
export PATH=$HOME/.config/tmux/plugins/t-smart-tmux-session-manager/bin:$PATH
{{- if eq .chezmoi.os "darwin" }}
export PATH=/opt/homebrew/bin/:$PATH # Mac homebrew path
export PATH=/usr/local/bin/:$PATH # Mac usr bin path
export PATH=/Applications/Visual\ Studio\ Code\ -\ Insiders.app/Contents/Resources/app/bin:$PATH # Mac vscode
{{- end}}
{{- if eq .chezmoi.os "linux" }}
export PATH=/var/lib/flatpak/exports/bin:$PATH # Flatpak path
export PATH=$HOME/.local/share/flatpak/exports/bin:$PATH # Flatpak path user
{{- end}}
export PATH=$HOME/progs/:$PATH # Misc Progs
# Zsh settings
# History Settings
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory
# Env Variables
# lesspipe
LESSOPEN="|lesspipe.sh %s"; export LESSOPEN
lessc () {/usr/share/vim/vim90/macros/less.sh "$@"}
EDITOR="nvim"; export EDITOR
# Theme
PURE_PROMPT_SYMBOL=
PURE_PROMPT_VICMD_SYMBOL=
zinit ice pick'async.zsh' src'pure.zsh'
zinit light sindresorhus/pure
# Completions
autoload -Uz compinit && compinit
# Programs
{{- if eq .chezmoi.os "darwin" }}
zinit lucid light-mode from"gh-r" as"command" bpick'*darwin*' for \
{{- else if eq .chezmoi.os "linux" }}
zinit lucid light-mode from"gh-r" as"command" bpick'*x86_64*linux*' for \
{{- end}}
atload'
eval "$(zoxide init --cmd cd zsh)"
alias z="__zoxide_z"
' pick'zoxide/zoxide' \
@ajeetdsouza/zoxide \
mv'ripgrep* -> rg' pick'rg/rg' \
@BurntSushi/ripgrep \
mv'fd* -> fd' pick'fd/fd' \
@sharkdp/fd \
mv'bat* -> bat' pick'bat/bat' atload'
export MANPAGER="bat --plain"
' \
@sharkdp/bat \
mv'delta* -> delta' pick'delta/delta' \
@dandavison/delta \
{{if eq .chezmoi.os "darwin" }}
zinit lucid light-mode from"gh-r" as"command" bpick'*darwin*arm64*' for \
{{- else if eq .chezmoi.os "linux" }}
zinit lucid light-mode from"gh-r" as"command" bpick'*linux*amd64*' for \
{{- end}}
@junegunn/fzf \
mv'direnv* -> direnv' pick'direnv/direnv' \
@direnv/direnv \
# Scripts
zinit lucid light-mode for \
id-as"fzf-tmux" sbin"./bin/fzf-tmux" junegunn/fzf \
# Rust
zinit lucid light-mode as"command" for \
id-as"eza" \
atclone'cargo install eza' \
atpull'cargo install eza' \
atload'alias ls="eza"' \
@zdharma-continuum/null \
id-as"oxi" \
atclone'cargo install oxi && $HOME/.local/share/nvim/lazy/nvim-spectre/build.sh nvim-oxi' \
atpull'cargo install oxi && $HOME/.local/share/nvim/lazy/nvim-spectre/build.sh nvim-oxi' \
@zdharma-continuum/null \
# Go
zinit lucid light-mode for \
atclone'
go build -o target/sesh
' atpull'
%atclone
' sbin'target/sesh' \
@joshmedeski/sesh \
setopt promptsubst
zinit lucid for \
atinit"
export ZSH_TMUX_FIXTERM=false
export ZSH_TMUX_AUTOSTART=true
export ZSH_TMUX_AUTOCONNECT=true
export ZSH_TMUX_DEFAULT_SESSION_NAME='</>'
" \
OMZP::tmux \
atinit"HIST_STAMPS=dd.mm.yyyy" \
OMZL::history.zsh \
zinit wait lucid for \
OMZL::clipboard.zsh \
OMZL::compfix.zsh \
OMZL::completion.zsh \
OMZL::correction.zsh \
atload'
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
function take() {
mkdir -p $@ && cd ${@:$#}
}
alias rm="rm -rf"
' \
OMZL::directories.zsh \
OMZL::git.zsh \
OMZL::grep.zsh \
OMZL::key-bindings.zsh \
OMZL::spectrum.zsh \
OMZL::functions.zsh \
OMZL::termsupport.zsh \
atload"
alias gcd='git checkout dev'
alias gce='git commit -a -e'
" \
OMZP::git \
https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh \
https://github.com/junegunn/fzf/blob/master/shell/completion.zsh \
zinit wait lucid for \
light-mode blockf atpull'zinit creinstall -q .' \
atinit"
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' menu select=2
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*:descriptions' format '-- %d --'
zstyle ':completion:*:processes' command 'ps -au$USER'
zstyle ':completion:complete:*:options' sort false
zstyle ':fzf-tab:complete:_zlua:*' query-string input
zstyle ':completion:*:*:*:*:processes' command 'ps -u $USER -o pid,user,comm,cmd -w -w'
zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap
zstyle ':fzf-tab:complete:cd:*' extra-opts --preview=$extract'exa -1 --color=always ${~ctxt[hpre]}$in'
" \
zsh-users/zsh-completions \
light-mode atinit"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20" atload"_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions \
light-mode atinit"
typeset -gA FAST_HIGHLIGHT;
FAST_HIGHLIGHT[git-cmsg-len]=100;
zpcompinit;
zpcdreplay;
" \
zdharma-continuum/fast-syntax-highlighting \
reset \
atclone"local P=${${(M)OSTYPE:#*darwin*}:+g}
\${P}sed -i \
'/DIR/c\DIR 38;5;63;1' LS_COLORS; \
\${P}dircolors -b LS_COLORS > c.zsh" \
atpull'%atclone' pick"c.zsh" nocompile'!' \
atload'zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS}”' \
trapd00r/LS_COLORS
# Aliases
tsa() {
# Run the tmux session script if it exists
if [[ -z "$TMUX_SESSION_SCRIPT" ]]; then
echo "TMUX_SESSION_SCRIPT is not set"
else
"$TMUX_SESSION_SCRIPT"
fi
}
ns() {
tmux has-session -t $1 &> /dev/null
if [ $? -ne 0 ]; then
tmux new -s $1 -d
fi
tmux switchc -t $1
}
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
{{- if or (eq .chezmoi.os "darwin") (eq .chezmoi.osRelease.id "fedora") }}
alias cat="bat"
{{- else if or (eq .chezmoi.osRelease.id "ubuntu") (eq .chezmoi.osRelease.id "pop-os") (eq .chezmoi.osRelease.id "debian") }}
alias cat="batcat"
{{- end }}
{{- if eq .chezmoi.osRelease.id "fedora" }}
alias open='xdg-open'
{{- end }}
alias lg="lazygit"
alias v="nvim"
alias ranger=". ranger"
alias fzh='print -z -- $(cat ~/.zsh_history | fzf)'
alias "docker compose"="docker-compose"
alias "docker-compose"="docker compose"
connect_sesh() {
sesh connect $(
sesh list -tz | fzf-tmux -p 55%,60% \
--no-sort --border-label ' sesh ' --prompt '⚡ ' \
--header ' ^a all ^t tmux ^x zoxide ^f find' \
--bind 'tab:down,btab:up' \
--bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list)' \
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t)' \
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z)' \
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)'
) || true
}
{{- if eq .chezmoi.os "darwin" }}
source {{ .chezmoi.homeDir }}/.config/op/plugins.sh
{{- end}}
{{- if eq .chezmoi.os "darwin" }}
# pnpm
export PNPM_HOME="{{ .chezmoi.homeDir }}/Library/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
{{- else if eq .chezmoi.os "linux" }}
# pnpm
export PNPM_HOME="{{ .chezmoi.homeDir }}/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
{{- end}}
# bun completions
[ -s "{{ .chezmoi.homeDir }}/.bun/_bun" ] && source "{{ .chezmoi.homeDir }}/.bun/_bun"
{{- if not (eq .chezmoi.os "darwin") }}
# 1password completion
eval "$(op completion zsh)"; compdef _op op
{{- end}}
{{- if eq .chezmoi.os "darwin" }}
bindkey '\e[1;9D' backward-word # Alt/Option + Left Arrow
bindkey '\e[1;9C' forward-word # Alt/Option + Right Arrow
# Navigate to the beginning or end of the line
bindkey '\e[1;5D' beginning-of-line # Cmd + Left Arrow
bindkey '\e[1;5C' end-of-line # Cmd + Right Arrow
{{- end}}
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
eval "$(direnv hook zsh)"
{{- if not (eq .chezmoi.os "darwin") }}
. "{{ .chezmoi.homeDir }}/.deno/env"
{{- end}}