-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathzshrc-mini
More file actions
357 lines (284 loc) · 10 KB
/
zshrc-mini
File metadata and controls
357 lines (284 loc) · 10 KB
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
UNAME=`uname`
################################################################################
## Aliases
################################################################################
if [ -x /usr/bin/host-nikhof ]
then
alias host="host-nikhof"
fi
if [ -x /usr/bin/links2 ]
then
alias links="links2"
fi
# editor
alias e='vim'
alias v='vim'
alias vi='vim'
# alias gvim='gvim.gnome'
alias k='kubectl'
alias ncdu='ncdu --color=dark'
alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules"
# ls
if [ "x`uname`" = "xDarwin" ]
then
alias ls='ls -G'
else
alias ls='ls --color=auto'
fi
alias l='ls'
alias la='ls -a'
alias ll='ls -l'
alias lla='ls -la'
# manual
pinfo=`which pinfo`
if [ $? -eq 0 ]
then
alias man='pinfo -m'
alias info='pinfo'
fi
alias lftp='nocorrect lftp'
alias ftp='lftp'
alias mv='nocorrect mv' # no spelling correction on mv
alias cp='nocorrect cp' # no spelling correction on cp
alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
alias c='reset;clear'
alias ocd='cd $OLDPWD'
alias grep='grep --color=auto'
################################################################################
## Environment
################################################################################
export RUBYOPT=rubygems
export MOSH_TITLE_NOPREFIX=1
export CONFIG_DIR='etc'
export HOME_ETC="$HOME/$CONFIG_DIR"
export HOSTNAME=`/bin/hostname`
export CVS_RSH='ssh'
export EDITOR='vim'
export SCREENDIR="$HOME/tmp/screen"
export PATH="$HOME/bin:/usr/local/bin:$PATH:/usr/X11R6/bin:/usr/sbin:/sbin:/usr/games"
if [ "x$UNAME" = "xDarwin" ]
then
export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
fi
path=($path $HOME/bin:/usr/local/bin)
export HISTFILE="$HOME/.history"
export HISTSIZE="10000"
export SAVEHIST="10000"
export LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;3:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:"
################################################################################
## Locale
################################################################################
#export LC_MESSAGES=C
export LANG=en_US.UTF-8
#if [ "x$LANG" = "x" ]
#then
# unset LC_ALL
# export LC_CTYPE=pl_PL
# export LC_TIME=pl_PL
# export LC_MONETARY=pl_PL
# export LC_MEASUREMENT=pl_PL
# export LC_MESSAGES=C
# export LANGUAGE=pl
# export LANG=pl_PL
#fi
if [ "x$UNAME" = "xDarwin" ]
then
unset LC_CTYPE
fi
################################################################################
## Completion
################################################################################
## Kolorowe dopełnianie
if [ "x`uname`" != "xDarwin" ]
then
eval $(dircolors)
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
fi
### Wybieranie dopełnienia za pomocą kursora
#setopt menucomplete
#zstyle ':completion:*' menu select=long-list select=1
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:rm:*' ignore-line yes
zstyle ':completion:*' group-name
zstyle ':completion:*' file-sort name
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
zstyle ':completion:*:expand:*' tag-order all-expansions
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~'
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.(o|c~|old|pro|zwc)'
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~''*?.old' '*?.pro'
zstyle ':completion:*' expand 'yes'
zstyle ':completion:*' squeeze-slashes 'yes'
## case-insensitive (uppercase from lowercase) completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
## case-insensitive (all) completion
#zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
## case-insensitive,partial-word and then substring completion
#zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*
## completion caching
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path ~/.zcompcache/$HOST
# complete hostnames out of ssh's ~/.ssh/known_hosts
zstyle ':completion:*' use-cache on
zstyle ':completion:*' users resolve
# ssh hosts
#sshhosts=(xxx)
#scphosts=(xxx: yyy:)
#compctl -k sshhosts ssh
#compctl -/ -f -k scphosts scp
################################################################################
## Bindings
################################################################################
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
[[ -n "${key[Home]}" ]] && bindkey "$key[Home]" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "$key[End]" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "$key[Insert]" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "$key[Delete]" delete-char
[[ -n "${key[Left]}" ]] && bindkey "$key[Left]" backward-char
[[ -n "${key[Right]}" ]] && bindkey "$key[Right]" forward-char
[[ -n "${key[Up]}" ]] && bindkey "$key[Up]" history-beginning-search-backward
[[ -n "${key[Down]}" ]] && bindkey "$key[Down]" history-beginning-search-forward
[[ -n "${key[PageUp]}" ]] && bindkey "$key[PageUp]" up-line-or-search
[[ -n "${key[PageDown]}" ]] && bindkey "$key[PageDown]" down-line-or-search
bindkey ' ' magic-space # also do history expansion on space
bindkey '^[[A' history-beginning-search-backward
bindkey '^[[B' history-beginning-search-forward
bindkey '^[[Z' reverse-menu-complete
bindkey "^R" history-incremental-search-backward
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
bindkey '^?' backward-delete-char
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
bindkey "\M\b" backward-delete-word # xterm
bindkey "^[[5D" backward-word # xterm
bindkey "^[[5C" forward-word # xterm
bindkey "˙" backward-delete-word # xterm (silly)
bindkey "^[[3;3~" delete-word # xterm
bindkey "^[^[[3~" delete-word # aterm
bindkey "^[^[[3~" delete-word # aterm
bindkey "^[O5D" backward-word # screen
bindkey "^[O5C" forward-word # screen
bindkey "^[Od" backward-word # aterm
bindkey "^[Oc" forward-word # aterm
bindkey "^[[1~" beginning-of-line # Linux console
bindkey "^[OH" beginning-of-line # xterm
bindkey "^[[H" beginning-of-line # xterm
bindkey "^[[4~" end-of-line # Linux console
bindkey "^[OF" end-of-line # xterm
bindkey "^[[F" end-of-line # xterm
bindkey "^[[7~" beginning-of-line # aterm
bindkey "^[[8~" end-of-line # aterm
# if [ "x`uname`" != "xDarwin" ]
# then
# bindkey "^[[D" backward-word
# bindkey "^[[C" forward-word
# fi
#
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
# os x
bindkey '^[^[[C' forward-word
bindkey '^[^[[D' backward-word
# terminal settings
# if [ "$TERM" = "xterm" ]; then
# export TERM='linux'
# fi
#if [ "$TERM" = "vt220" -o "$TERM" = "vt100" ]; then
# export TERM='xterm-color'
#fi
ulimit -c 5120 2> /dev/null
# zsh options
# setopt correctall
# setopt noautolist
# setopt bashautolist
# setopt listtypes
# setopt listpacked
# setopt autocd
# setopt automenu
# setopt extendedhistory
# setopt extendedglob
# setopt nolistbeep
# setopt allexport
# setopt prompt_subst
# Some terminals require this - uncomment if you like
#echo -ne '\033(K'
# homebrew
[ -f /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
# The next line updates PATH for the Google Cloud SDK.
if [ -f "$HOME/google-cloud-sdk/path.zsh.inc" ]; then . "$HOME/google-cloud-sdk/path.zsh.inc"; fi
# The next line enables shell command completion for gcloud.
if [ -f "$HOME/google-cloud-sdk/completion.zsh.inc" ]; then . "$HOME/google-cloud-sdk/completion.zsh.inc"; fi
if [ -f ~/.fzf.zsh ]
then
source ~/.fzf.zsh
elif [ -f /opt/homebrew/opt/fzf/shell/key-bindings.zsh ]
then
source /opt/homebrew/opt/fzf/shell/key-bindings.zsh
fi
[ -f /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[ -f /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[ -f ~/.iterm2_shell_integration.zsh ] && source ~/.iterm2_shell_integration.zsh
fasd_path=`which fasd`
if [ $? -eq 0 ]
then
eval "$(fasd --init auto)"
fi
export FZFZ_RECENT_DIRS_TOOL="fasd"
bat_path=`which bat`
if [ $? -eq 0 ]
then
alias cat="$bat_path"
export AWS_PAGER="bat"
fi
GO_BIN=`which go`
if [ $? -eq 0 ]
then
export PATH="$(go env GOPATH)/bin:$PATH"
fi
# Kubernetes helpers
alias k="kubectl"
function kns() {
if [ $# -eq 1 ]
then
echo "Switching kubernetes namespace to $1"
CONTEXT=$(kubectl config current-context)
kubectl config set-context $CONTEXT --namespace=$1 > /dev/null
else
kubectl config current-context
fi
}
function ksh() {
if [ $# -eq 1 ]
then
kubectl exec -it $1 -- /bin/sh
fi
}
function k_kind() {
kubectl config set-context kind-kind
}
function kube-toggle() {
if (( ${+POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND} )); then
unset POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND
else
POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile'
fi
p10k reload
if zle; then
zle push-input
zle accept-line
fi
}
zle -N kube-toggle
bindkey '^]' kube-toggle # ctrl-] to toggle kubecontext in powerlevel10k prompt
. ~/.zshrc_private