Fozzologs

RSS Feeds

About...

These posts are the creation of Doran L. Barton (AKA Fozziliny Moo). To learn more about Doran, check out his website at fozzilinymoo.org.

Right Side

This space reserved for future use.

Quest for terminal application nirvana

Posted: 30 November 2006 at 21:43:23

The real power of using Linux/Unix is in the command-line interface. As a result, terminal applications are the bread and butter of the Linux/Unix power user. That is, if they use a graphical user interface. If they're some kind of wacky console-only freak, that's another story.

Anyway... where was I? Oh yeah, terminal applications. I've never been completely satisfied with any of the standard offerings. Over the years I've used xterm, aterm, eterm, gnome-terminal, konsole, and some others I can't remember the names of. KDE's konsole and gnome-terminal are both pretty and all, but seem to be lacking in a few areas of terminal emulation. It seems programs like mutt do a good job of breaking terminal emulation if there's a weakness to be exploited.

Plus, konsole and gnome-terminal just take too frickin' long to start up. In my mind, terminal applications are doing something very simple and therefore should be lightweight and should launch instantaneously when needed.

One thing I do like about KDE's and GNOME's terminal apps is the support for tabs. If you're willing to push your mouse around a bit, you can even change the names/titles of each tabbed terminal session to something more meaningful than the default "Shell No. 99" or GNOME's standard: "Terminal."

Both of these terminal apps also have hot keys like CTRL+SHIFT+N (KDE) or CTRL+SHIFT+T (GNOME) to create new tabs. That's handy, but not as handy as it could be.

What would be ideal, in my little world, is a way to create new, customized tabs in a terminal application via the command line.

Next, I find I usually want to dedicate each terminal session I create to a specific task like:

  • Running a yum -y update
  • Opening an SSH connection to a remote host
  • Viewing a local file with less
  • Miscellaneous/general filesystem interaction

Creating a new tab is only the first of a few steps I must take to create a new session, distinguish it from others that may be open, and, if applicable, run a command in the terminal.

When running multiple terminal sessions in a graphical environment without any kind of significantly distinguishing characteristics associated with each terminal session, it's easy to get confused. I know I'm not the only person who types something like sudo poweroff into a terminal session only to realize afterward the system being shut down isn't the one you meant to shut down. In worse cases, it's a system you don't have physical access to.

fterm

I'm always open to new solutions, but for now, I have a shell script that I've maintained for several years called fterm (FozzTerm) that I run anytime I need a new terminal window. In its most basic form, fterm is just a fast way for me to launch a new terminal session with the geometry and foreground/background colors I prefer.

Since most of my terminal interaction involves SSH connections to remote systems, fterm also makes doing this more convenient. If I add a parameter after the fterm command, the script assumes I want to open an SSH connection to the host named by the parameter. A new terminal session will be launch and ssh will be run in that session.

Additionally, fterm inserts the hostname into the titlebar of the terminal session window which makes it so much easier to identify a specific session or remind myself which host I'm working with.

This works great when I want to log into the remote host using the same username I'm using when I execute the fterm script, but it's not uncommon for me to need to log into a remote system using a different username.

So, I originally modified the fterm script to prompt for a username, indicating that if the user merely pressed the ENTER key, the current username would be used.

% fterm foo.bar.com
[fozz] jdoe

This made things easier, but eventually I realized it could be better. My improvement was creating a cache of usernames associated with hostnames which could be looked at anytime you called fterm with a hostname as parameter. So, the next time you opened an fterm session to foo.bar.com:

% fterm foo.bar.com
[jdoe]

Lately, the actual terminal application run by my fterm script is xterm, but I have configured it to use other application as well.

In the interest of providing others with code they can use or inspiring them to come up with a tool that improves their own productivity, I'm including the code for fterm below. I'd also be interested in, perhaps, better solutions people have created or found.