-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zsh_aliases.sh
455 lines (368 loc) · 11.2 KB
/
.zsh_aliases.sh
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
alias zshconfig="vim ~/.zsh_aliases.sh && source ~/.zshrc"
alias pm="yay -S"
alias reloadzsh="source ~/.zshrc"
alias cleanpacman="sudo ~/cleanpacman.sh"
alias sctl="sudo systemctl"
alias addkey="gpg --recv-key"
alias py="python3"
alias tn="ping 8.8.8.8"
alias cp="rsync --progress -ravze ssh"
alias ..="cd .."
alias top="htop"
alias x+="chmod +x"
alias cls="clear"
alias suspend="sudo systemctl suspend"
alias pip3="sudo python3 -m pip"
alias condapip="sudo ~/anaconda3/bin/pip"
alias 757="sudo chmod -R 757"
alias q="exit"
alias pyc="ipython"
alias pmn='sudo pacman'
alias mountwin='sudo mount /dev/sda3 /run/media/tushar/OS && sudo mount /dev/sda8 /run/media/tushar/DATA'
alias umountwin='sudo umount /dev/sda3 && sudo umount /dev/sda8'
alias code='/usr/bin/code-oss --force-device-scale-factor=1 --ignore-gpu-blocklist --enable-gpu-rasterization --enable-oop-rasterization --unity-launch --no-sandbox -n .'
alias seed='~/seed.py'
alias pullhead='git pull origin $(git rev-parse --abbrev-ref HEAD)'
#alias gitu='gitbackup'
alias ls="lsd --group-dirs first"
alias myip="ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"
alias npmi="sudo npm i"
alias img="gpicview"
alias -g clip="xclip -sel clip"
alias gitc="git checkout"
# alias portsl="sudo lsof -i -P -n | grep LISTEN"
alias rmrf="rm -Rf"
alias sql="mysql -s -t --prompt='sql > '"
alias logout="qdbus org.kde.ksmserver /KSMServer logout 0 3 3"
alias performance="sudo cpupower frequency-set -g performance"
alias powersave="sudo cpupower frequency-set -g powersave"
alias rem="notify-send"
alias downloadsubs="py /home/tushar/download_en_subs.py -d"
alias backup_dotfiles="sh /home/tushar/backup_dotfiles.sh"
alias pull="adb-sync -R -n"
alias push="adb-sync -n"
alias rpi="ssh [email protected]"
# FUNCTIONS
function prepfakecam(){
sudo modprobe -r -f v4l2loopback;
sudo modprobe v4l2loopback devices=1 video_nr=2 card_label="USB2.0 VGA WebCam" exclusive_caps=1;
}
function jpgcompress(){
convert $1 -quality 50 -resize 1024x "compressed_$1"
}
function yt(){
filename="$(echo "$HOME/t/v/yt/$(yttitle $1)" | cut -f 1 -d '.').mp4";
echo $filename;
if [ -f "$filename" ]; then
mpv "$filename";
else
(cd $HOME/t/v/yt && youtube-dl --write-auto-sub --skip-download $1&)
mpv --stream-record=$filename --ytdl-format="(best[height<=$2]/bestvideo+bestaudio)" "$1";
fi
}
function yttitle(){
# curl "$1" -so - | grep -iPo '(?<=<title>)(.*)(?=</title>)' | recode html..ascii;
youtube-dl "$1" --get-filename;
}
function gitnewbranch() {
git checkout --orphan "$1";
git rm --cached -r .;
}
function ad() {
aria2c -c --max-connection-per-server=16 --split=16 --min-split-size=1M --human-readable=true "${1}";
rem "$(basename "${1}") download complete";
}
function remat() {
echo "notify-send "${0}"" | at ${1};
}
#function cd() {
# if [ "$#" = "0" ]
# then
# pushd ${HOME} > /dev/null
# elif [ -f "${1}" ]
# then
# ${EDITOR} ${1}
# else
# pushd "$1" > /dev/null
# fi
#}
function bd(){
if [ "$#" = "0" ]
then
popd > /dev/null
else
for i in $(seq ${1})
do
popd > /dev/null
done
fi
}
function coli {
g++ -Wfatal-errors -w -o $1 "$1.cpp" && echo "compiled and linked ./$1";
}
function coliru {
g++ -Wfatal-errors -w -o $1 "$1.cpp" && ./"$1";
}
function b64decode {
echo $1 | base64 --decode;
}
function adurllist {
aria2c -c --dir=./ --input-file=$1 --max-concurrent-downloads=1 --connect-timeout=60 --max-connection-per-server=16 --split=16 --min-split-size=1M --human-readable=true --download-result=full --file-allocation=none
}
function webcamrecord144 {
ffmpeg -f v4l2 -framerate 30 -video_size 176x144 -i /dev/video0 $1;
}
function webcamrecord240 {
ffmpeg -f v4l2 -framerate 30 -video_size 426x240 -i /dev/video0 $1;
}
function webcamrecord360 {
ffmpeg -f v4l2 -framerate 15 -video_size 640x360 -i /dev/video0 $1;
}
function fakewebcam {
#modprobe -n --first-time v4l2loopback;
prepfakecam;
#sudo ffmpeg -ss 4 -stream_loop -1 -re -i $1 -vf format=yuv420p -f v4l2 /dev/video2;
sudo ffmpeg -stream_loop -1 -re -i $1 -vf format=yuv420p -f v4l2 /dev/video2;
}
function remat {
echo "notify-send -t 5000 $1" | at $2 > /dev/null 2>&1;
}
function prepadb {
sudo adb kill-server;
sudo adb start-server;
adb devices;
}
function open {
xdg-open $1 > /dev/null 2>&1
}
function gitu {
git rm --cached `git status | grep deleted | sed 's#^.*:##'` &>/dev/null
git add .
if [ $# -eq 1 ]
then
git commit -m $1
else
git commit -m "tushar $(date +"%T")";
fi
git push origin $(git rev-parse --abbrev-ref HEAD)
}
function gcln {
#https://github.com/sigoa/krunner-bridge
tmp="$(/bin/python3 /home/tushar/src/py/gcln.py $1)"
# IFS=', ' read -r -a array <<< "$tmp"
# if ["${array[2]}" = "0"]
# then
# echo "${array[0]}"
# echo "${array[1]}"
# else
# echo "Wrong URL"
# fi
reponame=${tmp##*/}
reponame=${reponame%.git}
#echo "${tmp} 2=$2 1=$1";
git clone "$tmp" "$reponame";
cd "$reponame";
}
#function killport {
# kill $(portsl G $1 | awk '{print $2}')
#}
function portsl {
sudo lsof -i:$1;
}
function killport {
info="$(sudo lsof -i:"$1" -sTCP:LISTEN)";
pid="$(echo "$info" | awk 'FNR == 2 {print $2}')";
name="$(echo "$info" | awk 'FNR == 2 {print $1}')";
if sudo kill -9 $pid > out.log 2> /dev/null; then
echo "$name, PID $pid killed!"
else
echo "No process is LISTENING on port $1"
fi
}
function pdf2img {
mkdir "$1-images";
pdftoppm -jpeg -r 150 $1 "$1-images/pg"
}
function makepdf {
find . -name "*.png" -exec convert "{}" -background white -alpha remove -alpha off "{}" \;
img2pdf *.png --output $1
}
function makepdfjpg {
img2pdf *.jpg --output $1
}
function cdl {
cd $1
ls
}
function mcd {
mkdir -p $1
cd $1
}
function takeown {
sudo chgrp -R users $1
sudo chmod -R g+w $1
}
function startserver {
port=8000
if [ $# -eq 1 ]
then
port=$1
fi
echo "Hosting file server for this directory on port :" $port
#echo "This machine's IP addresses are : (local|local|public)"
#myip
echo "Enter http://$(myip):"$port" in your browser's address bar"
python3 -m http.server $port
}
function gitbackup {
git rm --cached `git status | grep deleted | sed 's#^.*:##'` &>/dev/null
git add .
git commit -m "$(date +"%T")"
#git push -u $(git rev-parse --abbrev-ref HEAD)
git push origin $(git rev-parse --abbrev-ref HEAD)
}
#function pm {
# sudo apt-get update
# sudo apt-get $1
#}
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]"
return 1
else
for n in $@
do
if [ -f "$n" ] ; then
tmp="$n"
d="${tmp%%.*}";
mkdir "$d";
case "${n%,}" in
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar|*.bz2)
tar xvf "$n" -C "$d" ;;
*.lzma) unlzma ./"$n" ;;
*.rar) unrar x -ad ./"$n" "$d" ;;
*.gz) gunzip -c ./"$n" > "$d"/"$n" ;;
*.zip) unzip ./"$n" -d "$d" ;;
*.z) uncompress ./"$n" ;;
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
7z x ./"$n" -o"$d"/ ;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*)
echo "extract: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
# Example aliases
# alias du="ncdu"
# alias ohmyzsh="nano ~/.oh-my-zsh"
# alias df='df -h' # Human-readable sizes
alias free='free -m' # Show sizes in MB
#alias vim="nvim"
# alias tikb="~/toggleinternalkeyboard.sh"
# alias startvnc="~/startvnc.sh"
# alias andkb="~/androidkeyboard.sh"
# alias shtdwn="~/shutdown now"
# alias telegram="flatpak run org.telegram.desktop"
# alias ls="ls_extended"
# alias pm="sudo apt-get"
# alias hotspot="sudo create_ap --config /etc/create_ap.conf"
# alias lxlogout="pkill -SIGTERM -f lxsession"
# alias lmenu="lxsession-logout"
# alias droid="adbfs ~/droid"
alias mkdir="mkdir -pv"
alias bc='bc -l'
# handy short cuts #
alias h='history'
# alias j='jobs -l'
alias now='date +"%T"'
# alias nowdate='date +"%d-%m-%Y"'
alias rm='rm -I --preserve-root'
alias mv='mv -i'
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
alias meminfo='free -m -l -t'
#new ones(global)
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'
# alias -g CA="2>&1 | cat -A"
alias -g C='| wc -l'
# alias -g D="DISPLAY=:0.0"
# alias -g DN=/dev/null
# alias -g ED="export DISPLAY=:0.0"
# alias -g EG='|& egrep'
# alias -g EH='|& head'
# alias -g EL='|& less'
# alias -g ELS='|& less -S'
# alias -g ETL='|& tail -20'
# alias -g ET='|& tail'
# alias -g F=' | fmt -'
alias -g G='| grep'
alias -g H='| head'
# alias -g HL='|& head -20'
# alias -g Sk="*~(*.bz2|*.gz|*.tgz|*.zip|*.z)"
# alias -g LL="2>&1 | less"
alias -g L="| less"
alias -g LS='| less -S'
# alias -g MM='| most'
alias -g M='| more'
# alias -g NE="2> /dev/null"
# alias -g NS='| sort -n'
# alias -g NUL="> /dev/null 2>&1"
# alias -g PIPE='|'
# alias -g RNS='| sort -nr'
alias -g S='| sort'
# alias -g TL='| tail -20'
alias -g T='| tail'
# alias -g US='| sort -u'
# alias -g VM=/var/log/messages
# alias -g X0G='| xargs -0 egrep'
# alias -g X0='| xargs -0'
# alias -g XG='| xargs egrep'
# alias -g X='| xargs'
alias Q='q'
#source /usr/share/doc/pkgfile/command-not-found.zsh
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
#export PATH="$PATH:$HOME/.rvm/bin"
#PATH="/home/tushar/.cargo/bin${PATH:+:${PATH}}"; export PATH;
#PATH="/home/tushar/perl5/bin${PATH:+:${PATH}}"; export PATH;
#PERL5LIB="/home/tushar/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
#PERL_LOCAL_LIB_ROOT="/home/tushar/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
#PERL_MB_OPT="--install_base \"/home/tushar/perl5\""; export PERL_MB_OPT;
#PERL_MM_OPT="INSTALL_BASE=/home/tushar/perl5"; export PERL_MM_OPT;
#$HOME/tmp/hello $USER
#neofetch
#clear
#autoload -Uz promptinit
#promptinit
# prompt_context() {
# if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
# prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
# fi
# }
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export EDITOR="vim"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export DISPLAY=":0"
# Blur {{{
if [[ $(ps --no-header -p $PPID -o comm) =~ '^kitty|polybar$' ]]; then
for wid in $(xdotool search --pid $PPID); do
xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $wid; done
fi
# }}}