BASH RC Program Auto Start
Published: Sat, Jan 25, 2025
Today Vincent shares odd little thing you can do with BASH.
Links:
Video Notes
Edit your .bashrc file using:
nano ~/.bashrc
When you’re done using nano press CTL+X, then Y, and press enter to close and save the file.
Below is a example I created to start htop after 4 seconds. Hitting CTL+C will exit that if don’t want it to open.
if [ $(tty) == "/dev/pts/1" ]; then
echo "You're on TTY 1!"
echo "Launching htop in 4 seconds..."
sleep 4
htop
fi
Code Breakdown
The first line starts the if statement block. This is where we will test for the right TTY, and if found the lines within the if statement block will run.
if [ $(tty) == "/dev/pts/1" ]; then
# Anything here will run...
fi
This means that our echoes will run, then our sleep, and lastly the htop command will run. You end a if statement with a backward if, or fi.