-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc
202 lines (195 loc) · 5.73 KB
/
dot_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
# Enable Powerlevel10k instant prompt[[[1
# 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
# ]]]
# history[[[1
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
setopt share_history # auto write and read
setopt extended_history # record timestamp
setopt hist_ignore_space # ignore commands starting from space
# ]]]
# auto complete, editor, options[[[1
# editor
export EDITOR='vim'
# lowercase matches uppercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' menu select
# auto completion at the beginning
zstyle ':completion:*' insert-tab false
# enable comment
setopt interactive_comments
# enter directory without cd
setopt autocd
# match hidden files
setopt globdots
# ]]]
# keybindings[[[1
# reduce Esc delays to 0.05s
export KEYTIMEOUT=5
# vi keybindings in menu
bindkey -v '^?' backward-delete-char
zmodload zsh/complist
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
# Ctrl+Arrow to jump words
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
# ]]]
# alias[[[1
# save pinky
alias ch=chezmoi
alias cho='chezmoi --source ~/.local/share/chezmoi-private' # o=own
alias cu='tmux split-window -h "yito; read"; checkupdates; paru -Qua --devel' # check updates for Arch repos and AUR
alias lg=lazygit
alias mn=pacman
alias mnn='sudo pacman'
alias nnv=$HOME/.cache/neovim-prerelease/nvim-linux64/bin/nvim
alias ru=paru
alias ruu='paru -Syu --needed linux{,-lts,-zen}{,-headers}'
alias s='sudo '
alias t=tmux
alias uu='sudo pacman -Syu'
alias uuu='sudo pacman -Syu --needed linux{,-lts,-zen}{,-headers}'
alias v=vim
alias x=z
alias xi=zi
# ]]]
# delayed commands[[[1
delayed_commands() {
# PATH
export PATH=~/bin:$PATH
export PATH=~/.local/bin:$PATH
# use exa
if (( $+commands[exa] )); then
alias ls='exa'
fi
# zoxide
if (( $+commands[zoxide] )); then
init_z() {
eval "$(zoxide init zsh)"
}
fi
# thefuck
if (( $+commands[thefuck] )); then
init_fuck(){
eval $(thefuck --alias)
}
fi
# nvm
init_nvm() {
[ -s /usr/share/nvm/init-nvm.sh ] && source /usr/share/nvm/init-nvm.sh
}
# miniconda
init_conda() {
[ -f /opt/miniconda/etc/profile.d/conda.sh ] && source /opt/miniconda/etc/profile.d/conda.sh
}
# lazyload function
lazyload() {
for i in "$@"
do
eval "
$i() {
unfunction $i
eval init_$i
$i \$@
}
"
done
}
lazyload z fuck nvm conda
# lfcd
lfcd () {
tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
rm -f "$tmp"
if [ -d "$dir" ]; then
if [ "$dir" != "$(pwd)" ]; then
cd "$dir"
fi
fi
fi
}
# don't let Home Manager manage shell
[[ -f $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh ]] && source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
}
# ]]]
# load plugins if zinit installed[[[1
if [[ -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
# zinit initialization[[[2
### 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
# ]]]
# plugins[[[2
zinit ice depth=1; zinit light romkatv/powerlevel10k
zinit light romkatv/zsh-defer
zinit wait"1" lucid light-mode for \
blockf \
zsh-users/zsh-completions \
blockf \
spwhitt/nix-zsh-completions \
chisui/zsh-nix-shell \
atinit"zicompinit; zicdreplay" \
zdharma-continuum/fast-syntax-highlighting \
atload"_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions \
kutsan/zsh-system-clipboard \
OMZL::directories.zsh \
OMZP::git
if (( $+commands[fzf] )); then
zinit wait"1" lucid light-mode for \
Aloxaf/fzf-tab \
joshskidmore/zsh-fzf-history-search
# disable sort in git show
zstyle ':completion:complete:git-show:argument-rest' sort false
# increase fzf height
export FZF_TMUX_HEIGHT="90%"
# use tmux popup
zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
fi
# ]]]
# run delayed_commands
zsh-defer -t 0.1 delayed_commands
else
delayed_commands
# completion
autoload -Uz compinit
compinit
# prompt
autoload -Uz promptinit
promptinit
prompt walters
fi
# ]]]
# initialize powerlevel10k[[[1
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# ]]]
# set fold and filetype in vim
# vim: foldmethod=marker foldmarker=[[[,]]] filetype=zsh