Friday, June 21, 2013

Add hostname, date, time, uptime, users and load Average to Linux Terminal Title

This tip is really useful if you need/want to monitor multiple servers at the same time. This Tip works, as the tip, by which you can add the date and time the title of the Linux terminal, but it adds more usefull info to terminal title. Following bash one liner add hostname, date, time, uptime, users and load Average to Linux Terminal Title and updates it every second.

This trick works at least following terminals: Gnome Terminal, xterm, urxvt, rxvt.


Simply type the following command line:
while sleep 1;do echo -ne '\033]2;'`/bin/hostname`' - '`date +\%a\ %b\ %d`', '`/usr/bin/uptime`'\007';done&


[naveen@thelinuxwiki ~]$ while sleep 1;do echo -ne '\033]2;'`/bin/hostname`' - '`date +\%a\ %b\ %d`', '`/usr/bin/uptime`'\007';done&


With username@hostname on Terminal

[naveen@thelinuxwiki ~]$ while sleep 1;do echo -ne '\033]2;'`whoami`@`/bin/hostname`' - '`date +\%a\ %b\ %d`', '`/usr/bin/uptime`'\007';done&


With IP Addess on Terminal
[naveen@thelinuxwiki ~]$ while sleep 1;do echo -ne '\033]2;'`whoami`@`/bin/hostname`' - '` ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' ` `date +\%a\ %b\ %d`', '`/usr/bin/uptime`'\007';done&

If you want to get this working every time you open console or connect to remote server then you need just copy and paste that one liner to your ~/.bashrc files.


Example screenshot, using different servers






No comments:

Post a Comment