-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.zshrc
327 lines (269 loc) · 9.69 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
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
# -- INIT ----------------------------------------------------------------------
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 [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.zinit/bin" && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# -- PLUGINS -------------------------------------------------------------------
zinit ice depth=1
zinit light romkatv/powerlevel10k
zinit wait lucid light-mode for \
ver="dev" \
atload'bindkey "^u" dotbare-transform;
bindkey "^d" dotbare-fedit' \
kazhala/dotbare \
kazhala/bmux \
kazhala/dump-cli \
https://github.com/kazhala/scripts/blob/master/shell/fbookmark \
https://raw.githubusercontent.com/aws/aws-cli/develop/bin/aws_zsh_completer.sh \
atload'bindkey -M vicmd "k" history-substring-search-up;
bindkey -M vicmd "j" history-substring-search-down' \
zsh-users/zsh-history-substring-search \
atload'_zsh_autosuggest_start;
unset ZSH_AUTOSUGGEST_USE_ASYNC;
bindkey -v "^ " autosuggest-accept' \
zsh-users/zsh-autosuggestions \
atinit'ZINIT[COMPINIT_OPTS]=-C;
zicompinit;
zicdreplay;
_dotbare_completion_cmd;
complete -o nospace -C "$(which terraform)" terraform;
eval "$(register-python-argcomplete pipx)"' \
atload"FAST_HIGHLIGHT[chroma-man]=" \
zdharma-continuum/fast-syntax-highlighting
# -- SETTINGS -----------------------------------------------------------------
# history
HISTSIZE=50000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_verify
setopt share_history
# completion
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.cache/zsh/completion
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle -e ':completion:*:approximate:*' \
max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
zstyle ':completion:*' menu select
zstyle ':completion:*' special-dirs true
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
expand-or-complete-with-dots() {
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
zmodload zsh/complist
LISTMAX=9999
# edit current line in vim
autoload -Uz edit-command-line
zle -N edit-command-line
# comments and process sub in propmt
setopt interactive_comments
setopt prompt_subst
# directory stack
setopt pushd_ignore_dups
setopt auto_pushd
setopt pushdminus
# misc
setopt nobeep
setopt ignoreeof
# -- PATH ----------------------------------------------------------------------
export PATH="$HOME/bin:/usr/local/bin:$HOME/.local/bin:$PATH"
export PATH="$HOME/Programming/scripts/shell:$PATH"
export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/cargo/bin:$PATH"
# -- ALIASES -------------------------------------------------------------------
alias vim="nvim"
alias vimf="nvim '+Dashboard | FloatermNew vifm'"
alias py3="python3"
alias tree="tree -I '.git|node_modules|bower_components|.DS_Store|build'"
alias ag="ag -p ~/.ignore"
alias lg="lazygit"
alias ll="lsd -lAF --group-dirs first"
alias ls="lsd"
alias ..="cd .."
alias mv="mv -v"
alias cp="cp -v"
alias rm="rm -v"
alias grep="grep --color=auto"
alias fs="bmux"
alias tf="terraform"
alias svenv="source venv/bin/activate"
# -- SYSTEM ENV ----------------------------------------------------------------
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export EDITOR=nvim
export TERM="xterm-256color"
export COLORTERM="truecolor"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
# -- MISC ----------------------------------------------------------------------
if [[ ${OSTYPE} =~ "linux-gnu" ]] && [[ $(lsb_release -ds) =~ "Ubuntu" ]]; then
if [[ "${WSL_DISTRO_NAME}" =~ Ubuntu-.* ]]; then
export OS_DISTRO="WSL_UBUNTU"
else
export OS_DISTRO="UBUNTU"
fi
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
export PATH="$HOME/.yarn/bin:$PATH"
elif [[ ${OSTYPE} =~ "darwin" ]]; then
export OS_DISTRO="MACOS"
fi
export GRIPHOME="${XDG_CONFIG_HOME:-$HOME/.config}/grip"
export FBOOKMARK_LOCATION="${XDG_CONFIG_HOME:-$HOME/.config}/fbookmark"
export CARGO_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/cargo"
export RUSTUP_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/rustup"
export LS_COLORS="$(vivid generate nord)"
# -- BMUX ----------------------------------------------------------------------
export BMUX_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/bmux"
export BMUX_ACTIVE_SYMBOL=""
export BMUX_INACTIVE_SYMBOL=""
export BMUX_ACTIVE_COLOR="32"
export BMUX_TREE_SYMBOL=""
export BMUX_3_WEB='05c6,210x63,0,0{150x63,0,0,56,59x63,151,0[59x31,151,0,57,59x31,151,32,58]}'
export BMUX_3_VS='3807,210x63,0,0[210x45,0,0,1,210x17,0,46{105x17,0,46,3,104x17,106,46,4}]'
export BMUX_CODE='578a,239x62,0,0[239x45,0,0,30,239x16,0,46,31]'
# -- DUMP ----------------------------------------------------------------------
export DUMP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/dump/trash"
export DUMP_LOG="${XDG_DATA_HOME:-$HOME/.local/share}/dump/log"
# -- LESS ----------------------------------------------------------------------
export LESSHISTFILE=-
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
# -- DOTBARE -------------------------------------------------------------------
export DOTBARE_DIR="$HOME/.cfg/"
export DOTBARE_TREE="$HOME"
export DOTBARE_BACKUP="${XDG_DATA_HOME:-$HOME/.local/share}/dotbare"
export DOTBARE_FZF_DEFAULT_OPTS="--preview-window=right:65%"
export DOTBARE_KEY="
--bind=alt-a:toggle-all
--bind=alt-w:jump
--bind=alt-0:top
--bind=alt-s:toggle-sort
--bind=alt-t:toggle-preview
"
# -- FZF ----------------------------------------------------------------------
_gen_fzf_default_opts() {
local color00='#2E3440'
local color01='#3B4252'
local color02='#434C5E'
local color03='#4C566A'
local color04='#D8DEE9'
local color05='#E5E9F0'
local color06='#ECEFF4'
local color07='#8FBCBB'
local color08='#BF616A'
local color09='#D08770'
local color0A='#EBCB8B'
local color0B='#A3BE8C'
local color0C='#88C0D0'
local color0D='#81A1C1'
local color0E='#B48EAD'
local color0F='#5E81AC'
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS
--color=bg+:$color00,bg:$color00,spinner:$color0C,hl:$color0D
--color=fg:$color04,header:$color0D,info:$color0A,pointer:$color0C
--color=marker:$color0C,fg+:$color06,prompt:$color0A,hl+:$color0D
--height 100% --layout=reverse --border --cycle --info=inline
--bind=ctrl-d:preview-page-down
--bind=ctrl-u:preview-page-up
"
}
_gen_fzf_default_opts
export FZF_DEFAULT_COMMAND="fd --type f"
export FZF_ALT_C_COMMAND="fd --type d"
export FZF_ALT_C_OPTS="--preview 'tree -L 1 -C --dirsfirst {} | head -200'"
# Use fd to generate auto completion
_fzf_compgen_path() {
fd --hidden --follow --exclude ".git" . "$1"
}
_fzf_compgen_dir() {
fd --type d --hidden --follow --exclude ".git" . "$1"
}
# activate fzf keybindings
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh ] && source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh
export FZF_COMPLETION_TRIGGER=''
export FZF_PREVIEW_COMMAND='cat {}'
# -- FUNCTIONS -----------------------------------------------------------------
take () {
mkdir -p $@ && cd ${@:$#}
}
_run_fm() {
fm
BUFFER=
zle accept-line
}
_run_ffd_d() {
local result
result="$(ffd --hidden --dir)"
[[ -d "${result}" ]] && \
cd "${result}"
BUFFER=
zle accept-line
}
pullhead () {
git pull origin "$(git rev-parse --abbrev-ref HEAD)"
}
pushhead() {
git push origin "$(git rev-parse --abbrev-ref HEAD)" -u
}
# -- KEYBINDING ----------------------------------------------------------------
bindkey -v
# ci", ci', ci`, di", etc
autoload -U select-quoted
zle -N select-quoted
for m in visual viopp; do
for c in {a,i}{\',\",\`}; do
bindkey -M $m $c select-quoted
done
done
# ci{, ci(, ci<, di{, etc
autoload -U select-bracketed
zle -N select-bracketed
for m in visual viopp; do
for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
bindkey -M $m $c select-bracketed
done
done
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect '^o' accept-and-infer-next-history
bindkey "^p" up-line-or-history
bindkey "^n" down-line-or-history
bindkey -M vicmd v edit-command-line
bindkey "^?" backward-delete-char
bindkey '^T' fzf-completion
bindkey '^I' $fzf_default_completion
zle -N fm-invoke _run_fm
bindkey "^g" fm-invoke
zle -N ffd-d-invoke _run_ffd_d
bindkey "\ed" ffd-d-invoke
# -- FINAL ---------------------------------------------------------------------
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh