-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
414 lines (348 loc) · 16.9 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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# Time load time with this command: time zsh -i -c exit
[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'
OS="$(uname 2> /dev/null)"
export PATH="$HOME/bin:/usr/local/bin:$HOME/.local/bin:$PATH"
# =========================================================================================
### 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
# Plugins
# =========================================================================================
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
#zinit light-mode for \
# zinit-zsh/z-a-rust \
# zinit-zsh/z-a-as-monitor \
# zinit-zsh/z-a-patch-dl \
# zinit-zsh/z-a-bin-gem-node
zinit light zsh-users/zsh-history-substring-search
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="standout"
zinit light zsh-users/zsh-syntax-highlighting
# Due to the following issue:
# https://github.com/zsh-users/zsh-syntax-highlighting/issues/295
# Syntax highlighting is really slow when pasting long text. This speeds it
# up to just a slight delay
zstyle ':bracketed-paste-magic' active-widgets '.self-*'
zinit ice atload"unalias grv"
zinit snippet 'https://github.com/robbyrussell/oh-my-zsh/raw/master/plugins/git/git.plugin.zsh'
zinit snippet 'https://github.com/robbyrussell/oh-my-zsh/raw/master/plugins/ssh-agent/ssh-agent.plugin.zsh'
zinit snippet 'https://github.com/robbyrussell/oh-my-zsh/raw/master/plugins/vi-mode/vi-mode.plugin.zsh'
zinit light olets/zsh-window-title
export ZSH_WINDOW_TITLE_DIRECTORY_DEPTH=1
# Homebrew
# =========================================================================================
case $OS in
Darwin)
eval "$(/opt/homebrew/bin/brew shellenv)"
;;
Linux)
;;
esac
# Theme
# =========================================================================================
# Old "pure" theme
#------------------------------------------------------------------
# zinit ice compile'(pure|async).zsh' pick'async.zsh' src'pure.zsh'
# zinit light sindresorhus/pure
# see https://github.com/sindresorhus/pure for more colors
# zstyle :prompt:pure:git:dirty color green
# LS_COLORS
export LS_COLORS="$(vivid generate 'modus-operandi')"
#------------------------------------------------------------------
# Load starship
# line 1: `starship` binary as command, from github release
# line 2: starship setup at clone(create init.zsh, completion)
# line 3: pull behavior same as clone, source init.zsh
zinit ice as"command" from"gh-r" \
atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \
atpull"%atclone" src"init.zsh"
zinit light starship/starship
# Options section
# =========================================================================================
setopt correct # Auto correct mistakes
setopt extendedglob # Extended globbing. Allows using regular expressions with *
setopt nocaseglob # Case insensitive globbing
setopt rcexpandparam # Array expension with parameters
setopt nocheckjobs # Don't warn about running processes when exiting
setopt numericglobsort # Sort filenames numerically when it makes sense
setopt nobeep # No beep
setopt share_history # Share history between tabs
setopt histignorealldups # If a new command is a duplicate, remove the older one
setopt autocd # if only directory path is entered, cd there.
setopt promptsubst
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case insensitive tab completion
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Colored completion (different colors for dirs/files/etc)
zstyle ':completion:*' rehash true # automatically find new executables in path
# Speed up completions
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
HISTFILE=~/.zhistory
HISTSIZE=10000
SAVEHIST=500
WORDCHARS=${WORDCHARS//\/[&.;]} # Don't consider certain characters part of the word
# Keybindings section
# =========================================================================================
# enable vim mode
# https://dougblack.io/words/zsh-vi-mode.html
bindkey -v
#export KEYTIMEOUT=50
export KEYTIMEOUT=1
# bindkey jk vi-cmd-mode
# change cursor shape
function zle-keymap-select zle-line-init zle-line-finish
{
case $KEYMAP in
vicmd)
print -n '\033[1 q' # block cursor
#echo -ne "\033]12;Green1\007"
;;
viins|main)
print -n '\033[5 q' # line cursor
# echo -ne "\033]12;Orange1\007"
;;
esac
}
# Yank to the system clipboard
function vi-yank-xclip {
zle vi-yank
echo "$CUTBUFFER" | pbcopy -i
}
zle -N vi-yank-xclip
bindkey -M vicmd 'y' vi-yank-xclip
# Paste from system clipboard
function pastefromclipboard {
RBUFFER="$(pbpaste)$RBUFFER"
}
zle -N pastefromclipboard
bindkey -M vicmd 'p' pastefromclipboard
zle -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select
# Note: see man zshzle for info on bindkey
# use kitty +kitten show_key to get the right UNIX escape sequence
case $OS in
Darwin)
bindkey '^[[1~' beginning-of-line # Home key
bindkey '^[[4~' end-of-line # End key
bindkey '^[[3~' delete-char # Delete key
bindkey '^[[1;3C' forward-word # alt+Right key
bindkey '^[f' forward-word # alt+f key
bindkey '^[[1;3D' backward-word # alt+Left key
bindkey '^[b' backward-word # alt+b key
bindkey '^[[1;3A' beginning-of-line # alt+up key
bindkey '^[[1~' beginning-of-line # home key
bindkey '^[[1;3B' end-of-line # alt+down key
bindkey '^[[4~' end-of-line # end key
bindkey '^[^?' backward-kill-word # alt+bksp key
bindkey '^[[3;3~' kill-word # alt+del key
# bindkey '^H' backward-kill-line # cmd+bksp key, kitty does not differentiate between it and simple backspace
# bindkey '\x1b[3;9~' kill-line # cmd+del key, kitty does not differntiate between it and alt+del
;;
Linux)
bindkey '^[[3~' delete-char # Delete key
bindkey '^[[1;5C' forward-word # alt+Right key
bindkey '^[[1;5D' backward-word # alt+Left key
bindkey '^H' backward-kill-word # alt+bksp key
bindkey '^[[3;5~' kill-word # alt+del key
;;
esac
## Plugins section: Enable fish style features
zmodload zsh/terminfo
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# Color man pages
# =========================================================================================
export LESS_TERMCAP_mb=$'\E[01;32m'
export LESS_TERMCAP_md=$'\E[01;32m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;47;34m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;36m'
export LESS=-r
# SAP connect to work
# =========================================================================================
[[ -e ~/.secret.zsh ]] && source ~/.secret.zsh
alias sapconnect="sudo f5fpc --start --host https://connectpal05.sap.com --user $SAP_USER"
#alias sapconnect="sudo f5fpc --start --host https://connectphl11.sap.com --user $SAP_USER"
alias sapinfo="sudo f5fpc --info"
alias sapstop="sudo f5fpc --stop"
# alias saprdp="xfreerdp /bpp:16 /u:$SAP_USER /d:GLOBAL /f /v:VANN34331165A.amer.global.corp.sap +clipboard +fonts +auto-reconnect -floatbar"
alias saprdp="xfreerdp /bpp:16 /u:$SAP_USER /d:GLOBAL /f /v:VANN34331165A.amer.global.corp.sap +clipboard +fonts +auto-reconnect +floatbar"
# some OS specific config
# =========================================================================================
case $OS in
Darwin)
export HOMEBREW_NO_GITHUB_API=1
export HOMEBREW_NO_AUTO_UPDATE="1"
export DISABLE_AUTO_TITLE='true' # for tmuxp
export GROOVY_HOME=/usr/local/opt/groovy/libexec
#export PATH="/usr/local/opt/openjdk@11/bin:$PATH"
#export JAVA_HOME="/usr/local/opt/openjdk@11"
#export JAVA_HOME=$(/usr/libexec/java_home)
;;
Linux)
;;
esac
# Version Management
# =========================================================================================
# fast node version manager
eval "$(fnm env --use-on-cd)"
# export FNM_DIR="/opt/repos/.fnm"
# yarn version management
export YVM_DIR=/Users/stephanbadragan/.yvm
[ -r $YVM_DIR/yvm.sh ] && source $YVM_DIR/yvm.sh init-sh
#export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
# sdkman jdk managment
# export SDKMAN_DIR="$HOME/.sdkman"
# [[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
# jvm version management
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init - --no-rehash)"
(jenv rehash &) 2> /dev/null
# makes sure JAVA_HOME is exported
eval "$(jenv enable-plugin export)"
export PATH="$HOME/.jenv/bin:$PATH"
#path=($HOME/.jenv/bin(N-/) $path) # path to jenv binary folder
if type jenv > /dev/null 2>&1; then
zinit ice wait"0" lucid
# zinit ice wait"0" lucid atload"jenv enable-plugin export"
zinit light anquegi/zinit-jenv
fi
# EB vars
# =========================================================================================
export EB_FE_DEV_CERT_FILE="/opt/repos/eb/config/certs/eb-localdev.pem"
# Aliases
# =========================================================================================
alias vim="nvim"
alias xmdev="tmuxp load xmdev"
alias xmdev-cloud="tmuxp load xmdev-cloud"
alias xmdev-kill="confirm && tmux kill-session -t xmdev"
alias xmdev-cloud-kill="confirm && tmux kill-session -t xmdev-cloud"
alias devincloud="tmuxp load devincloud"
alias devincloud-kill="confirm && tmux kill-session -t devincloud"
# alias ls="ls -G"
alias ls="eza --icons=auto --width=80 --group-directories-first"
alias lst="colorls --light --tree"
alias git_cleanup_bugfix_branches="git branch | grep bugfix/ | xargs git branch -D"
alias git_cleanup_branches="git branch | grep -v '*' | grep -v 'master' | xargs git branch -D"
alias clean-gradle-cache="find ~/.gradle -type f -name \"*.lock\" -delete"
alias frontend-changed-strings="cd /opt/repos/frontend/reactUi/src/translations; git --no-pager diff --unified=0 origin/main:./en.json ./en.json | /usr/bin/sed '/^@/d' | /usr/bin/sed '/^\\+\\+\\+/d' | /usr/bin/sed '/^---/d' | /usr/bin/sed 's/^\\+ //'; cd -"
alias list_listening_procs="sudo lsof -iTCP -sTCP:LISTEN -n -P"
# note: config is in cypress.env.json
alias qa-automation-run-kramerica="yarn run cypress open --config baseUrl=https://kramerica.dev.xmatters.com --e2e --browser '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'"
alias yarn-test-changed="yarn run test --watch --changedSince=origin/main"
alias pnpm-test-changed="pnpm run test --watch --changedSince=origin/main"
alias ondemand-dev-in-cloud="cd /opt/repos/ondemand; ./gradlew bootRunDevInCloud -PgcpInstance=kramerica -Pversion=0.x.stephanlocal -PdevInCloud=true -PrunVoiceXml=false -PrunSoap=false -i"
alias ondemand-dev-in-cloud-stop="xmvers kramerica webui 0-x-main"
alias ebfd-ondemand-dev-in-cloud="cd /opt/repos/ondemand; ./gradlew bootRunDevInCloud -PgcpInstance=kramerica-ebfd -Pversion=0.x.stephanlocal -PdevInCloud=true -PrunVoiceXml=false -PrunSoap=false -i"
alias ebfd-ondemand-dev-in-cloud-stop="xmvers kramerica-ebfd webui 0-x-main"
alias ondemand-rebuild="cd /opt/repos/ondemand; ./gradlew clean build -x test -x analyzeClassesDependencies -x analyzeTestClassesDependencies"
alias ondemand-webui-integ-test="cd /opt/repos/ondemand; ./gradlew webui:integTest --tests " # param need, ex: com.xmatters.exportimport.RelevanceEngineImportHandlerIntegTest.testImportEngineWithIntegrationNoAuthType
alias ondemand-webui-integ-test-debug="cd /opt/repos/ondemand; ./gradlew webui:integTest --debug-jvm --tests " # listens to port 5005, param need, ex: com.xmatters.exportimport.RelevanceEngineImportHandlerIntegTest.testImportEngineWithIntegrationNoAuthType
alias icat="kitty +kitten icat"
alias d="kitty +kitten diff"
alias qmk-flash-dactyl="qmk flash -kb handwired/dactyl_manuform/5x6 -km MagicDuck"
alias qmk-flash-cyboard="qmk flash -kb cyboard/dactyl/manuform_number_row -km sbadragan"
alias xmapi-dev-in-cloud="./gradlew bootRunDevInCloud -PgcpInstance=kramerica -Pversion=0.x.kramerica -x test -x spotbugsTest -x spotbugsMain -x checkstyleTest -x checkstyleMain"
alias xmapi-dev-in-cloud-stop="xm-instance-switch-version kramerica xmapi 0-x-main"
alias showkey="kitty +kitten show_key"
alias gcloud-impersonate-start="gcloud config set auth/impersonate_service_account [email protected]"
alias gcloud-impersonate-stop="gcloud config unset auth/impersonate_service_account"
alias ly="lazygit -w ~ -g ~/.local/share/yadm/repo.git "
alias my_conda_list_env="conda env list"
alias my_conda_activate="conda activate"
# FZF
# =========================================================================================
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
export FZF_DEFAULT_OPTS='--height 60% --layout=reverse --tiebreak=end --bind ctrl-a:toggle-all'
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow --glob "!{.git,node_modules}/*" 2> /dev/null'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# gcloud
# =========================================================================================
case $OS in
Darwin)
source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
;;
Linux)
;;
esac
# pnpm
# =========================================================================================
# export PNPM_HOME="/Users/stephanbadragan/Library/pnpm"
# export PATH="$PNPM_HOME:$PATH"
# BAT
# =========================================================================================
# export BAT_THEME='OneHalfLight'
# export BAT_THEME='Coldark-Cold'
# export BAT_THEME='GitHub'
export BAT_THEME='gruvbox-light'
# Git fuzzy
# =========================================================================================
export PATH=~/git-fuzzy/bin:$PATH
# Fix file limit exceeded issue
# =========================================================================================
ulimit -n 10240
# add gnu bin path for stuff like gnu-sed to override default sed
# =========================================================================================
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
# ranger vim cursor support
# =========================================================================================
function ranger () { command ranger "$@"; echo -e "\e[?25h"; }
# miniconda python virtual env
# =========================================================================================
case $OS in
Darwin)
__conda_setup="$('/opt/homebrew/Caskroom/miniconda/base/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" ]; then
. "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh"
else
export PATH="/opt/homebrew/Caskroom/miniconda/base/bin:$PATH"
fi
fi
unset __conda_setup
;;
Linux)
;;
esac
# Allows zsh -is eval "command" without exiting
# see https://www.zsh.org/mla/users/2005/msg00599.html
# =========================================================================================
if [[ $1 == eval ]]
then
"$@"
set --
fi
# [[ -z "${ZELLIJ}" ]] && zellij -l welcome
# certs
# =========================================================================================
case $OS in
Darwin)
export AWS_CA_BUNDLE=/Users/stephanbadragan/zcc/certs/ZscalerRootCertificate-2048-SHA256.crt
export REQUESTS_CA_BUNDLE=/Users/stephanbadragan/zcc/certs/allCAbundle.pem
export NODE_EXTRA_CA_CERTS=/Users/stephanbadragan/zcc/certs/allCAbundle.pem
;;
Linux)
;;
esac