/
zshrc
332 lines (275 loc) · 10.2 KB
/
zshrc
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
326
327
328
329
330
331
332
#!/usr/bin/env zsh
# zmodload zsh/zprof
# setopt xtrace
# shellcheck disable=SC2168,2296
# CodeWhisperer pre block. Keep at the top of this file.
[[ -f "${HOME}/Library/Application Support/codewhisperer/shell/zshrc.pre.zsh" ]] && builtin source "${HOME}/Library/Application Support/codewhisperer/shell/zshrc.pre.zsh"
unset CI
# shellcheck disable=2298
__zshrc_filename=${${(%):-%N}:A}
__zshrc_dirname=${__zshrc_filename:h}
# TODO: separate out all os-specific code so that we only run the platform
# detection code on zgen reset
source "${__zshrc_dirname}/scripts/detect-platform.zsh"
# shellcheck disable=SC1090
sourceIfExists() { [[ -e "$1" ]] && source "$1"; }
$IS_LINUXY && sourceIfExists /etc/profile.d/vte.sh
if $IS_OSX ; then
if [ -x /usr/libexec/path_helper ]; then
eval "$(/usr/libexec/path_helper -s)"
fi
if [[ -x /opt/homebrew/bin/brew ]]; then
HOMEBREW_PREFIX="/opt/homebrew"
elif [[ -x /usr/local/opt/bin/brew ]]; then
HOMEBREW_PREFIX="/usr/local/opt"
fi
if [[ -n "$HOMEBREW_PREFIX" ]]; then
path=(
$HOMEBREW_PREFIX/bin
$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin
$HOMEBREW_PREFIX/opt/gnu-sed/libexec/gnubin
$path
)
fpath[${fpath[(i)$HOMEBREW_PREFIX/share/zsh/site-functions]}]=()
fpath=($fpath $HOMEBREW_PREFIX/share/zsh/site-functions)
fi
fi
if ! type realpath >/dev/null ; then
realpath() { readlink -f "$@"; }
fi
if $IS_LINUXY ; then
# https://wiki.archlinux.org/index.php/SSH_keys#Start_ssh-agent_with_systemd_user
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
fi
# core shell settings
# export SHELL=$(whence $(ps wwwe -p $$ -o comm=)) # broken on m1 mac
# export SHELL=zsh
export EDITOR=hx
export VISUAL="wait-code"
export LC_ALL="en_CA.UTF-8"
export HISTTIMEFORMAT=": %F %T:0;"
export HISTFILESIZE=
export HISTSIZE=
HISTSIZE=50000; SAVEHIST=10000
HISTFILE=~/.zsh_history
tabs -2
# bindkey -M emacs "^\`" _complete_help
zmodload -i zsh/complist
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
$IS_INTERACTIVE && export HISTFILE=$HOME/.zsh_history_interactive
APPEND_HISTORY=true; setopt appendhistory; setopt histfcntllock; setopt nohistsavebycopy
# Bun
if [[ -x ~/.bun/bin/bun ]]; then
export BUN_INSTALL=~/.bun
path=("$BUN_INSTALL/bin" $path)
fi
# zgen settings
ZGEN_AUTOLOAD_COMPINIT=0
# omz settings
DISABLE_AUTO_UPDATE=true
HYPHEN_INSENSITIVE=true
# COMPLETION_WAITING_DOTS=true
DISABLE_AUTO_TITLE=false
# ZSH_PYENV_QUIET=true
# ENABLE_CORRECTION=true
# export BAT_PAGER="less +X -x2 -FR"
export LESS='-SRiF' # --mouse --wheel-lines=1 # scroll wheel used to freeze iterm2
export BAT_PAGER="moar --no-linenumbers"
export BAT_LIGHT_THEME=base16-tomorrow
export DELTA_LIGHT_THEME=base16-tomorrow
export MOAR="--statusbar=bold --no-linenumbers"
export RIPGREP_CONFIG_PATH="${__zshrc_dirname}/config/ripgreprc"
__FZF_BASE_COMMAND="fd --hidden --follow --exclude '.git' --exclude 'node_modules' --exclude '.marks' --exclude \$(realpath --relative-to=. $HOME/Library)"
export FZF_DEFAULT_COMMAND="$__FZF_BASE_COMMAND --type f"
export FZF_ALT_C_COMMAND="$__FZF_BASE_COMMAND --type d"
# zsh-nvm settings
export NVM_COMPLETION=true
export NVM_LAZY_LOAD=true
sourceIfExists "${__zshrc_dirname}/plugins/nvm/cache"
export DIRENV_WARN_TIMEOUT=1m
# TODO: use https://github.com/Schniz/fnm instead?
export TSC_NONPOLLING_WATCHER=true
export WATCHMAN_CONFIG_FILE="${__zshrc_dirname}/config/watchman.json"
# zsh settings
setopt no_extended_glob # breaks `git show HEAD^`
setopt bareglobqual
# zsh highlighting settings
zle_highlight+=(paste:none)
zstyle ':bracketed-paste-magic' active-widgets '.self-*'
# fuzzy completion
zstyle ':completion:*' completer _prefix _expand_alias _complete _correct _approximate
zstyle ':completion:*:correct:::' max-errors 2 not-numeric
zstyle ':completion:*' matcher-list 'r:|?=**'
zstyle ':completion:*:approximate:::' max-errors 2 numeric
zstyle ':completion:*:complete:*:*:*' matcher-list '' 'm:{a-z}={A-Z}'
zstyle ':completion:*' accept-exact-dirs true
zstyle ':completion:*' list-suffixes true
# zstyle ':autocomplete:list-choices:*' max-lines 40%
zstyle ':autocomplete:list-choices:*' max-lines 24
zstyle ':autocomplete:tab:*' completion select
# pure prompt settings
PURE_HIGHLIGHT_REPO=1
PURE_PROMPT_SYMBOL="%B»%b"
PURE_GIT_UNTRACKED_DIRTY=0
zstyle :prompt:pure:git:stash show yes
# $prompt_pure_git_stash
zstyle ':completion:*' rehash true
# local git plugin settings
export UNTRACKED_FILES_STORAGE="$HOME/code/.old-untracked-files"
path=(
~/.local/bin
~/.cargo/bin
$path
~/.zgen/deliciousinsights/git-stree-master
)
unset sourceIfExists
autoload -Uz bashcompinit && bashcompinit
autoload -Uz compinit && compinit -i
zstyle ':completion:*:warnings' format '%F{yellow}%d%f'
# https://gist.github.com/ctechols/ca1035271ad134841284
# shellcheck disable=SC1036,SC1088
DO_COMPDUMP=false
() {
setopt extendedglob local_options
if [[ -n ${ZDOTDIR:-$HOME}/.zcompdump(#qN.mh+24) ]]; then
compinit
DO_COMPDUMP=true
else
# echo nocache
compinit -C
fi
}
source "$__zshrc_dirname/zgen/zgenom.zsh"
alias zgen=zgenom
if ! zgen saved; then
zgen load zsh-users/zsh-syntax-highlighting
zgen load zsh-users/zsh-autosuggestions
# zgen load marlonrichert/zsh-autocomplete
$IS_OSX && zgen load "$__zshrc_dirname/plugins/brew"
zgen ohmyzsh
zgen ohmyzsh plugins/web-search
# zgen ohmyzsh plugins/command-not-found # very slow
$IS_OSX && zgen ohmyzsh plugins/brew
zgen ohmyzsh plugins/colorize
zgen ohmyzsh plugins/cp
zgen ohmyzsh plugins/git-extras
zgen ohmyzsh plugins/docker
zgen ohmyzsh plugins/docker-compose
# zgen ohmyzsh plugins/npm
[[ -d $CLOUDSDK_HOME ]] && zgen ohmyzsh plugins/gcloud
zgen ohmyzsh plugins/rbenv
zgen load "$__zshrc_dirname/plugins/python"
zgen ohmyzsh plugins/python
# zgen ohmyzsh plugins/pyenv
whence kubectl > /dev/null && zgen ohmyzsh plugins/kubectl
# zgen ohmyzsh plugins/jump
zgen load srijanshetty/zsh-pandoc-completion /
zgen load "$__zshrc_dirname/plugins/jump"
# zgen ohmyzsh encode64
! $IS_WINDOWS && zgen load mafredri/zsh-async / main
# ! $IS_WINDOWS && zgen load sindresorhus/pure
! $IS_WINDOWS && zgen load forivall/pure / underline-repo-name
$IS_WINDOWS && zgen load forivall/pure / underline-repo-name-no-async
zgen load zsh-users/zsh-completions src
zgen load zsh-users/zsh-history-substring-search
# zgen load deliciousinsights/git-stree
! $IS_WINDOWS && zgen load forivall/zsh-nvm
zgen load "$__zshrc_dirname/plugins/nvm"
zgenom load unixorn/fzf-zsh-plugin
# zgen load forivall/zsh-yarn-autocompletions / main
$IS_OSX && zgen load nilsonholger/osx-zsh-completions
# zgen load jocelynmallon/zshimarks
zgen load "$__zshrc_dirname/plugins/functional"
$IS_WINDOWS && zgen load "$__zshrc_dirname/plugins/cygwin-functions"
$IS_WINDOWS && zgen load "$__zshrc_dirname/plugins/cygwin-sudo"
$IS_OSX && zgen load "$__zshrc_dirname/plugins/iterm2"
zgen load "$__zshrc_dirname/plugins/oneliner"
zgen load "$__zshrc_dirname/plugins/external-tools"
zgen load "$__zshrc_dirname/plugins/dimensions-in-title"
zgen load "$__zshrc_dirname/plugins/rust"
zgen load "$__zshrc_dirname/plugins/ruby"
zgen load "$__zshrc_dirname/plugins/coreutils"
zgen load "$__zshrc_dirname/plugins/git"
zgen load "$__zshrc_dirname/plugins/git-ftp"
zgen load "$__zshrc_dirname/plugins/github"
zgen load "$__zshrc_dirname/plugins/go"
whence lab > /dev/null && zgen load "$__zshrc_dirname/plugins/lab"
whence glab > /dev/null && zgen load "$__zshrc_dirname/plugins/glab"
zgen load jscutlery/nx-completion / main
# zgen load forivall/nx-completion / update
zgen load "$__zshrc_dirname/plugins/magic-cd"
zgen load "$__zshrc_dirname/plugins/ngrok"
zgen load "$__zshrc_dirname/plugins/npm"
zgen load "$__zshrc_dirname/plugins/pnpm"
whence twilio > /dev/null && zgen load "$__zshrc_dirname/plugins/twilio"
zgen load "$__zshrc_dirname/plugins/wttr"
zgen load "$__zshrc_dirname/plugins/yarn"
zgen load "$__zshrc_dirname/plugins/yargs"
zgen load "$__zshrc_dirname/plugins/yargs"
# zgen load "$__zshrc_dirname/plugins/subl"
zgen load "$__zshrc_dirname/plugins/trash"
zgen load "$__zshrc_dirname/plugins/unsorted"
zgen load "$__zshrc_dirname/plugins/simple-history-search"
zgen load "$__zshrc_dirname/plugins/zgen-zplug"
# zgen load "$__zshrc_dirname/plugins/zgen-autoupdate" # TODO: figure out why this is slooooow!
[[ -d "$HOME/.opam" ]] && zgen load "$HOME/.opam/opam-init"
$IS_OSX && zgen load nilsonholger/osx-zsh-completions
zgen load gentslava/zsh-better-npm-completion
zgen load g-plane/zsh-yarn-autocompletions
zgen load g-plane/pnpm-shell-completion
whence direnv > /dev/null && zgen ohmyzsh plugins/direnv && zgen load "$__zshrc_dirname/plugins/direnv"
# zgen load dim-an/cod
# zgen load forivall/cod / feat/zsh-local-build
zgen load "$__zshrc_dirname/plugins/local"
# Build completions files
local ofpath=(${fpath})
fpath=(${(q)ZGEN_COMPLETIONS[@]} ${fpath})
for func in ${(kM)functions:#*__build_completions} ; do
echo "Running $func..." >&2
$func
done
fpath=(${ofpath})
zgen-zplug-before-save
zgen save
zgen-zplug-after-save
fi
[[ $(whence -w 9 2>/dev/null) == '9: alias' ]] && unalias 9
unsetopt nomatch
# from ohmyzsh web-search. github is from github desktop.
[[ $(whence -w github 2>/dev/null) == 'github: alias' ]] && unalias github
# TODO: move to a vscode plugin
if [[ "$VSCODE_CLI" == 1 ]] ; then
AMD_ENTRYPOINT=
ELECTRON_NO_ASAR=
ELECTRON_NO_ATTACH_CONSOLE=
ELECTRON_RUN_AS_NODE=
GOOGLE_API_KEY=
PIPE_LOGGING=
VERBOSE_LOGGING=
VSCODE_CLI=
VSCODE_HANDLES_UNCAUGHT_ERRORS=
VSCODE_IPC_HOOK=
VSCODE_IPC_HOOK_EXTHOST=
VSCODE_LOG_STACK=
VSCODE_NLS_CONFIG=
VSCODE_PID=
VSCODE_WINDOW_ID=
fi
if [[ "$TERM_PROGRAM" != "vscode" ]] ; then
unset VSCODE_CWD
fi
clean-env
if $DO_COMPDUMP; then
compdump
fi
unset DO_COMPDUMP
# zstyle ':completion:*:warnings' format '%F{yellow}%d%f'
# zprof
# dont override my variables, ya arse.
FIG_DOTFILES_SOURCED=1
# CodeWhisperer post block. Keep at the bottom of this file.
[[ -f "${HOME}/Library/Application Support/codewhisperer/shell/zshrc.post.zsh" ]] && builtin source "${HOME}/Library/Application Support/codewhisperer/shell/zshrc.post.zsh"
true