-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
258 lines (216 loc) · 8 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
# 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
# env prompt plugins user-configuration alias
# zsh 文件加载顺序:.zshenv → .zprofile → .zshrc → .zlogin → .zlogout
# 为了环境变量不被 .zprofile 覆盖,使用 .zshrc 存放环境变量
# env ##############################################
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.vector/bin:$PATH
# nvim
export NVIM_PATH=/usr/local/nvim-macos
export PATH=$NVIM_PATH/bin:$PATH
# java
# export JAVA_HOME=/usr/local/java/jdk1.8.0_201
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.0.5.jdk/Contents/Home
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
# python
export PYTHONPATH=/usr/bin/python3
export PYTHONPATH=$PYTHONPATH:$HOME/.pyenv/versions/3.9.16/lib/python3.9/site-packages
export PYENV_ROOT=$HOME/.pyenv
export PATH=$HOME/.pyenv/shims:$PATH
# golang
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$GOBIN:$GOROOT/bin:$PATH
export GO111MODULE=on
export GOPROXY=https://goproxy.io,direct
# export GOPROXY=https://goproxy.cn
# rust
export PATH=$HOME/.cargo/bin:$PATH
# lua
export LUA_PATH="./?.lua;;"
# 安装 emacs 时,需要 pyenv 依赖
export EMACS_PATH=/Applications/Emacs.app/Contents/MacOS
export PATH=$EMACS_PATH:$EMACS_PATH/bin:$PATH
# 取消 tldr 自动更新
export TLDR_AUTO_UPDATE_DISABLED=true
# 取消 brew 自动更新
export HOMEBREW_NO_AUTO_UPDATE=true
# 使用自己的 ranger 配置
export RANGER_LOAD_DEFAULT_RC=false
# ripgrep configuration file
export RIPGREP_CONFIG_PATH=$HOME/dotfiles/.ripgreprc
# nvm: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # T
if [ -f ~/servicewall/secret.zsh ]; then
source ~/servicewall/secret.zsh
fi
# prompt ##############################################
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# Set list of themes to pick from when loading at random
# ZSH_THEME="robbyrussell"
# ZSH_THEME="jonathan"
ZSH_THEME="powerlevel10k/powerlevel10k"
# ZSH_THEME="fino-time"
# ZSH_THEME="mikeh"
# ZSH_THEME="muse"
# ZSH_THEME="robbyrussell"
# ZSH_THEME="gallois"
# ZSH_THEME="juanghurtado"
# ZSH_THEME="agnoster"
# ZSH_THEME="kolo"
# ZSH_THEME="miloshadzic"
# ZSH_THEME="nanotech" # **
# ZSH_THEME="rkj-repos"
# ZSH_THEME="blinks"
# ZSH_THEME="bureau"
# ZSH_THEME="arrow"
# ZSH_THEME="avit"
# ZSH_THEME="bira"
# ZSH_THEME="blinks"
# ZSH_THEME="crunch"
# ZSH_THEME="fox"
# ZSH_THEME="funky"
# ZSH_THEME="sonicradish"
# ZSH_THEME="xiong-chiamiov"
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# plugins #############################################
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
HIST_STAMPS="mm/dd/yyyy"
setopt HIST_IGNORE_DUPS
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Add wisely, as too many plugins slow down shell startup.
plugins=(
vi-mode
zsh-autosuggestions
zsh-syntax-highlighting
you-should-use
z
)
# git support git aliases
# autojump quick jump with j
# zsh-history-substring-search
# copyfile
# after plugins and before plugin.zsh
source $ZSH/oh-my-zsh.sh
# after source $ZSH/oh-my-zsh.sh
# vi-mode
VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true
VI_MODE_SET_CURSOR=true
KEYTIMEOUT=1
# https://gist.github.com/ssebastianj/dd4a42da5eee3304751712dc8aa1dc62
bindkey '^b' backward-char
bindkey '^f' forward-char
bindkey '^w' backward-kill-word
bindkey '^a' beginning-of-line
bindkey '^e' end-of-line
bindkey '^p' up-line-or-beginning-search
bindkey '^n' down-line-or-beginning-search
# you should use
export YSU_MESSAGE_POSITION="after"
# user configuration ##################################
# You may need to manually set your language environment
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# export LANG=zh_CN.UTF-8
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# export BAT_CONFIG_PATH="${HOME}/dotfiles/bat.conf"
# --list-theme
export BAT_THEME="OneHalfDark"
# add less' arg -X for delta pager
export DELTA_PAGER="less -X $LESS"
# ostype ##############################################
if [[ "$OSTYPE" = darwin* ]]; then
alias rm=rmtrash
vimedit()
{
touch $1
open -a MacVim $1
}
alias v=vimedit
alias copy=pbcopy
alias dropbox='cd /Users/haoran/Library/CloudStorage/Dropbox'
elif [[ "$OSTYPE" = linux-gnu* ]]; then
# export GTK_IM_MODULE=fcitx5
# export QT_IM_MODULE=fcitx5
# export XMODIFIERS=@im=fcitx
alias open=dolphin
alias copy='xclip -selection clipboard'
alias dropbox='cd /home/haoran/Dropbox'
xset r rate 250 55
else
echo "unknow os"
fi
# highlight man page ##################################
export LESS_TERMCAP_mb=$'\e[1;31m' # begin bold
export LESS_TERMCAP_md=$'\e[1;33m' # begin blink
export LESS_TERMCAP_so=$'\e[01;44;37m' # begin reverse video
export LESS_TERMCAP_us=$'\e[01;37m' # begin underline
export LESS_TERMCAP_me=$'\e[0m' # reset bold/blink
export LESS_TERMCAP_se=$'\e[0m' # reset reverse video
export LESS_TERMCAP_ue=$'\e[0m' # reset underline
export GROFF_NO_SGR=1
# alias ###############################################
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
alias l='eza -a --group-directories-first'
alias ll='eza -l -U --icons --octal-permissions --group-directories-first -b -h -i --time-style long-iso'
alias lt='eza -l -U --icons --octal-permissions --group-directories-first -b -h -i --time-style long-iso --sort=created --reverse'
alias la='eza -l -U --icons --octal-permissions --group-directories-first -b -h -i --time-style long-iso -a'
alias c='clear'
alias gg='git clone'
alias lg='lazygit'
alias e='emacsclient -n'
alias q='exit'
alias so='source ~/.zshrc'
alias capacity='find /sys/ -name capacity -exec cat {} \;'
alias sudo='sudo '
alias gm='go run main.go'
alias pm='python main.py'
alias lm='lua main.lua'
gobuild()
{
go build -o _exe -gcflags "-N -l" $1
}
alias godebug='dlv exec _exe'
# build ran-tldr command first
alias r='~/haoran/gr/tldr/bin/ran-tldr'
alias ran.server='ssh ran.server'
alias cat='bat'
alias ping='gping'
# Generated for envman. Do not edit.
[ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# ^r fuzzy search
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh