-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
215 lines (172 loc) · 6.72 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
# Documentation: https://github.com/romkatv/zsh4humans/blob/v5/README.md.
# Periodic auto-update on Zsh startup: 'ask' or 'no'.
# You can manually run `z4h update` to update everything.
zstyle ':z4h:' auto-update 'no'
# Ask whether to auto-update this often; has no effect if auto-update is 'no'.
zstyle ':z4h:' auto-update-days '28'
# Keyboard type: 'mac' or 'pc'.
zstyle ':z4h:bindkey' keyboard {{ if eq .chezmoi.os "darwin" }} 'mac' {{ else }} 'pc' {{ end }}
# Whether to move prompt to the bottom when zsh starts and on Ctrl+L.
zstyle ':z4h:' prompt-at-bottom 'no'
# Mark up shell's output with semantic information.
zstyle ':z4h:' term-shell-integration 'yes'
# Right-arrow key accepts one character ('partial-accept') from
# command autosuggestions or the whole thing ('accept')?
zstyle ':z4h:autosuggestions' forward-char 'accept'
# Recursively traverse directories when TAB-completing files.
zstyle ':z4h:fzf-complete' recurse-dirs 'no'
# Tab in fzf will accept the selection and immediately open fzf once again
# if the current word isn't fully specified yet.
# zstyle ':z4h:fzf-complete' fzf-bindings tab:repeat
# Enable ('yes') or disable ('no') automatic teleportation of z4h over
# SSH when connecting to these hosts.
# zstyle ':z4h:ssh:example-hostname1' enable 'yes'
# zstyle ':z4h:ssh:*.example-hostname2' enable 'no'
# The default value if none of the overrides above match the hostname.
zstyle ':z4h:ssh:*' enable 'no'
# Send these files over to the remote host when connecting over SSH to the
# enabled hosts.
zstyle ':z4h:ssh:*' send-extra-files '~/.nanorc' '~/.env.zsh'
# Clone additional Git repositories from GitHub.
#
# This doesn't do anything apart from cloning the repository and keeping it
# up-to-date. Cloned files can be used after `z4h init`. This is just an
# example. If you don't plan to use Oh My Zsh, delete this line.
z4h install ohmyzsh/ohmyzsh || return
# Install or update core components (fzf, zsh-autosuggestions, etc.) and
# initialize Zsh. After this point console I/O is unavailable until Zsh
# is fully initialized. Everything that requires user interaction or can
# perform network I/O must be done above. Everything else is best done below.
z4h init || return
# MAILCHECK=0
# Export environment variables.
{{ if eq .chezmoi.os "darwin" -}}
export HOMEBREW_PREFIX="$(brew --prefix)"
export HOMEBREW_NO_ANALYTICS="1"
export HOMEBREW_AUTOREMOVE="1"
export HOMEBREW_NO_ENV_HINTS="1"
export HOMEBREW_BAT="1"
export MAMBA_EXE="$HOMEBREW_PREFIX/bin/micromamba";
export PNPM_HOME="$HOME/Library/pnpm"
export MAMBA_ROOT_PREFIX="$HOME/.micromamba"
export XDG_CONFIG_HOME="$HOME/.config"
export LDFLAGS="-L$HOMEBREW_PREFIX/opt/llvm/lib"
export CPPFLAGS="-I$HOMEBREW_PREFIX/opt/llvm/include"
export CMAKE_CXX_COMPILER_LAUNCHER="ccache"
export DYLD_INSERT_LIBRARIES="$HOMEBREW_PREFIX/opt/mimalloc/lib/libmimalloc.dylib"
{{ else -}}
export MAMBA_EXE="$HOME/.local/bin/micromamba"
export PNPM_HOME="$HOME/.local/share/pnpm"
{{ end -}}
export GPG_TTY=$TTY
export LANG="en_US.UTF-8"
export EDITOR="nvim"
export SUDO_EDITOR="$EDITOR"
export BAT_THEME="Catppuccin-mocha"
export BATDIFF_USE_DELTA=true
export BOB_CONFIG="$XDG_CONFIG_HOME/bob/config.json"
# Extend PATH.
{{ if eq .chezmoi.os "darwin" -}}
path=($HOMEBREW_PREFIX/opt/llvm/bin $HOMEBREW_PREFIX/opt/ccache/libexec $HOMEBREW_PREFIX/opt/python/libexec/bin $PNPM_HOME $HOME/.deno/bin $HOMEBREW_PREFIX/bin $HOME/.local/share/bob/nvim-bin $path)
{{ else -}}
path=($PNPM_HOME $HOME/.deno/bin /opt/cuda/bin $HOME/.local/bin $path)
{{ end -}}
fpath+=~/.zfunc
# Source additional local files if they exist.
# z4h source ~/.env.zsh
z4h source ~/.keys
{{ if eq .chezmoi.hostname "workBook" }}
z4h source ~/code/work/everdocs/scripts/tools.sh
{{ end -}}
cmd_exists() {
command -v "$@" >/dev/null 2>&1
}
function zz() {
if cmd_exists tmux; then
tmux -u new -A -D -t main
else
echo "tmux not installed"
fi
}
__mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
if [ -f "$HOME/.micromamba/etc/profile.d/micromamba.sh" ]; then
. "$HOME/.micromamba/etc/profile.d/micromamba.sh"
else
export PATH="$HOME/.micromamba/bin:$PATH"
fi
fi
unset __mamba_setup
# Use additional Git repositories pulled in with `z4h install`.
#
# This is just an example that you should delete. It does nothing useful.
# z4h source ohmyzsh/ohmyzsh/lib/diagnostics.zsh # source an individual file
z4h load ohmyzsh/ohmyzsh/plugins/git
z4h load ohmyzsh/ohmyzsh/plugins/zoxide
# Define key bindings.
z4h bindkey undo Ctrl+/ Shift+Tab # undo the last command line change
z4h bindkey redo Option+/ # redo the last undone command line change
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
{{ if eq .chezmoi.os "darwin" -}}
# https://stackoverflow.com/a/29403520
bindkey "^U" backward-kill-line
bindkey "^X\\x7f" backward-kill-line
bindkey "^X^_" redo
{{ end -}}
# Autoload functions.
autoload -Uz zmv
# Define aliases.
{{ if eq .chezmoi.os "darwin" -}}
alias b='brew'
alias up='brew upgrade'
alias bi='brew info'
alias bs='brew search'
alias bb='brew install'
alias bu='brew uninstall'
alias bl='brew list'
alias df='df -h'
alias network='networksetup -listallhardwareports'
alias checksum='shasum'
alias ssdcheck='smartctl -a disk0'
alias speedtest='speedtest --secure'
alias sudoedit='function _sudoedit(){sudo -e "$1";};_sudoedit'
{{ else if eq .chezmoi.os "linux" -}}
if cmd_exists xclip; then
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
elif cmd_exists xsel; then
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
fi
{{ end -}}
if cmd_exists zoxide; then
alias cd='z'
fi
if cmd_exists pnpm; then
alias np='pnpm'
[[ -f ~/.config/tabtab/zsh/__tabtab.zsh ]] && . ~/.config/tabtab/zsh/__tabtab.zsh || true
fi
alias 7x='7z x'
alias lg='lazygit'
alias src='exec zsh'
alias cm='chezmoi'
alias edit='chezmoi edit --apply'
alias mm='micromamba'
alias fz="fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'"
if cmd_exists lsd; then
alias l='lsd'
alias ll='lsd -l'
alias la='lsd -a'
alias lla='lsd -la'
alias lt='lsd --tree'
fi
# Add flags to existing aliases.
alias ls="${aliases[ls]:-ls} -A"
# Set shell options: http://zsh.sourceforge.net/Doc/Release/Options.html.
setopt glob_dots # no special treatment for file names with a leading dot
setopt no_auto_menu # require an extra TAB press to open the completion menu