-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
269 lines (258 loc) · 10.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
259
260
261
262
263
264
265
266
267
268
269
#########################################################################
# FIRST PROMPT LINE
#########################################################################
rosso='\e[1;34m'
NC='\e[0m'
echo -e "${rosso}Debian${NC}" `cat /etc/debian_version` "| ${rosso}ZSH${NC} ${ZSH_VERSION}"
#########################################################################
# ZINIT
#########################################################################
### Added by Zinit's installer
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
print -P "%F{33}▓▒░ %F{220}Installing DHARMA Initiative Plugin Manager (zdharma-continuum/zinit)…%f"
command mkdir -p $HOME/.zinit
command git clone https://github.com/zdharma-continuum/zinit $HOME/.zinit/bin && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%F" || \
print -P "%F{160}▓▒░ The clone has failed.%F"
fi
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
### End of Zinit installer's chunk
#########################################################################
# THEME
#########################################################################
zinit ice depth=1; zinit light romkatv/powerlevel10k
#########################################################################
# PLUGINS
#########################################################################
# AUTOSUGGESTIONS, TRIGGER PRECMD HOOK UPON LOAD
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
zinit ice wait="0a" lucid atload="_zsh_autosuggest_start"
zinit light zsh-users/zsh-autosuggestions
# ENHANCD
zinit ice wait="0b" lucid
zinit light b4b4r07/enhancd
export ENHANCD_FILTER=fzf:fzy:peco
# HISTORY SUBSTRING SEARCHING
zinit ice wait="0b" lucid atload'bindkey "$terminfo[kcuu1]" history-substring-search-up; bindkey "$terminfo[kcud1]" history-substring-search-down'
zinit light zsh-users/zsh-history-substring-search
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
# TAB COMPLETIONS
zinit ice wait="0b" lucid blockf
zinit light zsh-users/zsh-completions
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' menu select=2
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*:descriptions' format '-- %d --'
zstyle ':completion:*:processes' command 'ps -au$USER'
zstyle ':completion:complete:*:options' sort false
zstyle ':fzf-tab:complete:_zlua:*' query-string input
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w"
zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap
zstyle ":completion:*:git-checkout:*" sort false
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# FZF
zinit ice from="gh-r" as="command" bpick="*linux_amd64*"
zinit light junegunn/fzf
# FZF BYNARY AND TMUX HELPER SCRIPT
zinit ice lucid wait'0c' as="command" id-as="junegunn/fzf-tmux" pick="bin/fzf-tmux"
zinit light junegunn/fzf
# BIND MULTIPLE WIDGETS USING FZF
zinit ice lucid wait'0c' multisrc"shell/{completion,key-bindings}.zsh" id-as="junegunn/fzf_completions" pick="/dev/null"
zinit light junegunn/fzf
# FZF-TAB
zinit ice wait="1" lucid
zinit light Aloxaf/fzf-tab
# SAD
zinit ice from="gh-r" as="command"
zinit light ms-jpq/sad
# SYNTAX HIGHLIGHTING
zinit ice wait="0c" lucid atinit="zpcompinit;zpcdreplay"
zinit light zdharma-continuum/fast-syntax-highlighting
# EXA
zinit ice wait="2" lucid from="gh-r" as="program" mv="bin/exa* -> exa"
zinit light ogham/exa
zinit ice wait blockf atpull'zinit creinstall -q .'
# DELTA
zinit ice lucid wait="0" as="program" from="gh-r" bpick="*amd64.deb" pick="usr/bin/delta"
zinit light dandavison/delta
# DUST
zinit ice wait="2" lucid from="gh-r" as="program" bpick="*amd64.deb" pick="usr/bin/dust" atload="alias du=dust"
zinit light bootandy/dust
# BOTTOM
zinit ice wait="2" lucid from="gh-r" as="program" bpick='*.deb' pick="usr/bin/btm"
zinit light ClementTsang/bottom
# DUF
zinit ice lucid wait="0" as="program" from="gh-r" bpick='*linux_amd64.deb' pick="usr/bin/duf" atload="alias df=duf"
zinit light muesli/duf
# BAT
zinit ice from="gh-r" as="program" pick="usr/bin/bat" bpick="*amd64.deb" atload="alias cat=bat"
zinit light sharkdp/bat
# BAT-EXTRAS
zinit ice lucid wait="1" as="program" pick="src/batgrep.sh"
zinit ice lucid wait="1" as="program" pick="src/batdiff.sh"
zinit light eth-p/bat-extras
alias rg=batgrep.sh
alias bd=batdiff.sh
alias man=batman.sh
# RIPGREP
zinit ice from="gh-r" as="program" bpick="*amd64.deb" pick="usr/bin/rg"
zinit light BurntSushi/ripgrep
# NEOVIM
zinit ice from="gh-r" as="program" bpick="*linux64.tar.gz" ver="stable" pick="nvim-linux64/bin/nvim"
zinit light neovim/neovim
# FORGIT
zinit ice wait lucid
zinit load wfxr/forgit
# LAZYGIT
zinit ice lucid wait="0" as="program" from="gh-r" bpick="*Linux_x86_64*" pick="lazygit" atload="alias lg='lazygit'"
zinit light jesseduffield/lazygit
# LAZYDOCKER
zinit ice lucid wait="0" as="program" from="gh-r" bpick="*Linux_x86_64*" pick="lazydocker"
zinit light jesseduffield/lazydocker
# FD
zinit ice as="command" from="gh-r" bpick="*amd64.deb" pick="usr/bin/fd"
zinit light sharkdp/fd
# ZSH MANYDOTS MAGIC
zinit ice depth"1" wait lucid pick"manydots-magic" compile"manydots-magic"
zinit light knu/zsh-manydots-magic
# XURLS
zinit ice as="program" from="gh-r" mv="xurls* -> xurls" pick="xurls"
zinit light mvdan/xurls
# PRETTYPING
zinit ice lucid wait="" as="program" pick="prettyping" atload="alias ping=prettyping"
zinit load denilsonsa/prettyping
# ASDF
# asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
# asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
zinit ice lucid wait="0" pick="asdf.sh"
zinit light asdf-vm/asdf
# CROC
zinit ice lucid wait="0" as="program" from="gh-r" bpick="*64bit*"
zinit light schollz/croc
# ERDTREE
zinit ice lucid wait"0" as"program" from"gh-r"
zinit light solidiquis/erdtree
#########################################################################
# HISTORY
#########################################################################
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zhistory"
HISTSIZE=290000
SAVEHIST=$HISTSIZE
#########################################################################
# SETOPT
#########################################################################
setopt extended_history # record timestamp of command in HISTFILE
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_all_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
setopt inc_append_history # add commands to HISTFILE in order of execution
setopt share_history # share command history data
setopt always_to_end # cursor moved to the end in full completion
setopt hash_list_all # hash everything before completion
# setopt completealiases # complete alisases
setopt always_to_end # when completing from the middle of a word, move the cursor to the end of the word
setopt complete_in_word # allow completion from within a word/phrase
setopt nocorrect # spelling correction for commands
setopt list_ambiguous # complete as much of a completion until it gets ambiguous.
setopt nolisttypes
setopt listpacked
setopt automenu
unsetopt BEEP
setopt emacs
chpwd() {
set -- "$(git rev-parse --show-toplevel 2> /dev/null)"
# If cd'ing into a git working copy and not within the same working copy
if [ -n "$1" ] && [ "$1" != "$vc_root" ]; then
vc_root="$1"
git fetch
fi
# ls inside folder after cd
exa --git --icons --classify --group-directories-first --time-style=long-iso --group --color-scale
}
#########################################################################
# ENV VARIABLE
#########################################################################
export EDITOR='nvim'
export VISUAL=$EDITOR
export PAGER='less'
export SHELL='/bin/zsh'
export LANG='it_IT.UTF-8'
export LC_ALL='it_IT.UTF-8'
export BAT_THEME="gruvbox-dark"
if [[ ! $(tmux ls) ]] 2> /dev/null; then
tmux new -s λ
fi
#########################################################################
# COLORING
#########################################################################
autoload colors && colors
#########################################################################
# ALIASES
#########################################################################
source $HOME/.zsh_aliases
#########################################################################
# FANCY-CTRL-Z
#########################################################################
function fg-fzf() {
job="$(jobs | fzf -0 -1 | sed -E 's/\[(.+)\].*/\1/')" && echo '' && fg %$job
}
function fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER=" fg-fzf"
zle accept-line -w
else
zle push-input -w
zle clear-screen -w
fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z
#########################################################################
# FZF SETTINGS
#########################################################################
export FZF_DEFAULT_OPTS="
--ansi
--layout=default
--info=inline
--height=50%
--multi
--preview-window=right:50%
--preview-window=sharp
--preview-window=cycle
--preview '([[ -f {} ]] && (bat --style=numbers --color=always --theme=gruvbox-dark --line-range :500 {} || cat {})) || ([[ -d {} ]] && (tree -C {} | less)) || echo {} 2> /dev/null | head -200'
--prompt='λ -> '
--pointer='|>'
--marker='✓'
--bind 'ctrl-e:execute(nvim {} < /dev/tty > /dev/tty 2>&1)' > selected
--bind 'ctrl-v:execute(code {+})'"
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules}/*" 2> /dev/null'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
#########################################################################
# FZF-GC-PROJECT
#########################################################################
# Thanks to sei40kr/zsh-fzf-gcloud
function fzf-gcloud-config-set-project() {
local project="$(gcloud projects list |
fzf --header-lines=1 --reverse |
awk '{ print $1 }')"
if [[ -n "$project" ]]; then
gcloud config set project "$project"
fi
}
zle -N fzf-gcloud-config-set-project
bindkey '^G' fzf-gcloud-config-set-project
#########################################################################
# PATH
#########################################################################
export PATH=$PATH:/usr/local/go/bin:~/.local/bin:~/bin
#########################################################################
# P10K SETTINGS
#########################################################################
[[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh