-
Notifications
You must be signed in to change notification settings - Fork 2
/
.zshrc
378 lines (323 loc) · 13.7 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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# ╔═╗╔═╗╦ ╦╦═╗╔═╗ ╔═╗╔═╗╔╗╔╔═╗╦╔═╗
# ╔═╝╚═╗╠═╣╠╦╝║ ║ ║ ║║║║╠╣ ║║ ╦
# ╚═╝╚═╝╩ ╩╩╚═╚═╝ ╚═╝╚═╝╝╚╝╚ ╩╚═╝
# ┬ ┬┌─┐┬─┐┌─┐
# └┐┌┘├─┤├┬┘└─┐
# └┘ ┴ ┴┴└─└─┘
export VISUAL="${EDITOR}"
export TERM="xterm-256color"
### Shell integrations
##conda
eval "$(/home/genograche/miniforge3/bin/conda shell.zsh hook)"
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/genograche/miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/genograche/miniforge3/etc/profile.d/conda.sh" ]; then
. "/home/genograche/miniforge3/etc/profile.d/conda.sh"
else
export PATH="/home/genograche/miniforge3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
## setting starship prompt
export STARSHIP_CONFIG=~/.config/starship/starship.toml
eval "$(starship init zsh)"
## fzf
eval "$(fzf --zsh)"
## exporting some variables
export LIBVIRT_DEFAULT_URI='qemu:///system'
export MANPAGER="nvim +Man!"
export EDITOR='nvim'
export TERM='alacritty'
export TERMINAL='alacritty'
export BROWSER='firefox'
export FILEMANAGER='Thunar'
export HISTORY_IGNORE="(ls|cd|pwd|exit|sudo reboot|history|cd -|cd ..)"
if [ -d "$HOME/.local/bin" ] ;
then PATH="$HOME/.local/bin:$PATH"
fi
## nix path
#export PATH="$HOME/.nix-profile/bin:$PATH"
# ┬ ┌─┐┌─┐┌┬┐ ┌─┐┌┐┌┌─┐┬┌┐┌┌─┐
# │ │ │├─┤ ││ ├┤ ││││ ┬││││├┤
# ┴─┘└─┘┴ ┴─┴┘ └─┘┘└┘└─┘┴┘└┘└─┘
autoload -Uz compinit
for dump in ~/.config/zsh/zcompdump(N.mh+24); do
compinit -d ~/.config/zsh/zcompdump
done
compinit -C -d ~/.config/zsh/zcompdump
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
precmd () { vcs_info }
_comp_options+=(globdots)
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} 'ma=48;5;197;1'
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*:warnings' format "%B%F{red}No matches for:%f %F{magenta}%d%b"
zstyle ':completion:*:descriptions' format '%F{yellow}[-- %d --]%f'
zstyle ':vcs_info:*' formats ' %B%s-[%F{magenta}%f %F{yellow}%b%f]-'
# ┬ ┬┌─┐┬┌┬┐┬┌┐┌┌─┐ ┌┬┐┌─┐┌┬┐┌─┐
# │││├─┤│ │ │││││ ┬ │││ │ │ └─┐
# └┴┘┴ ┴┴ ┴ ┴┘└┘└─┘ ─┴┘└─┘ ┴ └─┘
expand-or-complete-with-dots() {
echo -n "\e[31m…\e[0m"
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
# ┬ ┬┬┌─┐┌┬┐┌─┐┬─┐┬ ┬
# ├─┤│└─┐ │ │ │├┬┘└┬┘
# ┴ ┴┴└─┘ ┴ └─┘┴└─ ┴
HISTFILE=~/.config/zsh/zhistory
HISTSIZE=5000
SAVEHIST=$HISTSIZE
HISTDUP=erase
#setopt appendhistory #append any cmds to zsh shell hisfile
setopt sharehistory #share history through all zsh sessions
setopt hist_ignore_space #will not save a command to history if it precedes with a space
# ┌─┐┌─┐┬ ┬ ┌─┐┌─┐┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
# ┌─┘└─┐├─┤ │ │ ││ ││ │ │├─┘ │ ││ ││││└─┐
# └─┘└─┘┴ ┴ └─┘└─┘└─┘┴─┘ └─┘┴ ┴ ┴└─┘┘└┘└─┘
setopt AUTOCD # change directory just by typing its name
setopt PROMPT_SUBST # enable command substitution in prompt
setopt MENU_COMPLETE # Automatically highlight first element of completion menu
setopt LIST_PACKED # The completion menu takes less space.
setopt AUTO_LIST # Automatically list choices on ambiguous completion.
setopt HIST_IGNORE_DUPS # Do not write events to history that are duplicates of previous events
setopt HIST_FIND_NO_DUPS # When searching history don't display results already cycled through twice
setopt COMPLETE_IN_WORD # Complete from both ends of a word.
# ┌┬┐┬ ┬┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┌┬┐
# │ ├─┤├┤ ├─┘├┬┘│ ││││├─┘ │
# ┴ ┴ ┴└─┘ ┴ ┴└─└─┘┴ ┴┴ ┴
#function dir_icon {
# if [[ "$PWD" == "$HOME" ]]; then
# echo "%B%F{black}%f%b"
# else
# echo "%B%F{cyan}%f%b"
# fi
#}
#
#PS1='%B%F{blue}%f%b %B%F{magenta}%n%f%b $(dir_icon) %B%F{red}%~%f%b${vcs_info_msg_0_} %(?.%B%F{green}.%F{red})%f%b '
# ┌─┐┬ ┬ ┬┌─┐┬┌┐┌┌─┐
# ├─┘│ │ ││ ┬││││└─┐
# ┴ ┴─┘└─┘└─┘┴┘└┘└─┘
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
## pacman -F "command not found" handler
function command_not_found_handler {
local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m'
printf 'zsh: command not found: %s\n' "$1"
local entries=(
${(f)"$(/usr/bin/pacman -F --machinereadable -- "/usr/bin/$1")"}
)
if (( ${#entries[@]} ))
then
printf "${bright}$1${reset} may be found in the following packages:\n"
local pkg
for entry in "${entries[@]}"
do
# (repo package version file)
local fields=(
${(0)entry}
)
if [[ "$pkg" != "${fields[2]}" ]]
then
printf "${purple}%s/${bright}%s ${green}%s${reset}\n" "${fields[1]}" "${fields[2]}" "${fields[3]}"
fi
printf ' /%s\n' "${fields[4]}"
pkg="${fields[2]}"
done
fi
return 127
}
## Clear the backbuffer using a key binding
function clear-screen-and-scrollback() {
printf '\x1Bc'
zle clear-screen
}
zle -N clear-screen-and-scrollback
bindkey '^L' clear-screen-and-scrollback
## Search history
bindkey '^p' history-substring-search-up
bindkey '^n' history-substring-search-down
zle -N clear-screen-and-scrollback
bindkey '^L' clear-screen-and-scrollback
## remapping run-help to help
autoload -Uz run-help
(( ${+aliases[run-help]} )) && unalias run-help
alias help=run-help
autoload -Uz run-help-git run-help-ip run-help-openssl run-help-p4 run-help-sudo run-help-svk run-help-svn
## Filemanger like keybinds
cdUndoKey() {
popd
zle reset-prompt
print
ls
zle reset-prompt
}
## Vim like keybinds
bindkey -v
bindkey "^A" vi-beginning-of-line
bindkey "^E" vi-end-of-line
cdParentKey() {
pushd ..
zle reset-prompt
print
ls
zle reset-prompt
}
zle -N cdParentKey
zle -N cdUndoKey
bindkey '^[[1;3A' cdParentKey
bindkey '^[[1;3D' cdUndoKey
# ┌─┐┬ ┬┌─┐┌┐┌┌─┐┌─┐ ┌┬┐┌─┐┬─┐┌┬┐┬┌┐┌┌─┐┬ ┌─┐ ┌┬┐┬┌┬┐┬ ┌─┐
# │ ├─┤├─┤││││ ┬├┤ │ ├┤ ├┬┘│││││││├─┤│ └─┐ │ │ │ │ ├┤
# └─┘┴ ┴┴ ┴┘└┘└─┘└─┘ ┴ └─┘┴└─┴ ┴┴┘└┘┴ ┴┴─┘└─┘ ┴ ┴ ┴ ┴─┘└─┘
#function xterm_title_precmd () {
# print -Pn -- '\e]2;%n@%m %~\a'
# [[ "$TERM" == 'screen'* ]] && print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-}\e\\'
#}
#
#function xterm_title_preexec () {
# print -Pn -- '\e]2;%n@%m %~ %# ' && print -n -- "${(q)1}\a"
# [[ "$TERM" == 'screen'* ]] && { print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-} %# ' && print -n -- "${(q)1}\e\\"; }
#}
#
#if [[ "$TERM" == (kitty*|alacritty*|termite*|gnome*|konsole*|kterm*|putty*|rxvt*|screen*|tmux*|xterm*) ]]; then
# add-zsh-hook -Uz precmd xterm_title_precmd
# add-zsh-hook -Uz preexec xterm_title_preexec
#fi
# ┌─┐┬ ┬┌─┐┌─┐
# ├─┤│ │├─┤└─┐
# ┴ ┴┴─┘┴┴ ┴└─┘
alias mirrors="sudo reflector --verbose --latest 5 --country 'United States' --age 6 --sort rate --save /etc/pacman.d/mirrorlist"
alias grub-update="sudo grub-mkconfig -o /boot/grub/grub.cfg"
alias mkinit-update="sudo mkinitcpio -P"
alias mantenimiento="yay -Sc && sudo pacman -Scc"
alias purga="sudo pacman -Rns $(pacman -Qtdq) ; sudo fstrim -av"
#alias update="paru -Syu --nocombinedupgrade"
alias vm-on="sudo systemctl start libvirtd.service"
alias vm-off="sudo systemctl stop libvirtd.service"
alias musica="ncmpcpp"
# some useful alias
alias history='history 1'
alias inm='sudo systemctl restart NetworkManager'
alias service='sudo systemctl'
alias vizsh='nvim $HOME/.zshrc'
alias srczsh='source $HOME/.zshrc'
alias visu='sudo nvim'
# Aurhelper
aurhelper="yay"
# Changing ls to eza
alias la='eza -a --icons=auto --color=always --group-directories-first' # all files and dirs
alias l='eza -lh --icons=auto' # long list
alias ls='eza -1 --icons=auto' # short list
alias ll='eza -lha --icons=auto --sort=name --group-directories-first' # long list all
alias l.='eza -a --icons=auto | grep -E "^\."' # hidden files only
alias ld='eza -lhD --icons=auto' # long list dirs
alias lt='eza -aT --color=always --group-directories-first' # tree listing
# pacman and yay
alias update='sudo pacman -Syu' # Refresh pkglist & update standard pkgs
alias fullupdate='$aurhelper -Syu' # update standard pkgs and AUR pkgs (aurhelper)
alias parsua='$aurhelper -Sua' # update only AUR pkgs (aurhelper)
alias unlock='sudo rm /var/lib/pacman/db.lck' # remove pacman lock
alias cleanup='sudo pacman -Rns $(pacman -Qtdq) ; sudo fstrim -av' # remove unused packages
alias cleanup1='$aurhelper -Qtdq | $aurhelper -Rns -' # remove unused packages
#alias cleanup="$aurhelper -Qqd | $aurhelper -Rsu --print -" # remove unused packages
alias pacrm='sudo pacman -Rns' # uninstall package
alias pacin='sudo pacman -S' # install pkg
alias pl='$aurhelper -Qs' # list installed package
alias search='$aurhelper -Ss' # list availabe package
alias pc='$aurhelper -Sc' # remove unused cache
alias ruk0='sudo paccache -ruk0' # remove uninstalled pkg cache using paccache
# Handy change dir shortcuts
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'
# Always mkdir a path (this doesn't inhibit functionality to make a single dir)
alias mkdir='mkdir -p'
# Get cpu freq
alias cpufreq='sudo auto-cpufreq --stats'
# Fixes "Error opening terminal: xterm-kitty" when using the default kitty term to open some programs through ssh
#alias ssh='alacritty ssh'
# Code editors
alias vim="nvim"
alias vc='sublime' # gui code editor
alias em="/usr/bin/emacs -nw"
alias emacs="emacsclient -c -a 'emacs'"
alias rem="killall emacs || echo 'Emacs server not running'; /usr/bin/emacs --daemon"
# get fastest mirrors
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist"
alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist"
alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist"
# Colorize grep output (good for log files)
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
# adding flags
alias df='df -h' # human-readable sizes
alias free='free -m' # show sizes in MB
# processes
alias psa="ps auxf"
alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e"
alias psmem='ps auxf | sort -nr -k 4'
alias pscpu='ps auxf | sort -nr -k 3'
# git
alias addup='git add -u'
alias addall='git add .'
alias branch='git branch'
alias checkout='git checkout'
alias clone='git clone'
alias commit='git commit -am'
alias fetch='git fetch'
alias pull='git pull origin'
alias push='git push origin'
alias gstat='git status' # 'status' is protected name so using 'stat' instead
alias tag='git tag'
alias newtag='git tag -a'
# get error messages from journalctl
alias jctl="journalctl -p 3 -xb"
# gpg encryption
# verify signature for isos
alias gpg-check="gpg2 --keyserver-options auto-key-retrieve --verify"
# receive the key of a developer
alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys"
# Play audio files in current dir by type
alias playwav='vlc *.wav'
alias playogg='vlc *.ogg'
alias playmp3='vlc *.mp3'
# Play video files in current dir by type
alias playavi='vlc *.avi'
alias playmov='vlc *.mov'
alias playmp4='vlc *.mp4'
# switch between shells
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'"
alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'"
#to make alias work after sudo
alias sudo="sudo "
alias gparted="sudo -E gparted"
#vpn
alias pvpn="sudo openvpn /etc/openvpn/protonvpn/jp-free-305010.protonvpn.udp.ovpn"
#systeminfo
alias raminfo="sudo dmidecode --type=Memory Device"
#some scripts
alias wlprop="./.config/hypr/scripts/wlprop"
#conda
alias cdps="cd ~/Projects/siesta/"
alias cdas="conda activate siesta"
alias cdd="conda deactivate"
# ┌─┐┬ ┬┌┬┐┌─┐ ┌─┐┌┬┐┌─┐┬─┐┌┬┐
# ├─┤│ │ │ │ │ └─┐ │ ├─┤├┬┘ │
# ┴ ┴└─┘ ┴ └─┘ └─┘ ┴ ┴ ┴┴└─ ┴
# $HOME/.local/bin/colorscript -r