-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestrc
More file actions
633 lines (541 loc) · 16.2 KB
/
testrc
File metadata and controls
633 lines (541 loc) · 16.2 KB
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
#!/bin/zsh
# ==== BETTER RUN COMMAND ===
# ======== SZMELC.INC =======
# Initial Welcome Prompt to tmp log
figlet .TestRC > /tmp/testrc-log
echo 'Better Run Command v1 ~ By $x66' >> /tmp/testrc-log
echo ' - Initial load: [source .testrc]' >> /tmp/testrc-log
echo ' - Reload config: [reloadrc]' >> /tmp/testrc-log
echo ' - List functions: [listrc <file>]' >> /tmp/testrc-log
cat /tmp/testrc-log | boxes -d tux > /tmp/testrcx-log && mv /tmp/testrcx-log /tmp/testrc-log
echo '\n - Add [source ~/.testrc] to ~/.zshrc to make it autoload' >> /tmp/testrc-log
echo ' - [ https://github.com/Szmelc-INC/Entropy-Package-Manager ]' >> /tmp/testrc-log
# REMOVE THIS LINE TO DISABLE WELCOME PROMPT
clear && echo "\n" && cat /tmp/testrc-log | lolcat && echo "\n\n"
# NET-PACK
# Detailed IP info
alias ipinfo="curl ipinfo.io"
# Print External IPv4 and IPv6
alias ip4ext="curl -4 ifconfig.me"
alias ip6ext="curl -6 ifconfig.me"
# Show Local IPs
alias iplocal="hostname -I | tr ' ' '\n'"
# Print Ipv6 and Ipv4
alias ip6="curl ifconfig.me"
alias ip4="hostname -I | tr ' ' '\n' | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'"
# Show All Open Files by Network Processes
alias netfiles="sudo lsof -i"
# Print Ports & Listening Ports
alias ports="netstat -tulanp"
alias portsl="ss -tuln"
# Capture packets
alias tcpd="sudo tcpdump -i eth0"
# Test connectivity by pinging google.com / 8.8.8.8
alias pingg="ping google.com -c 4 && ping 8.8.8.8 -c 4"
# Show Gateway, Routing table & DNS Server
alias gateway="ip route | grep default | awk '{print \$3}'"
alias routes="ip route show"
alias dns="cat /etc/resolv.conf | grep nameserver | awk '{print \$2}'"
# MAC Address of Interface
alias mac="ip link show eth0 | awk '/ether/ {print \$2}'"
# VPN Status
alias vpnstatus="nmcli connection show --active | grep vpn"
# Show All Active Connections
alias activeconn="netstat -ant | grep ESTABLISHED"
# List All Listening Services
alias listensrv="sudo lsof -i -P -n | grep LISTEN"
# Display All Wireless Networks
alias showwifi="nmcli dev wifi list"
# Check SSL Certificate Expiry
alias sslcheck="echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates"
# Find files by name
alias ffind="find . -type f -iname"
# Find directories by name
alias dfind="find . -type d -iname"
# Find and open with fzf
fopen() {
local file
file=$(find . -type f -iname "*$1*" | fzf) && xdg-open "$file"
}
# Time the execution of any command.
timer() {
start=$(date +%s)
"$@"
end=$(date +%s)
echo "Time elapsed: $((end - start)) seconds."
}
# Display weather for your location or specified city
weather() {
if [ -z "$1" ]; then
curl "wttr.in?format=4"
else
curl "wttr.in/${1// /+}?format=4"
fi
}
# Quick http python server
# Run to start py server / Optionally define port: $0 <port>
alias serve="python3 -m http.server"
# Show space usage for current folder
alias diskspace="du -sh * 2>/dev/null | sort -h"
# Add copy and paste commands
# Usage:
# Copy: [echo "Stuff" | copy], [copy "Stuff"], [copy $X]
# Paste: [paste], [command $(paste)]
copy() {
# Copy from stdin (e.g., echo "text" | copy)
if [ $# -eq 0 ]; then
xclip -selection clipboard
else
# Copy directly from a string or variable
echo -n "$*" | xclip -selection clipboard
fi
}
paste() {
xclip -selection clipboard -o
}
# Copy from file
alias copyf="cat $1 | xclip -selection clipboard"
# Grep highlight & count
alias grepi="grep -i --color=auto"
alias grepc="grep -c --color=auto"
# Add funny quote to error commands
precmd() {
LAST_CMD=$?
if [ $LAST_CMD -ne 0 ]; then
echo "$(curl -s https://zenquotes.io/api/random | jq -r '.[0].q')"
fi
}
# Fun stuff
alias joke="curl -s -H 'Accept: application/json' https://icanhazdadjoke.com/ | jq -r '.joke'"
alias inspire="curl -s https://zenquotes.io/api/random | jq -r '.[0].q + \" - \" + .[0].a'"
# Count to...
countdown() { for ((i=$1; i>0; i--)); do echo "$i..."; sleep 1; done; echo "Done!"; }
# Reminder in Xs
remindme() { sleep $1 && notify-send "Reminder" "$2"; }
# Pretty json
alias jsonp="python3 -m json.tool"
# Calendar
alias calh="clear && ncal -M -h"
# Syscheck
alias syscheck="echo 'CPU:' && lscpu | grep 'Model name' && echo 'Memory:' && free -h"
# Existential LS
alias ls='ls --color=auto; echo "\n ~ All these files... will eventually be dust..."'
# Parkour CD
function cd() {
builtin cd "$@" && echo "\n ~ PARKOUR!"
}
# Dramatic RM
function rm() {
echo "Farewell, sweet data. You'll be missed."
command rm "$@"
}
# Passive-Agressive WHOAMI
alias whoami='echo "*Oh, this dumb fuck again...*" && command whoami'
# Start GPT in conversation mode with functions enabled
function gpt() {
sgpt --repl TEXT "You are helpfull programmer, ready to debug my shitty code" --functions
}
# WTF Counter
export WTF_COUNT=0
function wtf() {
((WTF_COUNT++))
echo "WTF count: $WTF_COUNT"
}
# Good Manner Sudo
alias please='sudo'
# Pretty random emojis :P
function remoji() {
local emojis=(
# 1–10
"😀" "😁" "😂" "🤣" "😃" "😄" "😅" "😆" "😉" "😊"
# 11–20
"😋" "😎" "😍" "😘" "😗" "😙" "😚" "🙂" "🤗" "🤩"
# 21–30
"🤔" "🤨" "🧐" "🙄" "😏" "😒" "😞" "😔" "😟" "😕"
# 31–40
"🙁" "☹️" "😣" "😖" "😫" "😩" "🥺" "😢" "😭" "😤"
# 41–50
"😠" "😡" "🤬" "🤯" "😳" "🥵" "🥶" "😶" "😐" "😑"
# 51–60
"😶🌫️" "😴" "😪" "😮" "😯" "😲" "🥱" "🤤" "😇" "🤠"
# 61–70
"🤑" "😈" "👿" "👹" "👺" "🤡" "💀" "☠️" "👻" "👽"
# 71–80
"👾" "🤖" "😺" "😸" "😹" "😻" "😼" "😽" "🙀" "😿"
# 81–90
"😾" "🙈" "🙉" "🙊" "🐵" "🐒" "🦍" "🦧" "🐶" "🐕"
# 91–100
"🦮" "🐕🦺" "🐩" "🐺" "🦊" "🐱" "🐈" "🐈⬛" "🐯" "🐅"
# 101–110
"🐆" "🐴" "🐎" "🦄" "🦓" "🦌" "🦬" "🐮" "🐂" "🐃"
# 111–120
"🐄" "🐷" "🐖" "🐗" "🐽" "🐸" "🐊" "🐢" "🦎" "🐍"
# 121–130
"🐲" "🐉" "🦕" "🦖" "🐳" "🐋" "🐬" "🐟" "🐠" "🐡"
# 131–140
"🦈" "🐙" "🐚" "🪸" "🦀" "🦞" "🦐" "🦑" "🦪" "🐌"
# 141–150
"🦋" "🐛" "🐜" "🐝" "🪲" "🐞" "🦗" "🪳" "🕷️" "🕸️"
# 151–160
"🦂" "🐦" "🐧" "🐥" "🐤" "🐣" "🦆" "🦅" "🦉" "🦇"
# 161–170
"🐺" "🐗" "🦝" "🐴" "🦄" "🦓" "🦌" "🐝" "🪱" "🪰"
# 171–180
"🪲" "🪳" "🦟" "🦗" "🕷️" "💪" "👈" "👉" "👆" "👇"
# 181–190
"👍" "👎" "👊" "🤛" "🤜" "👏" "🙌" "👐" "🤲" "🤝"
# 191–200
"🙏" "✍️" "💅" "🤳" "💋" "👄" "🦷" "👅" "👂" "👃"
)
export EMOTE="${emojis[$RANDOM % ${#emojis[@]}]}"
echo $EMOTE | copy
echo "Found: " && paste
}
# Open manual for random command when you bored
bored() {
local manpage=$(man -k . | awk '{print $1}' | shuf -n 1)
if [[ -n $manpage ]]; then
man "$manpage"
else
echo "No man's system!"
fi
}
# Moody ECHO
function mecho() {
local moods=("cheerful" "grumpy" "sarcastic" "enthusiastic" "tired" "brooding" "eccentric" "philosophical")
local chosen_mood=${moods[$RANDOM % ${#moods[@]}]}
case "$chosen_mood" in
cheerful)
echo "✨ $* ✨"
;;
grumpy)
echo "Ugh... $*"
;;
sarcastic)
echo "Oh, *really*? $*..."
;;
enthusiastic)
echo "WOW!! $*!! AMAZING!!"
;;
tired)
echo "*yawn* $*..."
;;
brooding)
echo "Hm. $*. Sometimes I wonder..."
;;
eccentric)
echo "Behold: $* !"
;;
philosophical)
echo "$*. But is that truly what we mean, in the grand scheme of things?"
;;
esac
}
# Sad PWD - BUGGED
#function pwdd() {
# echo "You are here: $(builtin pwd)"
# echo "But does 'here' even matter anymore?"
#}
# FREE WISDOM
function wisdom() {
if command -v fortune >/dev/null && command -v cowsay >/dev/null; then
tfortune print | cowsay
else
echo "I can't predict the future without fortune or cowsay installed..."
fi
}
# Quality comments
function git() {
local quotes=(
"Keep calm and commit often."
"In git we trust."
"One commit at a time."
"Refactor like there's no tomorrow."
"Push code, not regrets."
"Code is ephemeral, commits are eternal."
)
local random_quote=${quotes[$RANDOM % ${#quotes[@]}]}
if [[ "$1" == "commit" ]]; then
echo "🤖 ${random_quote}"
fi
command git "$@"
}
# Typewriter CAT
function typecat() {
while IFS= read -r line; do
for (( i=0; i<${#line}; i++ )); do
printf "%s" "${line:$i:1}"
sleep 0.025
done
printf "\n"
done < "$1"
}
# Motivational Exit
function exit() {
echo "Remember, bugs are temporary, Linux is forever!"
sleep 2.5
builtin exit
}
# Overdramatic MKDIR
function mkdir() {
echo "Summoning a new directory from the void..."
command mkdir "$@"
echo "It has been done. BEHOLD! The realm is created!"
}
# Omnious PING
function ping() {
echo "Sending out requests... searching for signs of life..."
command ping "$@"
}
# BAD TOUCH! xD
function touch() {
echo "It rubs the code... Come baby, let me hug you hehe"
command touch "$@"
}
# MV Ain't fuckin around
alias moveit='mv'
function mv() {
local QUO=(
"\nYEEET!!\n"
"\nFucken Way She Goes!\n"
""
)
local RQUO=${QUO[$RANDOM % ${#QUO[@]}]}
echo $RQUO
command mv "$@"
}
# Silent nohup
function nohups() {
nohup "$@" &>/dev/null &
}
# Disable EOL
export PROMPT_EOL_MARK=""
# Define current shell .rc as $SHRC
case "$SHELL" in
*/bash)
export SHRC="$HOME/.bashrc"
;;
*/zsh)
export SHRC="$HOME/.zshrc"
;;
*/ksh)
export SHRC="$HOME/.kshrc"
;;
*/fish)
export SHRC="$HOME/.config/fish/config.fish"
;;
*)
# Fallback for other shells
export SHRC="$HOME/.profile"
;;
esac
# Reloadrc (assuming you have shrc func defined)
alias reloadrc="source $SHRC"
# Unload run config
unsource() {
local file="$1"
# Check if the file exists
if [[ ! -f "$file" ]]; then
echo "File not found: $file"
return 1
fi
# Unset all variables defined in the file
while IFS= read -r line; do
if [[ "$line" =~ ^([A-Za-z_][A-Za-z0-9_]*)= ]]; then
unset "${BASH_REMATCH[1]}"
fi
done < <(grep -E '^[A-Za-z_][A-Za-z0-9_]*=' "$file")
# Unset all functions defined in the file
while IFS= read -r func_name; do
unset -f "$func_name"
done < <(declare -F | awk '{print $NF}' | grep -Fxf <(grep -oP '^[A-Za-z_][A-Za-z0-9_]*(?=\(\))' "$file"))
# Unalias all aliases defined in the file
while IFS= read -r alias_name; do
unalias "$alias_name" 2>/dev/null
done < <(grep -oP '^alias\s+\K[A-Za-z_][A-Za-z0-9_]*' "$file")
# Unset all exported variables defined in the file
while IFS= read -r export_var; do
unset "$export_var"
done < <(grep -oP '^export\s+\K[A-Za-z_][A-Za-z0-9_]*' "$file")
echo "Unloaded file: $file"
}
# alias tezt="source ~/.testrc"
mkcd() {
mkdir -p "$1" && cd "$1"
}
# ======== QUICK CLEANUP ============
tidy() {
# Ensure the base directories exist
mkdir -p "$HOME/Media"/{Pictures,Video,Audio,Documents,Misc}
# Function to move files and avoid overwriting
move_file() {
local src_file="$1"
local dest_dir="$2"
# Extract the file name and extension
local base_name="${src_file:t}"
local name="${base_name%.*}"
local ext="${base_name##*.}"
local dest_file="$dest_dir/$base_name"
local counter=0
# Check for conflicts and append a number if needed
while [[ -e "$dest_file" ]]; do
dest_file="$dest_dir/${name}-${counter}.${ext}"
((counter++))
done
mv "$src_file" "$dest_file"
}
# Pictures
for file in *.gif(N); do
[[ -e "$file" ]] && move_file "$file" "$HOME/Media/Pictures"
echo "Moved $file"
done
for file in *.jpg(N); do
[[ -e "$file" ]] && move_file "$file" "$HOME/Media/Pictures"
echo "Moved $file"
done
for file in *.png(N); do
[[ -e "$file" ]] && move_file "$file" "$HOME/Media/Pictures"
echo "Moved $file"
done
# Audio
for file in *.mp3(N); do
[[ -e "$file" ]] && move_file "$file" "$HOME/Media/Audio"
echo "Moved $file"
done
for file in *.wav(N); do
[[ -e "$file" ]] && move_file "$file" "$HOME/Media/Audio"
echo "Moved $file"
done
# === CUSTOMIZE UP TO PREFERENCES ===
echo "Files organized!"
}
# Extract
extract() {
if [ -f "$1" ]; then
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xvf "$1" ;;
*.tbz2) tar xvjf "$1" ;;
*.tgz) tar xvzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "Cannot extract '$1'" ;;
esac
else
echo "'$1' is not a valid file."
fi
}
# Man Syntax Highlight
export LESS_TERMCAP_mb=$'\e[1;31m' # Red
export LESS_TERMCAP_md=$'\e[1;35m' # Magenta
export LESS_TERMCAP_me=$'\e[0m' # Reset
export LESS_TERMCAP_se=$'\e[0m' # Reset
export LESS_TERMCAP_so=$'\e[1;44;33m' # Yellow on blue
export LESS_TERMCAP_ue=$'\e[0m' # Reset
export LESS_TERMCAP_us=$'\e[1;32m' # Green
# Short weather
alias 'weather-short'='clear && echo "\n" && curl "wttr.in/?0Q" && echo "\n"'
# List all Aliases, Variables & Functions
listrc() {
local file="$1"
local tmpfile="/tmp/list_definitions_output"
# Clear the temporary file
: > "$tmpfile"
# Check if the file exists
if [[ ! -f "$file" ]]; then
echo "File not found: $file"
return 1
fi
# Write headers to the temporary file
echo "# Aliases:" >> "$tmpfile"
# Extract aliases
grep -E '^[[:space:]]*alias[[:space:]]+[a-zA-Z0-9_]+=' "$file" | \
sed -E 's/^[[:space:]]*alias[[:space:]]+([a-zA-Z0-9_]+)=.*/\1/' >> "$tmpfile"
echo >> "$tmpfile"
echo "# Functions:" >> "$tmpfile"
# Extract functions
grep -E '^[[:space:]]*(function[[:space:]]+[a-zA-Z0-9_]+|[a-zA-Z0-9_]+[[:space:]]*\(\))' "$file" | \
sed -E 's/^[[:space:]]*(function[[:space:]]+)?([a-zA-Z0-9_]+).*/\2/' >> "$tmpfile"
echo >> "$tmpfile"
echo "# Variables:" >> "$tmpfile"
# Extract variables
grep -E '^[[:space:]]*(export|declare[[:space:]]+-x)[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]*' "$file" | \
sed -E 's/^[[:space:]]*(export|declare[[:space:]]+-x)[[:space:]]*([a-zA-Z_][a-zA-Z0-9_]*).*/$\2/' >> "$tmpfile"
# Display the result
cat "$tmpfile"
}
# CLI Clock in ASCII
# Flags: -t (toilet) / --font <font name> / -s (with seconds)
clock() {
cmd="figlet"
args=()
fmt="%H:%M"
while [[ $# -gt 0 ]]; do
case $1 in
-t|--toilet)
cmd="toilet"
shift
;;
-s|--seconds)
fmt="%H:%M:%S"
shift
;;
*)
args+=("$1")
shift
;;
esac
done
while true; do
clear
tput civis
out="$(date +"$fmt" | $cmd "${args[@]}")"
rows=$(echo "$out" | wc -l)
cols=$(echo "$out" | head -n1 | wc -c)
term_rows=$(tput lines)
term_cols=$(tput cols)
pad_top=$(( (term_rows - rows) / 2 ))
pad_left=$(( (term_cols - cols) / 2 ))
for ((i=0; i<pad_top; i++)); do echo; done
echo "$out" | while IFS= read -r line; do
printf "%*s%s\n" $pad_left "" "$line"
done
sleep 1
done
tput cnorm
}
# List all ASCII fonts
ascii_fonts() {
tool="figlet"
ex="flf"
dirs=(/usr/share/figlet/fonts)
if [[ $1 == "-t" || $1 == "--toilet" ]]; then
tool="toilet"
ex="tlf"
dirs=(/usr/share/figlet)
shift
fi
found=0
for dir in "${dirs[@]}"; do
[[ -d $dir ]] || continue
for f in "$dir"/*.$ex(N); do
[[ -f $f ]] || continue
font=$(basename "$f" .${ex})
echo "---------------------------"
if [[ $tool == "figlet" ]]; then
figlet -f "$font" example
else
toilet -f "$font" example
fi
echo "$font"
echo
found=1
done
done
[[ $found -eq 1 ]] || echo "No fonts found. Blame Bill Gates."
}