-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc-personal-fedora
522 lines (431 loc) · 16 KB
/
.bashrc-personal-fedora
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
# -----------------------------------------------------
# ~/.bashrc
# -----------------------------------------------------
# ASCII Art Header
# | |__ __ _ ___| |__ _ __ ___
# | '_ \ / _` / __| '_ \| '__/ __|
# _| |_) | (_| \__ \ | | | | | (__
# (_)_.__/ \__,_|___/_| |_|_| \___|
# -----------------------------------------------------
# -----------------------------------------------------
# ENVIRONMENT VARIABLES
# -----------------------------------------------------
export HISTFILESIZE=10000
export HISTSIZE=500
export PATH="/usr/lib/ccache/bin/:$PATH"
export OLLAMA_API_BASE="http://localhost:11434"
# -----------------------------------------------------
# SHELL OPTIONS
# -----------------------------------------------------
bind "set completion-ignore-case on"
bind '"\C-f":"zi\n"'
# -----------------------------------------------------
# ALIASES
# -----------------------------------------------------
# System Management
alias sf='sudo setfont ter-128b'
alias c='clear'
alias shutdown='sudo shutdown -P now'
alias reboot='sudo shutdown -r now'
alias logout='pkill -TERM chadwm'
alias update='sudo dnf update && sudo dnf upgrade -y'
alias dnfc='sudo dnf clean all'
alias dnfp='sudo dnf autoremove -y'
alias update-grub='sudo grub-mkconfig -o /boot/grub/grub.cfg'
alias setkb='setxkbmap gb && echo "Keyboard set back to gb."'
alias unlock="sudo rm /var/lib/pacman/db.lck"
alias rmpacmanlock="sudo rm /var/lib/pacman/db.lck"
alias gui="sudo systemctl isolate graphical.target"
# File and Directory Management
alias v='nvim'
alias shot='scrot -d 3 -c -z -u'
alias shotsel='scrot -s'
alias dot="cd ~/dotfiles"
alias wdownload='sudo mount --bind ~/Downloads ~/.local/share/waydroid/data/media/0/Download'
alias cd..="cd .."
alias hs="cd ~/ && ls"
alias up="cd .."
alias home="cd ~/"
alias root="sudo su"
alias mkdir="mkdir -pv"
alias hist="history"
alias jobs="jobs -l"
alias path="echo -e ${PATH//:/\\n}"
# Network Management
alias wifi='nmtui'
alias ports="netstat -tulanp"
alias whatismyip="whatsmyip"
# Window Managers
alias Qtile='startx'
alias QtileWayland='qtile start -b wayland'
alias xfce='exec startxfce4'
alias chadwm='startx ~/dotfiles/arco-chadwm/scripts/run.sh'
alias flexidwm='startx ~/dotfiles/flexi/autostart.sh'
alias cosmic='startx gnome-session --session=pop'
# Docker Management
alias dps='docker ps -a'
alias dimages='docker images'
alias dlogs='docker logs'
alias dexec='docker exec -it'
alias drm='docker rm'
alias drmi='docker rmi'
alias dstopall='docker stop $(docker ps -a -q)'
alias drmall='docker rm $(docker ps -a -q)'
alias dprune='docker system prune -a'
alias dcup='docker-compose up -d'
alias ds='docker start'
# SSH Management
alias sshs='sudo service sshd start'
alias sshstatus='sudo service sshd status'
# Git Management
alias gs="git status"
alias ga="git add"
alias gc="git commit -m"
alias gp="git push"
alias gpl="git pull"
alias gst="git stash"
alias gsp="git stash; git pull"
alias gcheck="git checkout"
alias gcom="git add . && git commit -m \"$1\""
alias lazyg="git add . && git commit -m \"$1\" && git push"
# Virtual Machine Management
alias vm='~/private/launchvm.sh'
alias lg='~/dotfiles/scripts/looking-glass.sh'
alias vmstart='virsh --connect qemu:///system start win11'
alias vmstop='virsh --connect qemu:///system destroy win11'
alias vmstatus='virsh --connect qemu:///system list --all'
# Config Files Management
alias confq='nvim ~/dotfiles/qtile/config.py'
alias confb='nvim ~/dotfiles/.bashrc-personal-fedora'
alias confp='nvim ~/dotfiles/.setup/install-packages.sh'
alias catb='cat ~/dotfiles/.bashrc-personal-fedora'
alias notes='vim ~/notes.txt'
# Grep and ls Aliases
alias grep="grep --color=auto"
alias l.="ls -d .* --color=auto"
alias ls="ls -C --color=auto"
alias lm="ls -lhA --color=auto | more"
alias ll="ls -lh --color=auto"
alias la="ls -lhA --color=auto"
alias lar="ls -lhAR --color=auto | more"
alias lcr="ls -CAR --color=auto | more"
alias lx='ls -la --color | grep "^d" && ls -la | grep "^-" && ls -la | grep "^l"'
# Time Related Aliases
alias now="date +\"%T\""
alias nowtime=now
alias nowdate="date +\"%d-%m-%Y\""
# Miscellaneous Aliases
alias df='df -h'
alias lock='xscreensaver-command -lock'
alias matrix='cat /dev/urandom'
alias removesvn='rm -rf `find . -type d -name .svn`'
alias syslog='sudo cat /var/log/messages'
alias beets='beet import ~/Music'
alias update-fc='sudo fc-cache -fv'
alias speedtest='speedtest-cli'
alias fix-thorium='rm -f /home/abu/.config/thorium/lockfile /home/abu/.config/thorium/SingletonLock /home/abu/.config/thorium/SingletonSocket /home/abu/.config/thorium/SingletonCookie'
alias yt="youtube-dl -ci"
alias ytp="youtube-dl -tAci"
alias ytm="youtube-dl -cif 251"
# Custom Scripts
alias gr='python ~/dotfiles/scripts/growthrate.py'
alias ChatGPT='python ~/mychatgpt/mychatgpt.py'
alias chat='python ~/mychatgpt/mychatgpt.py'
alias ascii='~/dotfiles/scripts/figlet.sh'
alias startSillyTavern='cd /home/abu/Documents/Repos/SillyTavern && nohup ./start.sh > /dev/null 2>&1 &'
# -----------------------------------------------------
# FUNCTIONS
# -----------------------------------------------------
# Network interface management
find_interface() {
local default_interface="enp1s0"
local interface_name=$(ip -4 addr show up | grep -E '^[0-9]+: ' | grep -v 'docker0' | head -n 1 | awk '{print $2}' | sed 's/://')
if [[ -z "$interface_name" ]]; then
echo "No active Ethernet interfaces found. Using default interface '$default_interface'."
interface_name="$default_interface"
fi
echo "$interface_name"
}
# Alias functions for IP management
alias set_ip='
interface_name=$(find_interface)
current_ip=$(ip -4 addr show "$interface_name" | grep "inet 10.0.1.200")
if [[ -z "$current_ip" ]]; then
echo "Setting IP 10.0.1.200/24 on interface: $interface_name"
sudo ip addr add 10.0.1.200/24 dev "$interface_name"
else
echo "IP 10.0.1.200/24 is already set on interface: $interface_name"
fi
'
alias reset_ip='
interface_name=$(find_interface)
current_ip=$(ip -4 addr show "$interface_name" | grep "inet 10.0.1.200")
if [[ -n "$current_ip" ]]; then
echo "Removing IP 10.0.1.200/24 from interface: $interface_name"
sudo ip addr del 10.0.1.200/24 dev "$interface_name"
else
echo "IP 10.0.1.200/24 is not set on interface: $interface_name"
fi
'
# Unmute and max volume for Master
unmute-all() {
amixer sset Master unmute
amixer sset Master 100%
}
# Copy file with a progress bar
cpp() {
set -e
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 | awk '{
count += $NF
if (count % 10 == 0) {
percent = count / total_size * 100
printf "%3d%% [", percent
for (i=0;i<=percent;i++)
printf "="
printf ">"
for (i=percent;i<100;i++)
printf " "
printf "]\r"
}
}
END { print "" }' total_size="$(stat -c '%s' "${1}")" count=0
}
# Show current network information
netinfo() {
echo "--------------- Network Information ---------------"
/sbin/ifconfig | awk /'inet addr/ {print $2}'
echo ""
/sbin/ifconfig | awk /'Bcast/ {print $3}'
echo ""
/sbin/ifconfig | awk /'inet addr/ {print $4}'
/sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
echo "---------------------------------------------------"
}
# IP address lookup (internal and external)
whatsmyip() {
if [ -e /sbin/ip ]; then
echo -n "Internal IP: "
/sbin/ip addr show wlan0 | grep "inet " | awk '{print $2}'
else
echo -n "Internal IP: "
/sbin/ifconfig wlan0 | grep "inet " | awk '{print $2}'
fi
echo -n "External IP: "
curl -s ifconfig.me
}
# Git reset to origin/main
git_reset_hard_main() {
git fetch origin
git reset --hard origin/main
}
# Extract various archive formats
ex() {
if [ -f "$1" ]; then
case $1 in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1";;
*.7z) 7z x "$1" ;;
*.xz) unxz "$1" ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
vento() {
cd /opt/ventoy && sudo bash ./VentoyWeb.sh
}
# Function to get list of Ollama models
list_ollama_models() {
echo -e "${yellow}Ollama Models Available:${green}"
if command -v ollama &> /dev/null; then
ollama list | awk 'NR>1 {print $1}'
else
echo -e "${red}Error: Ollama command not found. Is Ollama installed?${reset}"
fi
}
# Function to list virtual machines and their statuses
list_vm_status() {
echo -e "${yellow} Virtual Machines and Their Status:${green}"
virsh --connect qemu:///system list --all
if [ $? -ne 0 ]; then
echo -e "${red}Error: Unable to retrieve VM information.${reset}"
fi
}
# Function to get Docker status and port information
docker_status() {
echo -e "${yellow} Docker Status:${green}"
docker info --format '{{.ServerVersion}} - {{.Name}}'
echo -e "${yellow} Docker Port Mappings:${green}"
docker ps --format "table {{.Names}}\t{{.Ports}}"
}
function project_overview() {
local output_file="${1:-project_structure_and_code.txt}"
local depth="${2:-8}"
# Define exclusions
local -a excludes=(
"logs"
"project_structure_and_code.txt"
"readme.md"
"readme_no2.md"
".git"
".vscode"
"node_modules"
"sim-management-setup-script.sh"
"up.sh"
"error_log"
)
# Join array with | for tree command
local tree_exclude=$(IFS="|"; echo "${excludes[*]}")
# Create find command with proper exclusions
local find_cmd="find ."
for item in "${excludes[@]}"; do
if [[ "$item" == .* ]]; then
# Directory exclusion (starts with dot)
find_cmd+=" -not -path \"*/$item/*\""
else
# File exclusion
find_cmd+=" -not -name \"$item\""
fi
done
find_cmd+=" -type f -exec echo {} \; -exec cat {} \; -exec echo \;"
(
# Print directory structure
tree -L "$depth" -I "$tree_exclude" && \
# Execute the find command
eval "$find_cmd"
) > "$output_file"
# Debug output - uncomment to see the actual command being run
# echo "Tree command: tree -L $depth -I \"$tree_exclude\""
# echo "Find command: $find_cmd"
echo "Project overview saved to $output_file"
}
# -----------------------------------------------------
# WELCOME MESSAGE
# -----------------------------------------------------
welcome_message() {
# Set colors
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
blue='\033[0;34m'
reset='\033[0m'
# Get SSH service status
ssh_status=$(systemctl is-active sshd)
if [ "$ssh_status" = "active" ]; then
ssh_status="${green}Running${reset}"
else
ssh_status="${red}Stopped${reset}"
fi
# Welcome banner
figlet -f slant "${green}Welcome to Fedora"
echo "==============================================================="
# Fedora version
echo -e "${yellow}Fedora Version\t\t:${green} $(cat /etc/fedora-release)"
# Date and time
echo -e "${yellow}Current Date/Time\t:${green} $(date)"
# Kernel information
echo -e "${yellow}Kernel Information\t:${green} $(uname -smr)"
# Current directory
echo -e "${yellow}Current Directory\t:${green} $(pwd)"
echo "==============================================================="
# User information
echo -e "${yellow}Logged in as\t\t:${green} $(whoami)"
echo -e "${yellow}User's home\t\t:${green} $HOME"
# IP addresses
internal_ip=$(hostname -I | awk '{print $1}')
external_ip=$(curl -s ifconfig.me)
echo -e "${yellow}Internal IP\t\t:${green} $internal_ip"
echo -e "${yellow}External IP\t\t:${green} $external_ip"
echo "==============================================================="
# System information
echo -e "${yellow}Hostname\t\t:${green} $(hostname)"
echo -e "${yellow}System Uptime\t\t:${green} $(uptime -p)"
echo -e "${yellow}CPU Load\t\t:${green} $(uptime | awk -F'load average: ' '{ print $2 }')"
echo -e "${yellow}Memory Usage\t\t:${green} $(free -h | awk '/^Mem/ {print $3 "/" $2}')"
echo -e "${yellow}Disk Usage\t\t:${green} $(df -h / | awk '/\// {print $5 " (" $3 "/" $2 ")"}')"
echo -e "${yellow}CPU Info:${green} $(lscpu | grep 'Model name' | cut -f 2 -d ":")"
echo -e "${yellow}GPU Info\t\t:${green} $(lspci | grep -i vga | cut -d ":" -f3)"
echo -e "${yellow}SSH Service\t\t:${ssh_status}"
echo "==============================================================="
# Package information
echo -e "${yellow}Installed Packages\t:${green} $(rpm -qa | wc -l)"
echo -e "${yellow}Available Updates\t:${green} $(dnf check-update --quiet | grep -v "^$" | wc -l)"
echo "==============================================================="
# Network interface information
gateway_interface=$(ip -o link show | grep -E 'enp|eth|wlan' | awk -F': ' '{print $2}' | head -n 1)
if [ -n "$gateway_interface" ]; then
gateway_ip=$(ip -o -4 addr list "$gateway_interface" | awk '{print $4}' | cut -d/ -f1)
if [ -n "$gateway_ip" ]; then
echo -e "${yellow}Gateway Interface (${gateway_interface}) IP:${green} $gateway_ip"
else
echo -e "${red}Warning: No IP assigned to gateway interface ${gateway_interface}.${reset}"
fi
else
echo -e "${red}Warning: No network interface matching enp or eth found.${reset}"
fi
echo "==============================================================="
# Virtual Machine Status
echo -e "${yellow}Virtual Machine Status:${green}"
list_vm_status
echo "==============================================================="
# Docker Status and Port Mappings
docker_status
echo "==============================================================="
# Ollama Models
echo -e "${yellow}Ollama Models:${green}"
list_ollama_models
echo "==============================================================="
# List block devices
lsblk -o NAME,TYPE,GROUP,SIZE,VENDOR,MOUNTPOINT
echo "==============================================================="
# Network devices status
nmcli d
echo "==============================================================="
# List available Wi-Fi networks
nmcli device wifi list
echo "==============================================================="
# List connected Bluetooth devices
echo -e "${yellow}Bluetooth Devices\t:${green}"
bluetoothctl devices Connected | awk -F ' ' '{print $3,$4,$5}'
echo "==============================================================="
# SELinux status
echo -e "${yellow}SELinux Status\t\t:${green} $(getenforce)"
# Firewall status
echo -e "${yellow}Firewall Status\t\t:${green} $(systemctl is-active firewalld)"
# Last system boot
echo -e "${yellow}Last System Boot\t:${green} $(who -b | awk '{print $3,$4}')"
# Last logged in users
echo -e "${yellow}Last Logins:${green}"
last -n 5 | head -n 5
echo "====================== W E L C O M E ========================"
# Reset colors
echo -e "${reset}"
}
alias ollama-qwen-download="ollama pull qwen2.5-coder:32b"
# -----------------------------------------------------
# INITIALIZATIONS
# -----------------------------------------------------
# Enable bash programmable completion features
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Zoxide Initialization
eval "$(zoxide init bash)"
# Starship Prompt
eval "$(starship init bash)"
# Run welcome message on startup
# welcome_message
# -----------------------------------------------------
# END OF ~/.bashrc
# -----------------------------------------------------