So the terminal is something that a program uses all the time but the default terminals on Unix distros looks very plain and boring in my opinion.
While I really like the Kali Linux terminal style I use my Xubuntu distro much more often, its my personal favourite. So I decided to customize it and make it look more interesting.
Before
After
The customized terminal when opened prints:
- The current date and time
- CPU usage (I came up for some code specifically for this project)
- Available memory
- Storage Usage
- A nice ‘Aperture Laboratories’ background
- A cow who spits out a random quote! (using cowsay and fortune )
How to get the above terminal style
To replicate the colours and style, simply copy the preferences from the image below. These settings should be pretty similar on all graphics based Linux distributions.
You can download the Aperture Laboratories background image by Download Aperture Laboratories Terminal Wallpaper.
You will have to modify your bash preference files to get the terminal welcome message printed at the top of the terminal when you spawn a new shell (bash prompt).
Navigate to your home directory and add the following to the end of your .bash_profile file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# Terminal welcome message terminal_welcome() { date +"%A, %d %B %Y, %I:%M:%S %p" #Date in nice format # CPU echo -n CPU usage: $(echo print `top -n 1 | tr -s " " | cut -d$" " -f10 | tail -n +8 | head -n -1 | paste -sd+ | bc`/ `nproc` | python)% echo -n " | " # Memory in use echo -n Available memory: `cat /proc/meminfo | grep "MemFree" | tr -s " " | cut -d$" " -f2-` / `cat /proc/meminfo | grep "MemTotal" | tr -s " " | cut -d$" " -f2-` echo -n " | " # XX% of storage used (XXG out of XXG) echo `df -h --total | tail -1 | tr -s " " | cut -d$' ' -f5` storage used \(`df -h --total | tail -1 | tr -s " " | cut -d$' ' -f3` / `df -h --total | tail -1 | tr -s " " | cut -d$' ' -f2`\) fortune | cowsay echo -e "\n" } |
Next, append the following to .bashrc file:
1 2 3 4 5 |
# Source my bash profile in interactive mode source ~/.bash_profile # Show terminal welcome message terminal_welcome |
Now restart your terminal or spawn a new shell to see the results!
Note: The function which determines the CPU usage is a little slow so you may notice a slight delay (~150ms) every time you spawn a new shell. If this is a massive problem for you, simply remove the CPU usage line from the terminal welcome message.