-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot_zshrc
182 lines (148 loc) · 4.47 KB
/
dot_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
#setopt XTRACE
setopt interactive_comments
setopt chase_links
setopt hist_ignore_space
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export ZSH=$HOME/.oh-my-zsh
export ZSH_CUSTOM="$HOME/.zsh-custom"
plugins=(vi-mode kubectl aws 1password nvm)
zstyle ':omz:plugins:nvm' autoload yes
__USR_PATH="/usr"
if [[ $(uname -s) == "Darwin" ]]; then
__USR_PATH="/opt/homebrew"
fi
eval "$(/opt/homebrew/bin/brew shellenv)"
export PATH="$HOME/.local/bin:/opt/homebrew/opt/curl/bin:$PATH"
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
for __customfile in $HOME/.zsh-custom/*.zsh; do
source $__customfile
done
unsetopt XTRACE
source $ZSH/oh-my-zsh.sh
eval "$(starship init zsh)"
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
eval "$(fzf --zsh)"
fpath=(~/.zsh-completions /opt/homebrew/share/zsh/site-functions $fpath)
alias tf=terraform
alias lg=lazygit
alias gco='g checkout'
alias ga="g add"
alias gc="g commit -v"
alias mongod="mongod --config /usr/local/etc/mongod.conf"
alias less="less -R"
alias d="grc --colour=auto docker"
alias k=kubectl
alias ggpnp='git stash && git pull --rebase && git push && git stash pop'
alias ag="ag -S"
alias vscr="v -c ':Scratch'"
alias mytop="perl /usr/local/bin/mytop"
alias g=git
alias cm=chezmoi
#alias g="~/git"
#alias lab="~/lab"
if [ -x $__USR_PATH/bin/richgo ] || [ -x $HOME/go/bin/richgo ]; then
alias go=richgo
fi
alias rg="rg -i -g \"!{vendor}\""
if [ -x $__USR_PATH/bin/bat ]; then
alias cat=bat
fi
export LESS="-iMx4 -RX"
export LESS_TERMCAP_so=$'\E[30;43m'
export LESS_TERMCAP_se=$'\E[39;49m'
export GIT_EDITOR=$EDITOR
load_nvm() {
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
}
function quote() {
echo "“$*”" | pbcopy
}
export NODE_PATH=$__USR_PATH/lib/node
function bail_on_tmux() {
echo "Loading tmux...."
echo "Press CTRL-C to cancel"
sleep 1.5
}
function load_tmux() {
tmux_session="local"
if [ ! -z "$SSH_CONNECTION" ]; then
tmux_session="ssh"
fi
if [[ "$__CFBundleIdentifier" == "com.qvacua.VimR" ]]; then
return
fi
if (which tmux 2>&1 > /dev/null); then
if [ -z "$TMUX" ] && ( tmux ls | grep "${tmux_session}:" &> /dev/null ); then
bail_on_tmux && tmux attach -t $tmux_session && exit
else
if [ -z "$TMUX" ] && [ -z "$SUDO_USER" ]; then
bail_on_tmux && tmux new-session -s $tmux_session && exit
fi
fi
fi
}
function printcolors() {
for i in {0..255} ; do
printf "\\x1b[38;5;${i}m \\\x1b[38;5;${i}m\n"
printf "\x1b[38;5;${i}mcolour${i}\x1b[0m\n"
done
}
function jstags() {
find . -type f -iregex ".*\.js$" -not -path "./node_modules/*" -exec jsctags {} -f \; | sed '/^$/d' | sort > tags
}
# History searching
bindkey -M vicmd '/' fzf-history-widget
bindkey -M vicmd '?' history-incremental-pattern-search-forward
bindkey -M isearch '^R' history-incremental-search-backward
bindkey -M isearch '^F' history-incremental-search-forward
bindkey "^Q" push-input
if [[ "$TERM_PROGRAM" == "ghostty" && -d $HOME/Google\ Drive/My\ Drive/Visual\ fortunes ]]; then
kitten icat --align=left "$(find "$HOME/Google Drive/My Drive/Visual fortunes" -name '*.png' -or -name '*.jpg' | shuf -n 1)"
else
fortune startrek computers $HOME/.fortunes/sadserver_tweets $HOME/.fortunes/honest_update_tweets $HOME/.fortunes/devops_borat
fi
echo
stty discard undef
TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S'
ulimit -S -n 2048
if [ -f $HOME/.config/op/plugins.sh ]; then
source $HOME/.config/op/plugins.sh
unalias aws
fi
#load_tmux
if [ -f /opt/homebrew/etc/grc.zsh ]; then
. /opt/homebrew/etc/grc.zsh
elif [ -f /usr/local/etc/grc.zsh ]; then
. /usr/local/etc/grc.zsh
elif [ -f /etc/grc.zsh ]; then
. /etc/grc.zsh
fi
unalias kubectl &> /dev/null
unfunction kubectl &> /dev/null
kubectl() {
if [[ "$1" == "node-shell" ]]; then
$__USR_PATH/bin/kubectl "$@"
elif [[ "$@" =~ '(attach|run|exec|logs|edit)' ]]; then
$__USR_PATH/bin/kubectl "$@"
else
grc -e -s -c conf.kubectl -- $__USR_PATH/bin/kubectl "$@"
fi
}
# Alias ls after grc since lsd is colorized
if [ -x $__USR_PATH/bin/lsd ]; then
alias ls=lsd
fi
alias l='ls -l'
if [ -f $__USR_PATH/bin/aws_zsh_completer.sh ]; then
. $__USR_PATH/bin/aws_zsh_completer.sh
fi
autoload -Uz compinit bashcompinit
compinit
bashcompinit
# I don't use visual mode in the terminal since I use tmux
bindkey -M vicmd 'v' edit-command-line
load_nvm
eval $(thefuck --alias)
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh