long time reader, 1st time asking a question...
So I've been trying to "build a basic bash based OS" (for lack of a better term), using only built in bash commands
So far I have 2 scripts that I've managed to put together, 1 provides network info, the other provides basic system information:
NETWORK SCRIPT:
#!/bin/bash
watch -t -n 1 "echo 'NETWORK:' && date &&
echo 'Hostname: $(uname -n)'
echo 'Host I.P : $(ip r | grep src | awk '{print $9}')'
echo 'Uptime: $(uptime)'
echo 'Users: $(users)'
echo
echo 'ROUTER:'
echo 'I.P: $(ip r| grep 'default'| awk '{print $3}')'
echo 'MAC: $(iwconfig | grep Access | awk '{print $6}')'
echo 'ESSID: $(iwgetid -r)'
echo 'Public I.P: $(wget -qO- https://ipecho.net/plain)'
"
Here is the SYSTEM script:
#!/bin/bash
watch -t -n 1 "
echo 'SYSTEM:'
date
uptime -s
uptime -p
echo '\\t\t\t\t PROCESSES:'
ps aux | head -n7
echo '\\t\t\t\t CPU:'
lscpu | grep Hz
echo
echo '\\t\t\t\t RAM:'
free -m -h
echo
echo '\\t\t\t\t STORAGE:'
lsblk -l | grep sd
echo
"
With these, I'm using the watch command so that the output refreshes itself every second,
but I was wanting to know if it was possible for me to add a "press Q to quit" option in there anywhere?..
The Idea is that I could have a "main menu" where I could select an option, and have it open up, preferably in the same window but no drama if I can't...
I also have another script that I can run, that will allow me to have both of these scripts open in their own window:
#!/bin/bash
# run v1.0.0.0
# Automates loading:
# SYSTEM INFORMATION:
gnome-terminal -- sh -c "bash -c \"!!; exec bash system.sh \""
# NETWORK INFORMATION:
gnome-terminal -- sh -c "bash -c \"!!; exec bash network.sh \""
Keep in mind (as you can all probably tell),I'm still very new to this whole bash thing, so I would love to learn some wisdom from the gods.
Currently using Ubuntu 20.04
Any replies greatly appreciated