-
Notifications
You must be signed in to change notification settings - Fork 1
/
.zshrc.old
283 lines (244 loc) · 8.89 KB
/
.zshrc.old
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
# The following lines were added by compinstall
zstyle :compinstall filename '/home/genograche/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
bindkey -v
# End of lines configured by zsh-newuser-install
## reduce time of escaping vi mode
export KEYTIMEOUT=5
## Exporting some things
export TERM="xterm-256color"
export EDITOR="nvim"
# Created by `pipx` on 2024-01-28 20:06:10
export PATH="$PATH:/home/genograche/.local/bin"
## starshipconfig
export STARSHIP_CONFIG=~/.config/starship/starship.toml
## "nvim" as manpager
export MANPAGER="nvim +Man!"
## setting starship prompt
eval "$(starship init zsh)"
## command completion
zstyle ':completion:*' menu select
zstyle ':completion::complete:*' gain-privileges 1
## historysearch
#autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
#zle -N up-line-or-beginning-search
#zle -N down-line-or-beginning-search
#[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search
#[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search
## prompt theme
#autoload -Uz promptinit
#promptinit
#prompt elite
## 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
## 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
}
cdParentKey() {
pushd ..
zle reset-prompt
print
ls
zle reset-prompt
}
zle -N cdParentKey
zle -N cdUndoKey
bindkey '^[[1;3A' cdParentKey
bindkey '^[[1;3D' cdUndoKey
## 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
## Fish-like syntax highlighting and autosuggestions
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
## Function extract for common file formats
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
else
for n in "$@"
do
if [ -f "$n" ] ; then
case "${n%,}" in
*.cbt|*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
tar xvf "$n" ;;
*.lzma) unlzma ./"$n" ;;
*.bz2) bunzip2 ./"$n" ;;
*.cbr|*.rar) unrar x -ad ./"$n" ;;
*.gz) gunzip ./"$n" ;;
*.cbz|*.epub|*.zip) unzip ./"$n" ;;
*.z) uncompress ./"$n" ;;
*.7z|*.arj|*.cab|*.cb7|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.pkg|*.rpm|*.udf|*.wim|*.xar)
7z x ./"$n" ;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*.cpio) cpio -id < ./"$n" ;;
*.cba|*.ace) unace x ./"$n" ;;
*)
echo "extract: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
IFS=$SAVEIFS
## Alias
# some useful alias
alias history='history 1'
alias inm='sudo systemctl restart NetworkManager'
alias service='sudo systemctl'
alias vizsh='vim $HOME/.zshrc'
alias srczsh='source $HOME/.zshrc'
# 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 pacsy='sudo pacman -Sy' # update only standard pkgs
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='$aurhelper -Qtdq | $aurhelper -Rns -' # remove unused packages, also try > $aurhelper -Qqd | $aurhelper -Rsu --print -
alias pacrm='sudo pacman -Rns' # uninstall package
alias pacin='sudo pacman -S' # install pkg
alias yay='yay -S'
alias pl='$aurhelper -Qs' # list installed package
alias search='$aurhelper -Ss' # list availabe package
alias pc='$aurhelper -Sc' # remove unused cache
# 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'
# 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 stat='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 "
#some scripts
alias wlprop="./.config/hypr/scripts/wlprop"