-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc.tmpl
219 lines (156 loc) · 5.73 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
{{- if .zsh.enabled -}}
###############################################################################
# Environment
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export FZF_DEFAULT_OPTS='--color=16'
{{- if .helix.enabled }}
export EDITOR=hx
export VISUAL=hx
{{- end }}
{{- if .bat.enabled }}
export MANPAGER="sh -c 'col -bx | bat --language man --style=plain'"
{{- end }}
###############################################################################
# zsh4humans (https://github.com/romkatv/zsh4humans/blob/v5/README.md)
# https://github.com/romkatv/zsh4humans/blob/v5/tips.md#prompt
POSTEDIT=$'\n\n\e[2A'
zstyle ':z4h:' auto-update 'no'
zstyle ':z4h:' auto-update-days '28'
zstyle ':z4h:bindkey' keyboard 'mac'
zstyle ':z4h:' start-tmux 'no'
# zstyle ':z4h:' start-tmux command tmux -u new -A -D -t z4h
zstyle ':z4h:' prompt-at-bottom 'no'
zstyle ':z4h:' propagate-cwd yes
zstyle ':z4h:' term-shell-integration 'yes'
zstyle ':z4h:autosuggestions' forward-char 'partial-accept'
zstyle ':z4h:autosuggestions' end-of-line 'partial-accept'
# Instruct zsh4humans to use fzf from PATH.
zstyle ':z4h:*' fzf-command fzf
zstyle ':z4h:fzf-complete' recurse-dirs 'yes'
zstyle ':z4h:*' fzf-flags "${FZF_DEFAULT_OPTS}"
zstyle ':z4h:ssh:*' enable 'no'
{{- if .git.enabled }}
zstyle ':z4h:direnv' enable 'yes'
{{- end }}
###############################################################################
# Clone git repositories using `z4h install`
{{- if .git.enabled }}
z4h install zimfw/git
{{- end }}
###############################################################################
# Initialize zsh4humans. Console/Network I/O is unavailable after this.
z4h init || return
###############################################################################
# Customizations
# Set shell options: http://zsh.sourceforge.net/Doc/Release/Options.html.
setopt no_auto_menu # require an extra TAB press to open the completion menu
setopt no_auto_cd # don't cd without cd
# Extend PATH.
path=(
~/.local/bin
{{- if .lang.cpp }}
${HOMEBREW_PREFIX}/opt/llvm/bin
{{- end }}
{{- if .lang.rust }}
~/.cargo/bin
{{- end }}
$path
)
{{- if .lang.cpp }}
export CC=clang
export CXX=clang++
export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/llvm/lib/c++ -L${HOMEBREW_PREFIX}/opt/llvm/lib -lunwind"
export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/llvm/include"
{{- end }}
{{- if .lang.dotnet }}
export DOTNET_ROOT="${HOMEBREW_PREFIX}/opt/dotnet/libexec"
{{- end }}
# Source additional local files if they exist.
z4h source --compile ~/.bashrc
z4h source --compile ~/.private.zsh
# Define key bindings.
z4h bindkey z4h-cd-back Shift+Left # cd into the previous directory
z4h bindkey z4h-cd-forward Shift+Right # cd into the next directory
z4h bindkey z4h-cd-up Shift+Up # cd into the parent directory
z4h bindkey z4h-cd-down Shift+Down # cd into a child directory
# Always accept line on enter
z4h bindkey z4h-accept-line Enter
# Autoload functions.
autoload -Uz zmv
# Define functions and completions.
function md() { [[ $# == 1 ]] && mkdir -p -- "$1" && cd -- "$1" }
compdef _directories md
###############################################################################
# Aliases
# Basics
{{- if .bat.enabled }}
alias c='bat --style=plain'
alias b='bat --style=default'
{{- else }}
alias c='cat'
{{- end }}
alias e='${EDITOR}'
alias o='open'
alias q='exit'
{{- if .qalc.enabled }}
alias :calc=qalc
{{- end }}
# System upgrade
alias :sup='chezmoi update --init --apply --refresh-externals && brew upgrade {{- if .lang.rust }} && rustup update {{- end }} && z4h update'
# chezmoi
alias :ha='chezmoi add'
alias :hA='chezmoi add --template'
alias :hc='cd "$(chezmoi source-path)"'
alias :hd='chezmoi diff --init'
alias :he='chezmoi edit --init --apply'
alias :hs='chezmoi edit-config'
alias :hS='chezmoi cat-config'
alias :hm='chezmoi merge'
alias :hp='chezmoi apply --init'
alias :hu='chezmoi update --init'
alias :hU='chezmoi update --init --refresh-externals'
{{- if .git.enabled }}
gprefix=':g'
zstyle ':zim:git' aliases-prefix "${gprefix}"
z4h load --compile zimfw/git
# difftastic
alias ${gprefix}wdp="${aliases[${gprefix}wd]/ --no-ext-diff/} --no-ext-diff"
alias ${gprefix}wd="${aliases[${gprefix}wd]/ --no-ext-diff/} --ext-diff"
alias ${gprefix}csp="${aliases[${gprefix}cs]/ --no-ext-diff/} --no-ext-diff"
alias ${gprefix}cs="${aliases[${gprefix}cs]/ --no-ext-diff/} --ext-diff"
alias ${gprefix}idp="${aliases[${gprefix}id]/ --no-ext-diff/} --no-ext-diff"
alias ${gprefix}id="${aliases[${gprefix}id]/ --no-ext-diff/} --ext-diff"
alias ${gprefix}ldp="${aliases[${gprefix}ld]/ --no-ext-diff/} --no-ext-diff"
alias ${gprefix}ld="${aliases[${gprefix}ld]/ --no-ext-diff/} --ext-diff"
alias ${gprefix}sdp="${aliases[${gprefix}sd]/ --no-ext-diff/} --no-ext-diff"
alias ${gprefix}sd="${aliases[${gprefix}sd]/ --no-ext-diff/} --ext-diff"
export DFT_DISPLAY=side-by-side-show-both
# https://www.youtube.com/watch?v=aolI_Rz0ZqY
alias "${gprefix}??"="git blame -wCCC"
unset gprefix
{{- end }}
{{- if .eza.enabled }}
alias ls=eza
# tree excluding gitignored paths
alias :t='eza --tree --git-ignore'
alias :ta='eza --tree --git-ignore --all'
# tree including gitignored paths but excluding .git
alias :tg='eza --tree --ignore-glob .git'
alias :tga='eza --tree --all --ignore-glob .git'
# tree including gitignored paths and .git
alias :tG='eza --tree'
alias :tGa='eza --tree --all'
{{- end }}
{{- if .mpv.enabled }}
function :mpv {
mpv "${@}" </dev/null &>/dev/null & disown
}
function :ytdl {
yt-dlp --downloader aria2c "${@}"
}
function :yt {
:ytdl "${@}" --exec "mpv %(filepath,_filename|)q </dev/null &>/dev/null & disown"
}
{{- end }}
{{- end }}