-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
215 lines (170 loc) · 7.01 KB
/
dot_zshrc.tmpl
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
### 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
### zinit custom start
# 迁移 oh-my-zsh lib 相当于oh-my-zsh 默认加载的插件
# lib 目录: https://github.com/ohmyzsh/ohmyzsh/tree/master/lib
zinit snippet OMZL::clipboard.zsh
# zinit snippet OMZL::termsupport.zsh
# zinit snippet OMZL::history.zsh
# zinit snippet OMZL::key-bindings.zsh
# zinit snippet OMZL::completion.zsh
zinit snippet OMZL::git.zsh
# Load starship theme
# `starship` binary as command, from github release
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
# eval "$(starship init zsh)"
# install and enable fzf.
# 'completion.zsh -> _fzf;' is not needed, as fzf will be loaded by fzf-tab
zinit wait lucid \
for \
as'command' \
dl="$(print -c https://raw.githubusercontent.com/junegunn/fzf/master/{shell/'key-bindings.zsh;',man/{'man1/fzf.1 -> $ZPFX/share/man/man1/fzf.1;','man1/fzf-tmux.1 -> $ZPFX/share/man/man1/fzf-tmux.1;'}})" \
from'gh-r' \
pick'fzf' \
src'key-bindings.zsh' \
@junegunn/fzf
# install oh my tmux, ~/.tmux.conf.local 会通过 chezmoi 创建
zinit for \
as"null" \
from'github' \
atclone'ln -s -f $PWD/.tmux.conf ~/.tmux.conf' \
@gpakosz/.tmux
# zellij is an alternative to tmux. https://github.com/zellij-org/zellij
# install zellij
# zinit wait lucid \
# as"command" from"gh-r" \
# atclone"./zellij setup --generate-completion zsh > ./_zellij" \
# atpull"%atclone" \
# atload"zicompinit; zicdreplay" \
# bpick"*x86_64-apple-darwin.tar.gz" \
# pick"zellij" \
# for zellij-org/zellij
# install exa
# mac 的 arm cpu 下仍然需要使用 brew 手动安装 exa
zinit ice as"command" from"gh-r" \
atclone"cp -vf ./man/exa.1 $ZPFX/share/man/man1; cp -vf completions/exa.zsh _exa" \
atpull"%atclone" pick"bin/exa"
zinit light ogham/exa
# volta: node、yarn、pnpm 等的版本管理
# completion 文件(比如 _volta)只有放在 atclone 中生成才会被安装,更新后需要手动重新安装 `zinit creinstall weineel/zinit-volta`
# !!! turbo 模式,可能会导致 starship 获取版本号等信息失败。
export VOLTA_HOME="$HOME/.volta" && export PATH="$VOLTA_HOME/bin:$PATH"
zinit as"program" pick"volta" \
atclone"curl https://get.volta.sh | bash && volta completions zsh > _volta" \
atpull"curl https://get.volta.sh | bash -s -- --skip-setup && volta completions zsh > _volta" \
run-atpull \
for weineel/zinit-volta
# 像 ls 一样使用 exa, https://github.com/weineel/zsh-exa
# zinit ice has"exa" atinit"AUTOCD=1" # 启用 AUTOCD 不知道其作用,暂不开启
zinit light weineel/zsh-exa
# NOTE: fzf-tab needs to be loaded after compinit, but before plugins which will wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting!!
zinit light Aloxaf/fzf-tab
zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup # 在 tmux 中使用 tmux-popup 显示 fzf-tab 的结果
# zstyle ':fzf-tab:*' fzf-bindings 'tab:accept' # 使用 tab 键接受当前选中的项, 在 tmux 中不生效
zinit light zsh-users/zsh-autosuggestions
zinit light zdharma-continuum/fast-syntax-highlighting
# 命令行输入使用 vi/vim 模式
zinit ice depth=1
zinit light jeffreytse/zsh-vi-mode
ZVM_VI_INSERT_ESCAPE_BINDKEY=jj
# 使用 zsh-z 而不是 autojump
zinit light agkozak/zsh-z
# docker 简写: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/docker
# zinit ice as"completion"
# zinit snippet OMZP::docker/_docker
# oh-my-zsh 插件
zinit snippet OMZP::git
# zsh-history-substring-search - https://github.com/zsh-users/zsh-history-substring-search
zinit wait lucid atload"bindkey '^P' history-substring-search-up;
bindkey '^N' history-substring-search-down" for \
zsh-users/zsh-history-substring-search
# 自定义, 维护在 github https://github.com/weineel/zsh-weineel
zinit light weineel/zsh-weineel
# atuin 放在 fzf、zsh-vi-mode 下面,需要覆盖 ctrl-r 快捷键
zvm_after_init_commands+=(eval "$(atuin init zsh)")
### zinit custom end
# https://github.com/zdharma-continuum/zinit#completions-2
autoload -Uz compinit
compinit
zinit cdreplay -q
##
### custom
##
export PATH=~/.local/bin:$PATH
# generate gitignore
function gi() { curl -sLw "\n" https://www.toptal.com/developers/gitignore/api/$@ ;}
# pipenv
export PIPENV_VENV_IN_PROJECT=1
# pyenv: 管理 python 版本,多版本切换等。
# 先判断安装了 pyenv
if command -v pyenv &> /dev/null; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi
# rust
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
# rust end
# 命令历史的条数
HISTFILE=~/.zsh_history #记录历史命令的文件
HISTSIZE=1000000
# 会保存到历史文件中的命令条数
SAVEHIST=1000000
setopt appendhistory
# sdkman 初始化
# THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh"
###
# 不同主机类型(或使用场景的配置)
###
{{- if eq .hosttag "ps" }}
# inno-lane, 这种简单处理,会导致 shell 启动变慢
eval "$(_INNO_LANE_COMPLETE=zsh_source inno-lane)"
zinit snippet /Users/lijufeng/project/patsnap/inno-lane/zsh-plugin/zsh-inno-lane.plugin.zsh
{{- end }}
###
# 不同操作系统的配置
###
{{- if (and (not (empty .chezmoi.osRelease)) (eq .chezmoi.osRelease.id "ubuntu")) }}
# Ubuntu 暂时使用 vim,因为 nvim 暂时不方便安装 0.8 以上版本
export EDITOR="vim"
ZVM_VI_EDITOR="vim" # zsh-vi-mode 插件, vv 使用的编辑器改为 vim
{{- else }}
# 使用 neovim
export EDITOR="nvim"
alias vim="nvim"
ZVM_VI_EDITOR="nvim" # zsh-vi-mode 插件, vv 使用的编辑器改为 nvim
{{- end }}
{{- if eq .chezmoi.os "darwin" }}
# darwin (macOS)
# brew 镜像
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
{{- else if eq .chezmoi.os "linux" }}
# linux
{{- else }}
# other operating system
{{- end }}