forked from lu5je0/.dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
294 lines (233 loc) · 9.35 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
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
##########################################
# zinit
##########################################
if [[ ! -d ~/.local/share/zinit/zinit.git ]]; then
git clone --depth=1 https://github.com/zdharma-continuum/zinit.git ~/.local/share/zinit/zinit.git
fi
source ~/.local/share/zinit/zinit.git/zinit.zsh
export UNAME_INFO=$(uname -a)
fpath=(~/.dotfiles/zsh/completions $fpath)
autoload -Uz compinit && compinit
setopt AUTO_CD
# 设置 Zsh 在命令补全时删除后缀的字符,只设置一个空格,那么只有空格会被删除。
# If ZLE_REMOVE_SUFFIX_CHARS is not set, the default behaviour is equivalent to:
# ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'
export ZLE_REMOVE_SUFFIX_CHARS=''
##########################################
# OMZ
##########################################
zinit snippet OMZ::lib/completion.zsh
zinit snippet OMZ::lib/history.zsh
zinit snippet OMZ::lib/key-bindings.zsh
zinit snippet OMZ::lib/git.zsh
# 注释后没有文件颜色
zinit snippet OMZ::lib/theme-and-appearance.zsh
# zinit ice lucid wait='0'
zinit snippet OMZ::plugins/git/git.plugin.zsh
unalias gcp
zinit ice lucid wait='1'
zinit snippet OMZ::plugins/colored-man-pages/colored-man-pages.plugin.zsh
##########################################
# plugins
##########################################
zinit ice depth=1 lucid wait='1'
zinit light paulirish/git-open
zinit ice depth=1 lucid wait='0'
zinit light zsh-users/zsh-syntax-highlighting
zinit ice depth=1 lucid wait='0'
zinit light hlissner/zsh-autopair
# zinit ice lucid wait='0' atload='_zsh_autosuggest_start'
# zinit light zsh-users/zsh-autosuggestions
# 额外补全
zinit ice depth=1 lucid wait='0'
zinit light zsh-users/zsh-completions
##########################################
# 本地sh文件
##########################################
zinit ice lucid wait='0'
zinit snippet ~/.dotfiles/zsh/zoxide.sh
# zinit ice lucid wait='1'
zinit snippet ~/.dotfiles/zsh/platform.sh
zinit ice lucid wait='1'
zinit snippet ~/.dotfiles/zsh/functions.sh
zinit ice lucid wait='1'
zinit snippet ~/.dotfiles/zsh/proxy.sh
zinit snippet ~/.dotfiles/zsh/vi-mode.zsh
zinit snippet ~/.dotfiles/zsh/vi-im-switch.zsh
# zinit wait'2' lucid \
# atinit"source $ZHOMEDIR/rc/pluginconfig/per-directory-history.zsh" \
# atload"_per-directory-history-set-global-history" \
# light-mode for @CyberShadow/per-directory-history
# https://github.com/jimhester/per-directory-history/issues/21
# https://github.com/jimhester/per-directory-history/issues/27
##########################################
# theme
##########################################
# zinit snippet ~/.dotfiles/zsh/lu5je0.zsh-theme # lu5je0
# p10k
zinit ice depth=1
zinit light romkatv/powerlevel10k
source ~/.dotfiles/zsh/p10k.zsh
##########################################
# zsh key mappings
##########################################
bindkey "^[[5~" history-beginning-search-backward
bindkey "^[[6~" history-beginning-search-forward
# bindkey "^n" autosuggest-accept
##########################################
# ENV
##########################################
export ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=""
export PATH=~/.local/bin:~/.local/bin/solid:$PATH
export PATH=$PATH:~/go/bin
export EDITOR=nvim
export PATH=~/.local/share/neovim/bin:$PATH
export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=01;34:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.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:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:"
export NODE_NO_WARNINGS=1
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
##########################################
# alias
##########################################
alias pc="proxychains4 -q"
# alias sftp="sftp -C"
alias crontab="cron.sh"
# alias wgetp="wget -c -e use_proxy=yes -e http_proxy=p775.local:1080 -e https_proxy=p775.local:1080"
alias vc='vi ~/tools/script/curl.sh'
alias vz='vi ~/.dotfiles/zshrc'
alias sz='source ~/.dotfiles/zshrc'
alias sudo='sudo env PATH=/sbin:$PATH'
alias sudo-default-path='\sudo'
# alias sudo="sudo "
# alias sudo-with-path='sudo env PATH=$PATH'
alias awk-map-count="awk '{a[\$1]++} END {for (i in a) print i,a[i]}'"
alias speedtest-hz='speedtest -s 54312'
alias speedtest-hk='speedtest -s 1536'
alias speedtest-js='speedtest -s 5396'
# ls
# alias l='ls -lah'
# alias ll='ls -lh'
alias ll='eza -laF'
alias l='eza -lF'
# alias rz='trz'
# alias sz='tsz'
alias grep='grep --color'
alias ntpdate-aliyun='sudo ntpdate -u time1.aliyun.com'
# git
alias gmc='sh ~/tools/script/gmc.sh'
alias gck='git checkout'
alias glc='python3 ~/tools/script/xhyd/deploy.py'
alias qrencode-ansi='qrencode -t ansiutf8'
alias time-204='time curl "https://www.gstatic.com/generate_204"'
alias time-204-http='time curl "http://www.gstatic.com/generate_204"'
alias curl-post-json='curl -H "Content-Type:application/json" -X POST'
# tmux
alias td="tmux detach"
alias tl="tmux ls"
alias tkss="tmux kill-session -t"
# alias ta="tmux attach -t"
alias tn="tmux new-session -s"
function ta() {
# 检查是否提供了会话名
if [ -z "$1" ]; then
echo "Usage: ta <session-name>"
return 1
fi
# 尝试连接到会话,如果不存在则创建
if tmux has-session -t "$1" 2>/dev/null; then
tmux attach -t "$1"
else
tmux new-session -s "$1"
fi
}
# nvim
alias vi='nvim'
alias vim='nvim'
alias vimn='nvim -u None'
# maven
alias mvni='mvn install -Dmaven.test.skip=true'
alias mvnp='mvn package -Dmaven.test.skip=true'
# docker
alias sd='sudo docker'
alias sdc='sudo docker-compose'
alias md='mkdir -p'
##########################################
# vi-mode
##########################################
VI_MODE_SET_CURSOR="true"
bindkey -a H vi-first-non-blank
bindkey -a L vi-end-of-line
bindkey -a j down-line
bindkey -a k up-line
bindkey -a K history-beginning-search-backward
bindkey -a J history-beginning-search-forward
end-of-buffer() {
CURSOR=9999999
}
zle -N end-of-buffer
begin-of-buffer() {
CURSOR=0
}
zle -N begin-of-buffer
bindkey -a gg begin-of-buffer
bindkey -a G end-of-buffer
export KEYTIMEOUT=1
# surround
autoload -Uz surround
zle -N delete-surround surround
zle -N add-surround surround
zle -N change-surround surround
bindkey -a cs change-surround
bindkey -a ds delete-surround
bindkey -a ys add-surround
bindkey -M visual S add-surround
# bindkey -a "m" autosuggest-accept
# bindkey -a "^n" autosuggest-accept
# 补全
# 0 -- vanilla completion (abc => abc)
# 1 -- smart case completion (abc => Abc)
# 2 -- word flex completion (abc => A-big-Car)
# 3 -- full flex completion (abc => ABraCadabra)
# zstyle ':completion:*' matcher-list '' \
# 'm:{a-z\-}={A-Z\_}' \
# 'r:[^[:alpha:]]||[[:alpha:]]=** r:|=* m:{a-z\-}={A-Z\_}' \
# 'r:|?=** m:{a-z\-}={A-Z\_}'
if [[ ! -f ~/.ohmyenv ]]; then
touch ~/.ohmyenv
echo "# export PATH=~/.local/share/neovim/bin:$PATH\n# export USER_HTTP_PROXY='http://127.0.0.1:1081'" >~/.ohmyenv
fi
source ~/.ohmyenv
# if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then
# exec tmux
# fi
setopt ignore_eof
function bash-ctrl-d() {
if [[ $CURSOR == 0 && -z $BUFFER ]]; then
[[ -z $IGNOREEOF || $IGNOREEOF == 0 ]] && exit
if [[ "$LASTWIDGET" == "bash-ctrl-d" ]]; then
((--__BASH_IGNORE_EOF <= 1)) && exit
else
echo 'repeat ^D to exit shell'
((__BASH_IGNORE_EOF = IGNOREEOF))
fi
else
zle delete-char-or-list
fi
}
export IGNOREEOF=2
zle -N bash-ctrl-d
bindkey '^D' bash-ctrl-d
### End of Zinit's installer chunk
# bob
[[ -s "$HOME/.local/share/bob/nvim-bin" ]] && export PATH="$HOME/.local/share/bob/nvim-bin":$PATH
# linuxbrew
[[ -d "/home/linuxbrew/.linuxbrew/bin" ]] && export PATH=$PATH:"/home/linuxbrew/.linuxbrew/bin:"
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"