|
||
Home Articles Authors Links Useful Tips Polls HOWTOs |
|
Useful Tip # 8I tend to get lost with the number of terminals I use on a regular basis. Because I work with a number of systems at the same time, I want a reminder of who I am and where I am to show up in the xterm titlebar. Once I've done that, the task lists that are available in gnome use that description instead of just "xterm". Here's how I did it. Add the following lines to /etc/bashrc: SHOSTNAME=`hostname -s` PROMPT_COMMAND='if [ "${TERM}" = "xterm" -o "${TERM}" = "xterm-color" ]; then if [ -n "${XTITLE}" ]; then echo -ne "\033]0;${XTITLE}\007" ; else echo -ne "\033]0;${USER}@${SHOSTNAME} ${PWD}\007" | sed -e "s@${HOME}@\~@" ; fi ; fi' export PROMPT_COMMAND SHOSTNAME Note that the PROMPT_COMMAND line is split to avoid wrapping, but everything from PROMPT_COMMAND= to fi' needs to be on a single line. Now, the XTERM titlebar is reset every time a command is run. It shows me what machine I'm on, what user I'm logged in as, and what directory I'm in, like: wstearns@sparrow /tmp If I happen to be in a directory relative to my home directory it shows up as: wstearns@sparrow ~/mail In addition, if I want to force the titlebar to stay at a given string all the time, all I have to type in the shell is: XTITLE=Inbox and it stays that way until I type: unset XTITLE at which point it reverts to showing me the user@host /dir version. This extra reminder has helped me avoid typing "shutdown -r now" in the wrong terminal. And yes, I have done that, ahem, once or twice. But never on any absolutely crucial machine that has to stay up. *smile* Thanks to William Stearns for this tip. Other Tips
If you have a useful tip you want to share with the community please let us know at: suggestions@www.linuxmonth.com |
0.4.0 | Copyright to all articles belong to their respective authors. Everything else © 2024 LinuxMonth.com Linux is a trademark of Linus Torvalds. Powered by Apache, mod_perl and Embperl. |