-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliasrc
executable file
·962 lines (823 loc) · 34.1 KB
/
aliasrc
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
#File: /home/$USER/.config/shellz/aliasrc
#Author: 4ndr0666
#Edited: 04-26-2024
#
# --- // ALIASRC // ========
# ==================================================== // QUICK_VIEW //
alias 00='cat ~/.config/shellz/aliasrc'
alias 0f='cat ~/.config/shellz/functions/functions.zsh'
alias 0z='cat ~/.zshrc'
alias 0b='cat ~/.bashrc'
# ===================================== // RECENT_PROGRAMS //
alias jf='sudo -S joshuto'
alias lf='lfub'
alias fd1='fd --exact-depth=1 --hidden'
alias screenrecord="wf-recorder -a"
alias screenrecord2="wf-recorder -a -c h264_vaapi -C aac -d /dev/dri/renderD128 --file=recording.mp4"
alias kmon='sudo kmon --color blue --accent-color 15FFFF --unicode'
# =========================================================== // EXPRESSVPN //
alias vpnc='sudo expressvpn connect'
alias vpnd='sudo expressvpn disconnect'
alias vpns='sudo expressvpn status'
alias vpnr='sudo expressvpn refresh'
alias vpnauto='expressvpn autoconnect true'
alias vpnset='sudo expressvpn preferences set '
alias vpnl='sudo expressvpn list'
alias vpnblock='sudo expressvpn preferences set block_all false'
alias vpnproto='sudo expressvpn protocol lightway_udp'
# ================================================================================================ // EDITOR //
if command -v nvim > /dev/null 2>&1; then
alias vim="nvim"
alias vimdiff="nvim -d"
else
echo "nvim not found, falling back to vim if available"
command -v vim > /dev/null 2>&1 || { echo "vim also not found. Please install a text editor."; return 1; }
fi
alias vim="nvim"
# ============================================================= // REMOVE_SUDO //
for cmd in pacman-key ufw mount umount pacman updatedb su systemctl useradd userdel groupadd groupdel chown chmod \
btrfs ip netstat modprobe; do
alias $cmd="sudo $cmd"
done
# =================================================== // COMMON_TYPOS //
alias gerp='grep'
alias shudown='shutdown'
alias pdw='pwd'
alias cd..='cd ..'
# ==================================================== // CHEATSHEETS //
cht() {
local cheats=("$HOME/.cheater/"*.md)
local choice=$(printf "%s\n" "${cheats[@]}" | fzf --prompt="Select a cheat sheet: ")
[ -n "$choice" ] && bat "$choice" || echo "No cheat sheet selected."
}
alias chtvim='cat ~/.cheater/chtvim.md'
alias chtyay='cat ~/.cheater/yay.md'
alias chtusername='cat ~/.cheater/chtusername.md'
alias chtvpn='cat ~/.cheater/chtvpn.md'
alias chtx='cat ~/.cheater/chtx.md'
alias chtperms='cat ~/.cheater/chtperms.md'
alias chtscr='cat ~/.cheater/chtscripts.md'
alias chtff='cat ~/.cheater/chtffmpeg.md'
alias chtmicro='cat ~/.cheater/chtmicro.md'
alias chtpy='cat ~/.cheater/chtpython.md'
alias bsnip='cat ~/.cheater/bash_snippets.md'
alias bhead='cat ~/.cheater/bash_header.md'
alias psnip='cat ~/.cheater/python_snippets.md'
alias chtutil='cat ~/.cheater/chtutils.md'
alias chtpkg='cat ~/.cheater/chtpkg.md'
alias chtgit='cat ~/.cheater/chtgit.md'
alias chtrsync='cat ~/.cheater/chtrsync.md'
alias chtyay='cat ~/.cheater/chtyay.md'
# ============================================== // EDIT_CONFIG_FILES //
edit_config() {
local file_path=$1
if [[ $file_path ]]; then
sudo -S nvim "$file_path"
else
echo "File path not provided."
fi
}
alias svim="edit_config"
alias valias='edit_config /home/$(whoami)/.config/shellz/aliasrc'
alias vfunc='edit_config /home/$(whoami)/.config/shellz/functions/functions.zsh'
alias vpac='edit_config /etc/pacman.conf'
alias vgrub='edit_config /etc/default/grub'
alias vgrubc='edit_config /boot/grub/grub.cfg'
alias vmkinit='edit_config /etc/mkinitcpio.conf'
alias vmirrors='edit_config /etc/pacman.d/mirrorlist'
alias vfstab='edit_config /etc/fstab'
alias vbash='edit_config ~/.bashrc'
alias vzsh='edit_config ~/.zshrc'
alias vfish='edit_config ~/.config/fish/config.fish'
alias vmpv='edit_config /home/andro/.config/mpv/mpv.conf'
alias vfire='edit_config ~/.config/wayfire.ini'
# ============================================ // DIRECTORY_SHORTCUTS //
goto() {
local dir=$1
if [[ -d "$dir" ]]; then
cd "$dir"
else
echo "Directory not found: $dir"
fi
}
# --- //$USER:
alias dc='goto ~/Documents'
alias dl='goto ~/Downloads'
alias conf='goto ~/.config'
alias confw='goto ~/.config/wayfire/'
alias confwb='goto ~/.config/wayfire/waybar/'
alias ob='goto ~/.config/openbox'
alias obt='goto ~/.config/openbox/themes'
alias hdd='cd /run/media/'
# --- //STORAGE:
alias s1='goto /storage'
alias sdl='goto /storage/Downloads'
alias spic='goto /storage/Pictures'
alias svid='goto /storage/Videos'
# --- //STO2:
alias s2'goto /sto2'
alias s2dl='goto /sto2/Downloads'
alias s2pic='goto /sto2/Pictures'
alias s2vid='goto /sto2/Videos'
# --- //23.1:
alias 23='goto /23.1'
alias 23dl='goto /23.1/Downloads'
alias 23pic='goto /23.1/Pictures'
alias 23vid='goto /23.1/Videos'
alias 23e='goto /23.1/Edits'
alias cloud='goto /23.1/Thecloud'
# --- //Nas:
alias nas='goto /Nas/'
alias b='goto /Nas/Build'
alias nbin='goto /Nas/Build/git/syncing/scr'
alias nnas='goto /Nas/Build/git/syncing/nas'
alias ngpt='goto /Nas/Build/git/syncing/gpt'
alias ngc='goto /Nas/Build/git/clone'
alias ngl='goto /Nas/Build/git/local'
alias npkg='goto /Nas/Build/pkgs'
alias npro='goto /Nas/Build/projects'
alias ndot='goto /Nas/Build/git/clone/dotfiles'
# --- //System:
alias et='goto /etc'
alias ske='goto /etc/skel'
alias bin='goto /usr/local/bin'
alias lbin='goto ~/.local/bin'
alias lshare='goto ~/.local/share/'
alias lsrc='goto ~/.local/src/'
alias shellzsh='goto ~/.config/shellz'
alias shellbash='goto ~/.config/shell'
# ========================================================== // SCRIPTS_DROPDOWN_MENU //
# --- // $USER/.local/bin //
slb() {
choice="$(find ~/.local/bin -mindepth 1 -printf '%P\n' | fzf)"
[ -f "$HOME/.local/bin/$choice" ] && $EDITOR "$HOME/.local/bin/$choice";
}
# --- // /Nas/Build/git/syncing/scr //
ms() {
local dir="${1:-/Nas/Build/git/syncing/scr}"
# Find executable files and directories, excluding .git items, and sorting directories first
local choice=$(find "$dir" -mindepth 1 \( -type d -o -executable -type f \) \
! -path '*/.git/*' -printf '%P\n' | \
sort -r | \
fzf --preview "cat '$dir/{}'" --preview-window=down:70%)
if [ -n "$choice" ]; then
if [ -d "$dir/$choice" ]; then
# If the choice is a directory, list its contents
echo "Selected directory: $dir/$choice"
elif [ -x "$dir/$choice" ]; then
# If the choice is an executable file, execute it
echo "Executing $dir/$choice ..."
"$dir/$choice"
else
echo "No script selected or script is not executable."
fi
else
echo "No selection made."
fi
}
# =======================================================// OH_MY_ZSH //
#alias oz="svim ~/.zshrc"
#alias oc="cd ~/.oh-my-zsh/custom/"
#alias omzp="echo -e '\033[1;36mPlugins:\033[0m'; awk -F'=' '/^plugins/{gsub(/[\(\)]/, \"\"); split(\$2, a, \" \"); for(i in a) print a[i]}' ~/.zshrc"
#alias omzl='omz plugin list'
#alias omzi='omz plugin info'
# ================================================== // BASIC_ALIASES //
alias cd='cd -P'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias s='sudo'
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='trash-put' # Aliases for trash-cli
#alias rm='rm -vI'
alias rmf='sudo -S /usr/bin/rm -vI -rf'
alias rg='batgrep' # Aliased for bat-extras ripgrep
#alias rg="rg --sort path"
alias diff='diff --color=auto'
alias rmdir='rm -vI --preserve root'
alias ln='ln -iv'
alias bc='bc -ql'
alias mkdir='mkdir -pv'
alias wget="wget -c"
alias curl="curl --user-agent 'noleak'"
alias df='df -h --exclude-type=squashfs --exclude-type=tmpfs --exclude-type=devtmpfs'
alias cat='bat'
alias showpath='echo $PATH | tr ":" "\n"'
#alias path='path -l $path'
alias rsync='rsync -vrPlu'
alias grub-mkconfig='sudo grub-mkconfig -o /boot/grub/grub.cfg'
alias grepc='grep --color=always'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias lessc='less -R'
alias ip='ip -color=auto'
alias c='clear; echo; echo; seq 1 $(tput cols) | sort -R | spark | lolcat; echo; echo'
alias hw='sudo hwinfo --short'
alias lsblk='lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT'
#alias lsblkh='lsblk.sh'
alias psa='ps auxf | less'
alias free='free -mt'
alias jctl='journalctl -p 3 -xb'
alias g='git'
alias gstat='git status'
alias grh="git reset --hard"
alias gfs='git-lfs'
alias mapit="ifconfig -a | grep -Po '\b(?!255)(?:\d{1,3}\.){3}(?!255)\d{1,3}\b' | xargs nmap -A -p0-"
alias ports='netstat -tulanp'
alias speedtest='curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -'
alias netspeed='ifstat -t -S -w'
alias iotop='sudo iotop -o'
alias netwatch='sudo nethogs'
alias dir5='du -cksh * | sort -hr | head -5'
alias dir10='du -cksh * | sort -hr | head -10'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias z='zathura'
function back() {
local steps=${1:-1} # Number of steps back in the directory stack, default is 1
for ((i = 0; i < steps; i++)); do
if [[ $(dirs -p | wc -l) -gt 1 ]]; then
cd - # Move to the previous directory in the stack
else
echo "No more directories in the history."
break
fi
done
}
alias tarnow='sudo -S tar cf archive.tar.gz '
alias untar='sudo -S tar xvf '
alias watch='watch '
alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e"
mem() {
local count=${1:-5}
echo "Top $count memory-consuming processes:"
ps aux --sort=-%mem | awk 'NR==1; NR>1 {print $0}' | head -n $(($count + 1))
}
cpu() {
local count=${1:-5}
echo "Top $count CPU-consuming processes:"
ps aux --sort=-%cpu | awk 'NR==1; NR>1 {print $0}' | head -n $(($count + 1))
}
# --- // MEM, POWER, TOP 5:
#unalias mem5 2>/dev/null
#mem5() {
# ps aux --sort=-%mem | awk '{print $11}' | head -n 6
#}
#unalias mem10 2>/dev/null
#mem10() {
# ps aux --sort=-%mem | awk '{print $11}' | head -n 11
#}
#unalias cpu5 2>/dev/null
#cpu5() {
# ps aux --sort=-%cpu | awk '{print $11}' | head -n 6
#}
#unalias cpu10 2>/dev/null
#cpu10() {
# ps aux --sort=-%cpu | awk '{print $11}' | head -n 11
#}
# ======================================================================= // LS_CONFIGS //
# --- // Config 1:
alias mkplaylist="ls -d */ > mpv_playlist.txt"
alias lb='ls | bat'
alias l1='lsd -1'
alias lr='lsd -tr'
alias ls='exa -hlx --no-filesize --no-time --no-permissions --octal-permissions --color=always --group-directories-first --icons=always'
alias la="lsd -aFlL --permission=rwx --color=always --group-dirs=first --icon=always"
alias ll='exa -xXDa --color=always --icons=always'
alias l.='exa -ax --sort=modified --color-scale-mode=gradient --color=always --group-directories-first --icons | grep "^\."'
alias lt='exa -aT -s new --color=always --group-directories-first --icons'
# --- // Config 2:
#alias ls="ls -alhfN --time-style=long-iso --color=auto --group-directories-first"
#alias ll="ls -lFh --color=auto --group-directories-first --time-style=long-iso"
#alias la='exa -hFlBgmnsa -s new --git --octal-permissions --group-directories-first --icons'
#alias lt='ls -ltFh'
#alias ldot='ls -1FSsh'
#alias LS='ls -1FSsh'
#alias lart='ls -1Fcart'
#alias lrt='ls -1Fcrt'
#alias lm='ls -m'
#alias lr='ls -R'
#alias lg='ls -l --group-directories-first'
# --- // Config 3:
#alias l.='ls -d .* --color=auto'
#alias ll='ls -lh --color=auto'
#alias la='ls -lha --color=auto'
#alias lsd='ls -lhS --color=auto | grep -E "^d"'
#alias lsf='ls -lhS --color=auto | grep -E "^-"'
#alias lsp='ls -lhS --color=auto | grep -E "^l"'
# ============================================================================= // PERMISSIONS //
alias chown='sudo chown --preserve-root'
alias chmod='sudo chmod --preserve-root'
alias chgrp='sudo chgrp --preserve-root'
alias chgpg='sudo chown -R $USER:$USER ~/.gnupg && sudo chmod 700 ~/.gnupg && sudo chmod 600 ~/.gnupg/private-keys-v1.d/*'
alias lock='sudo chattr +i '
alias unlock='sudo chattr -i '
alias chlocal='sudo chown -R $USER:$USER ~/.config ~/.local && echo "Ownership of ~/.config and ~/.local changed to $USER."'
chboot() {
sudo chmod -R 755 /boot/efi
sudo chown -R root:root /boot/efi
echo "Boot directory permissions reset appropriately."
}
chdefault() {
if [[ -z "$1" ]]; then
echo "Usage: chdefault <directory>"
return 1
elif [[ ! -d "$1" ]]; then
echo "Error: '$1' is not a valid directory."
return 1
fi
echo "Setting directory permissions to 755 for: $1"
sudo find "$1" -type d -exec chmod 755 {} +
echo "Permissions reset successfully for $1."
}
chandro() {
if [[ -z "$1" ]]; then
echo "Usage: chandro <directory>"
return 1
elif [[ ! -d "$1" ]]; then
echo "Error: '$1' is not a valid directory."
return 1
fi
echo "Changing ownership and permissions to $USER for: $1"
sudo chown -R $USER:$USER "$1"
sudo find "$1" -type d -exec chmod 755 {} +
sudo find "$1" -type f -exec chmod 644 {} + # Adjusted to 644 for files
echo "Ownership and permissions set successfully for $1."
}
chroot() {
if [[ -z "$1" ]]; then
echo "Usage: chroot <directory>"
return 1
elif [[ ! -d "$1" ]]; then
echo "Error: Directory not found."
return 1
fi
echo "Setting ownership to root and permissions to 755 (directories) and 644 (files) for: $1"
sudo find "$1" -type d -exec chmod 755 {} +
sudo find "$1" -type f -exec chmod 644 {} +
sudo chown -R root:root "$1"
echo "Ownership and permissions set successfully for $1."
}
chpython() {
local python_version
python_version=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
local site_packages_dir="/usr/lib/python${python_version}/site-packages"
if [[ -d "$site_packages_dir" ]]; then
echo "Setting ownership to root and permissions to 755 for: $site_packages_dir"
sudo chown -R root:root "$site_packages_dir"
sudo chmod -R 755 "$site_packages_dir"
echo "Ownership and permissions set successfully for $site_packages_dir."
else
echo "Error: Directory $site_packages_dir not found for Python version $python_version."
fi
}
chexcept() {
if [[ -z "$1" ]]; then
echo "Usage: chexcept <directory>"
return 1
elif [[ ! -d "$1" ]]; then
echo "Error: Directory not found."
return 1
fi
read -r -p "Enter the directory name to exclude: " exclude_dir
if [[ -z "$exclude_dir" ]]; then
echo "Error: No directory specified to exclude."
return 1
fi
echo "Setting permissions for $1, excluding $exclude_dir"
sudo find "$1" -type d -not -name "$exclude_dir" -exec chmod 755 {} +
sudo find "$1" -type f -not -path "*/$exclude_dir/*" -exec chmod 644 {} +
sudo chown -R root:root "$1"
echo "Permissions set successfully for $1, excluding $exclude_dir."
}
# ======================================================================== // UNIQUE_ALIASES //
# --- // Retries cmd until executes:
alias retry='until !!; do :; done'
# --- // Backup & restore skel from recover dir:
alias bupskel='sudo cp -Rf /etc/skel /var/recover/skel-backup-$(date +"%Y.%m.%d-%H.%M.%S") && echo "Backup of skel made."'
alias restore='sudo cp -Rf /var/recover/skel-backup-*/. $HOME/ && echo "Restored from latest backup."'
alias ssha='eval $(ssh-agent) && ssh-add'
alias sshid='xclip -sel clip < ~/.ssh/id_ed25519.pub'
alias update-grub="sudo grub-mkconfig -o /boot/grub/grub.cfg"
alias myip='curl icanhazip.com'
alias fixbootloader='sudo grub-install && sudo grub-mkconfig -o /boot/grub/grub.cfg'
alias dracutthiskernel='sudo dracut --force --kver=$(uname -r) /boot/initramfs-linux.img'
alias dracutallkernels='sudo dracut --regenerate-all --fstab --early-microcode --enhanced-cpio --lz4 --force'
alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
alias pacdiff='sudo -H DIFFPROG=meld pacdiff'
alias restartntp='sudo systemctl stop ntpd.service && sudo pacman -Syu ntp'
alias fixntp='sudo ntpd -qg && sleep 10 && sudo hwclock -w'
alias fixkeyboard='sudo localectl set-x11-keymap us'
alias listusers='cut -d: -f1 /etc/passwd | sort'
alias setlocales='sudo localectl set-locale LANG=en_US.UTF-8'
alias microcode='grep . /sys/devices/system/cpu/vulnerabilities/*'
alias audio="pactl info | grep 'Server Name'"
#alias mcut='cat /home/$USER/.config/mpv/scripts/cutter.lua | grep key'
#alias findit='read -p "Do you want to find a file (f) or a directory (d)? " choice; if [ "$choice" == "f" ]; then read -p "Enter the filename to search for: " filename; sudo find / -type f -name "$filename" 2>/dev/null; elif [ "$choice" == "d" ]; then read -p "Enter the directory name to search for: " dirname; sudo find / -type d -name "$dirname" 2>/dev/null; else echo "Invalid choice. Please select 'f' for file or 'd' for directory."; fi'
#alias whatsnew='read -p "Do you want to find files based on modification time (m) or access time (a)? " choice; if [ "$choice" == "m" ]; then find "$PWD" -type f -mtime -7 -print0 | xargs -0 ls -lt | head; elif [ "$choice" == "a" ]; then find "$PWD" -type f -atime -7 -print0 | xargs -0 ls -lt | head; else echo "Invalid choice. Please select 'm' for modification time or 'a' for access time."; fi'
#alias cleanls='echo "pacman -Q | grep -E 'pipewire|pulseaudio|alsa|jack' > audio_packages.txt && sed -i 's/ .*$//' audio_packages.txt"'
#alias list="xclip -o | tr '\n' ' ' | sed 's/ $/\n/' | xclip -selection c"
#alias splitlist="xclip -o | tr ',' '\n'"
#alias copy='xclip -selection clipboard'
#alias copy='wl-copy <'
#alias cleanssh="sed -i 18d .ssh/known_hosts"
# --- // restore shell configs from /etc/skel:
#alias cb='cp /etc/skel/.bashrc ~/.bashrc && exec bash'
#alias cz='cp /etc/skel/.zshrc ~/.zshrc && echo "Copied."'
#alias cf='cp /etc/skel/.config/fish/config.fish ~/.config/fish/config.fish && echo "Copied."'
#alias swap="sudo swapoff -a; sudo swapon -a"
#alias mpvplaylist='mpv --input-ipc-server=/tmp/mpvsocket --playlist=/home/andro/mpv_playlist.txt'
# --- // Change_shell:
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.'"
# --- // Display:
alias xd='ls /usr/share/xsessions'
alias xdw="ls /usr/share/wayland-sessions"
alias xfix='echo "DISPLAY=:0 XAUTHORITY=$HOME/.Xauthority xterm"'
alias xi='sudo xbps-install'
alias xr='sudo xbps-remove -R'
alias xq='xbps-query'
alias xmerge='xrdb -merge ~/.Xresources'
# --- // Switch login managers:
alias tolightdm="sudo pacman -S lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings --noconfirm --needed ; sudo systemctl enable lightdm.service -f ; echo 'Lightm is active - reboot now'"
alias tosddm="sudo pacman -S sddm --noconfirm --needed ; sudo systemctl enable sddm.service -f ; echo 'Sddm is active - reboot now'"
alias toly="sudo pacman -S ly --noconfirm --needed ; sudo systemctl enable ly.service -f ; echo 'Ly is active - reboot now'"
alias togdm="sudo pacman -S gdm --noconfirm --needed ; sudo systemctl enable gdm.service -f ; echo 'Gdm is active - reboot now'"
alias tolxdm="sudo pacman -S lxdm --noconfirm --needed ; sudo systemctl enable lxdm.service -f ; echo 'Lxdm is active - reboot now'"
# --- // Btrfs:
alias btrfsfs='sudo btrfs filesystem df /'
alias btrfsli='sudo btrfs su li / -t'
# --- // Snapper:
alias snapcroot="sudo snapper -c root create-config /"
alias snapchome="sudo snapper -c home create-config /home"
alias snapli="sudo snapper list"
alias snapcr="sudo snapper -c root create"
alias snapch="sudo snapper -c home create"
# --- // Count or list files in dir:
lsfiles() {
if [[ "$1" == "-l" ]]; then
echo "Files in $PWD:"
find $PWD -type f
else
echo "Total files in $PWD: $(find $PWD -type f | wc -l)"
fi
}
lsmount() {
if [[ -n "$1" ]]; then
mount | column -t | grep "$1"
else
mount | column -t
fi
}
killit() {
local pattern=$1
if [[ -z "$pattern" ]]; then
echo "Error: Please provide a process name or pattern."
return 1
fi
echo "Searching for processes matching '$pattern'..."
local pids=$(pgrep -fl "$pattern")
if [[ -z "$pids" ]]; then
echo "No processes found matching '$pattern'."
return 1
fi
echo "Found processes:"
echo "$pids"
echo "Please enter the PIDs to kill (separate multiple PIDs with spaces):"
read -r pid_list
if [[ -z "$pid_list" ]]; then
echo "No PIDs provided, no action taken."
return 1
fi
for pid in $pid_list; do
if echo "$pids" | grep -q -w "$pid"; then
sudo kill -9 "$pid" && echo "Process $pid killed." || echo "Failed to kill process $pid."
else
echo "PID $pid does not match any of the listed processes. Skipping."
fi
done
}
# --- // Sets up zram:
generate-zramconf() {
echo '[zram0]
zram-size = ram / 2' | sudo tee /etc/systemd/zram-generator.conf
sudo systemctl daemon-reload
sudo systemctl start /dev/zram0
}
# --- // List dependencies of pkg:
whatdependson() {
search="$1"
sudo pacman -Sii $search | grep "Required" | sed -e "s/Required By : //g" | sed -e "s/ /\n/g"
}
# --- // Backsup archive of pkg typed after:
f() {
local target="$1"
local backup_dir="${2:-.}" # Optional second argument to specify backup directory, defaults to current directory
if [[ -z "$target" ]]; then
echo "Error: Please provide a file or directory to back up."
return 1
fi
if [[ ! -e "$target" ]]; then
echo "Error: The target '$target' does not exist."
return 1
fi
local target_name=$(basename "$target")
local timestamp=$(date -u "+%h-%d-%Y_%H.%M%p")
local backup_file="${backup_dir}/${target_name}_${timestamp}_backup.tar.gz"
echo "Creating backup for '$target'..."
# Check if we have write access to the backup directory and read access to the target
if [[ ! -w "$backup_dir" || ! -r "$target" ]]; then
echo "Insufficient permissions, attempting with sudo..."
if sudo tar -czvf "$backup_file" "$target"; then
echo "Backup successful with sudo: $backup_file"
else
echo "Error: Failed to create backup with sudo."
return 1
fi
else
if tar -czvf "$backup_file" "$target"; then
echo "Backup successful: $backup_file"
else
echo "Error: Failed to create backup."
return 1
fi
fi
}
# --- // Move_up_1_directory:
up() { for _ in $(seq "${1:-1}"); do cd ..; done; }
# --- // List app :80 connections:
function con80() {
{
LANG= ss -nat || LANG= netstat -nat
} | grep -E ":80[^0-9]" | wc -l
}
# --- // List 20 :80 connections:
function http20() {
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | head -n 20
}
# --- // List 20 SYN connections:
function syn20() {
{
LANG= ss -an | awk '/SYN/ {print $5}' \
|| LANG= netstat -an | awk '/SYN/ {print $5}'
} | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n20
}
# --- // Sort 100 connections by uptime and occurrences:
function consume100() {
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100
# if django website or other website make by no suffix language
# awk '{print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100
}
# --- // Delete 0byte files:
function d0() {
local target_dir="${1:-.}"
find "$target_dir" -type f -size 0 -print0 | while IFS= read -r -d '' file; do
read -r -p "Delete '$file'? [y/N] " response
if [[ $response =~ ^[Yy]$ ]]; then
rm -rf "$file"
echo "Deleted: $file"
else
echo "Skipped: $file"
fi
done
}
# --- Python with no venv:
syspip() {
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}
syspip2() {
PIP_REQUIRE_VIRTUALENV="" pip2 "$@"
}
syspip3() {
PIP_REQUIRE_VIRTUALENV="" pip3 "$@"
}
# ==================================================================================== // MEDIA:
alias trem='transmission-remote'
alias unhblock='hblock -S none -D none'
alias imgscrape='wget -r -l1 --no-parent -nH -nd -P/tmp -A".gif,.jpg,.png"' http://example.com/images
alias mirrorsite='wget -m -k -K -E -e robots=off'
alias ytt='yt --skip-download --write-thumbnail'
alias YT='youtube-viewer'
alias yta='yt -x -f bestaudio/best'
ytdl() {
yt-dlp --add-metadata \
--embed-metadata \
--external-downloader aria2c \
--external-downloader-args "-c -j 3 -x 3 -s 3 -k 1M" \
-f "315/313/308/303/302/247/244+bestaudio/best" \
--merge-output-format mp4 \
--no-playlist \
--no-mtime \
"$@"
}
reddl() {
yt-dlp --external-downloader aria2c \
--external-downloader-args "-c -j 3 -x 3 -s 3 -k 1M" \
-o "/home/andro/Downloads/%(title)s.%(ext)s" \
"$@"
}
alias nm3='function _nm3() {
local url="$1"
local name="download_$(date +%Y%m%d_%H%M%S)"
n-m3u8dl-re "$url" --save-name "$name" --use-ffmpeg-concat-demuxer --thread-count 32 --download-retry-count 5 --auto-select --live-real-time-merge --mux-after-done format=mp4:muxer=ffmpeg:keep=false --tmp-dir "/storage/tmp" --save-dir "/sto2/Downloads"
}; _nm3'
# ====================================================================================== // PACMAN //
# --- // Package Manager Utils:
alias mirrors='sudo reflector --latest 10 --age 2 --fastest 10 --protocol https --sort rate --save /etc/pacman.d/mirrorlist'
alias fixpacman='sudo unlink /var/lib/pacman/db.lck'
alias fixpacman2='sudo unlink /var/cache/pacman/pkg/cache.lck'
alias cleanpacman="sudo find /var/cache/pacman/pkg/ -iname '*.part' -delete"
alias checkdb='sudo pacman -Dk'
alias findpkg='sudo pacman -Fyx'
alias eol='comm -23 <(pacman -Qqm | sort) <(curl https://aur.archlinux.org/packages.gz | gzip -cd | sort)'
#alias undo='sudo apt-get remove $(dpkg -l | tail -n +6 | awk "{print $2}")'
# --- // Package Lists:
alias bigpkg="expac -H M '%m\t%n' | sort -h | nl"
alias rip="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl"
alias riplong="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -3000 | nl"
alias gitpkg="pacman -Q | grep -i '\-git' | wc -l"
alias pkgbysize="expac -Q '%m - %n %v' | sort -n -r"
alias mkpkglist='bat /tmp/pacui-ls'
# --- // Package Manger Customization Flags:
yaysearch() {
read -p "Choose a search parameter (1-5): " search_param
case $search_param in
1) yay --singlelineresults --groups --provides --searchby name ;;
2) yay --singlelineresults --groups --provides --searchby desc ;;
3) yay --singlelineresults --groups --provides --searchby maintainer ;;
4) yay --singlelineresults --groups --provides --searchby packager ;;
5) yay --singlelineresults --groups --provides --searchby depends ;;
*) echo "Invalid choice. Please choose a number between 1 and 5." ;;
esac
}
alias yay='yay --answerdiff no --builddir "/home/build" --cleanafter --cleanmenu --editmenu --norebuild --noredownload --provides --singlelineresults --sortby votes'
alias yaydeps='yay --recursive --refresh --singlelineresults --sudoloop --sysupgrade --timeupdate --verbose'
alias yayskip='yay -S --mflags --skipinteg'
alias trizenskip='trizen -S --skipinteg'
alias powerupdate='sudo pacman -Sy && sudo powerpill -Su && paru -Su'
# --- // Unsafe Install (security bypass):
alias fninstall="yay -S --needed --cleanafter --cleanmenu --devel --noconfirm --rebuild --refresh --sudoloop --sysupgrade --overwrite='*' --disable-download-timeout --pgpfetch=false --noupgrademenu --removemake --redownload --batchinstall=false --answerclean=yes --answerdiff=no --answeredit=no"
# --- // Unsafe Update (security bypass):
alias fnupdate='yay -Syyu --noconfirm --disable-download-timeout --noupgrademenu --skipreview --removemake --rebuild --nopgpfetch --nosign --nosigndb --nocheck --bottomup --overwrite="*"'
# --- // Unsafe Removal (dependency bypass):
alias fnremove='yay -Rddn --noconfirm'
# --- // Unsafe Siglevel Manipulation:
alias pacmansigoff="read -p 'Are you sure you want to disable PGP signature verification? (yes/no): ' answer && \
if [[ \$answer == 'yes' ]]; then \
if sudo cp --preserve=all -f /etc/pacman.conf /etc/pacman.conf.backup; then \
sudo sed -i '/^SigLevel/ s/Required/Never/' /etc/pacman.conf && \
echo 'PGP signature verification bypassed.'; \
else \
echo 'Failed to create backup. Aborting.'; \
fi; \
else \
echo 'Operation canceled.'; \
fi"
alias pacmansigon="if [ -f /etc/pacman.conf.backup ]; then \
if sudo cp --preserve=all -f /etc/pacman.conf.backup /etc/pacman.conf; then \
sudo rm /etc/pacman.conf.backup && \
echo 'PGP signature verification restored.'; \
else \
echo 'Failed to restore the original pacman.conf. Aborting.'; \
fi; \
else \
echo 'Backup file not found. Cannot restore.'; \
fi"
# ===================================================================================== // GPG //
alias fixdirmngr='sudo dirmngr </dev/null'
alias rmgpg='sudo rm -r /etc/pacman.d/gnupg'
alias mkgpg="[ -d ~/.gnupg ] || mkdir ~/.gnupg ; cp /etc/pacman.d/gnupg/gpg.conf ~/.gnupg/ ; echo 'done'"
alias fixpacmankey='sudo pacman -S archlinux-keyring && sudo pacman-key --populate'
#alias fixgpgkey="echo 'keyring /etc/pacman.d/gnupg/pubring.gpg' >> $HOME/.gnupg/gpg.conf && sudo pacman-key --populate archlinux"
alias gpgkeyserver2="sudo gpg --keyserver hkps://keys.openpgp.org/ --search-keys user-id"
alias generate-keyserver='gpg --full-generate-key && gpg --import /usr/share/pacman/keyrings/archlinux* && gpg --recv-keys --keyserver hkp://pool.sks-keyservers.net && pacman-key --init && pacman-key --populate archlinux'
#alias newkeyring='sudo pacman -Syu gnupg $(pacman -Qsq '(-keyring)' | grep -v -i -E '(gnome|python|debian)' | paste -sd " " )" --noconfirm'
#alias initkeyring='sudo pacman-key --init && sudo pacman-key --populate $(pacman -Qsq '(-keyring)' | grep -v -i -E '(gnome|python|debian)' | sed 's/-keyring//' | paste -sd " " )'
# ==================================================================================== // GIT //
# ---- // Git_clone:
gclone() {
# Check if a repository URL is provided
if [[ -z "$1" ]]; then
echo "Error: No repository URL provided."
echo "Usage: gclone <repository-url>"
return 1
fi
# Extract the directory name from the repository URL
repo_name=$(basename "$1" .git)
# Check if the directory already exists
if [[ -d "$repo_name" ]]; then
echo "Error: Directory '$repo_name' already exists."
return 1
fi
# Clone the repository with depth 1
if git clone --depth 1 "$@"; then
# Change into the newly cloned directory
cd "$repo_name" || {
echo "Error: Failed to change into directory '$repo_name'."
return 1
}
echo "Successfully cloned and switched to '$repo_name'."
else
echo "Error: Failed to clone the repository."
return 1
fi
}
# --- // Git_add_all/commit_all/comment/pull/push:
gcomp() {
# Check if there are any changes to commit
if ! git diff-index --quiet HEAD --; then
# Gather information about the changes
added=$(git status --porcelain | grep "^A" | wc -l)
modified=$(git status --porcelain | grep "^ M" | wc -l)
deleted=$(git status --porcelain | grep "^D" | wc -l)
# Generate a commit message based on changes
commit_message="Auto-commit: ${added} added, ${modified} modified, ${deleted} deleted"
# Add all changed files to staging
git add .
# Commit the changes with the generated commit message
if ! git commit -m "$commit_message"; then
echo "Error: Commit failed. Aborting."
return 1
fi
# Pull the latest changes from the remote repository
if ! git pull --rebase; then
echo "Error: Pull failed. Aborting."
return 1
fi
# Push the changes to the remote repository
if ! git push; then
echo "Error: Push failed. Aborting."
return 1
fi
echo "Changes committed, pulled, and pushed successfully."
echo "Commit message: $commit_message"
else
echo "No changes detected. Nothing to commit."
fi
}
# --- // Add_ssh_id:
gssh() {
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/github
ssh -T [email protected]
}
# --- // Git_search:
gsearch() {
git exec ag "$1"
}
# --- // Git_delete_cache:
rmgitcache() {
rm -rf ~/.cache/git
}
# --- // Git_root:
groot() {
cd "$(git rev-parse --show-toplevel)" || exit
}
# --- // Reset_git_remote_to_mine:
gremote() {
# Check if the current directory is a Git repository
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "Not a git repository. Please navigate to a git repository and try again."
return 1
fi
printf "Enter the repository name: "
read -r -p repo_name
local url="[email protected]:4ndr0666/${repo_name}.git"
git remote remove origin
git remote add origin "$url"
git remote -v
}
# --- // Use_SSH_for_git_auth:
grepo() {
local repo_name commit_msg
git init
echo "Enter the name of the GitHub repository:"
read -r -p repo_name
git remote add origin "[email protected]:4ndr0666/${repo_name}.git"
git add .
echo "Enter a commit message for the initial commit (default: 'Initial commit'):"
read -r -p commit_msg
commit_msg=${commit_msg:-"Initial commit"} # Use default message if none provided
git commit -m "$commit_msg"
git push -u origin main
}
# ================================== // POWER // ====================================================
alias magic='sudo /usr/local/bin/magic.sh'
# Polkit Check and Cleanup Script
cleanup_session() {
# Check if Polkit is running
pgrep -x polkit-gnome-authentication-agent-1 > /dev/null && echo "Polkit running" || echo "Polkit not running"
# Session cleanup commands
pkill -f "polkit-gnome-authentication-agent-1"
pkill -f "xdg-desktop-portal"
# Add other necessary cleanup commands
echo "Session cleanup complete."
}
# Shutdown Alias
alias sdn="cleanup_session && echo 'Shutting down...' | sudo tee -a /var/log/user_commands.log && sudo shutdown -h now"
# Reboot Alias
alias ssr="cleanup_session && echo 'Rebooting...' | sudo tee -a /var/log/user_commands.log && sudo reboot -h now"