Wandering Thoughts archives

2010-05-31

Another building block of my environment: sshterm

I am unreasonably fond of running X programs remotely; it's always struck me as one of the niftier bits of X, and I like to use it as much as possible. But even I have to admit that it's not always the right answer, and thus sometimes my rxterm script isn't what I want. For those times I have another script, which I unimaginatively call sshterm.

Sshterm is the direct inverse of rxterm; instead of using ssh to run a remote xterm, it uses a local xterm to run ssh to the remote machine, with some trimmings. Because this is a lot simpler a job than rxterm has, the script is a lot shorter, but it does have a few important features that complicate it a bit. First, it puts the remote machine's name in the xterm title so that I can tell my xterms apart (although many shell environments immediately overwrite the window title anyways, the behavior is not yet universal). Next, it turns the xterm red if I am ssh'ing to something with 'root@' in the hostname, just like how I have 'rxterm -r' set up. Finally it has an option to run gnome-terminal instead of xterm (and makes everything work just the same with it).

(It turns out that there are a certain number of things that just work better in a UTF-8 gnome-terminal environment than in my plain xterm one. Usually these are programs that try drawing elaborate text graphics, such as certain Debian and Ubuntu package installation tools.)

In theory sshterm accepts a -r argument, just like rxterm. In practice I never use it and instead just tell sshterm to connect to 'root@wherever' when I want to be root somewhere.

In a sense sshterm is a silly command; it's not very difficult to start a terminal window and then type ssh into it. But in practice it's been one of those little lubricants that make things enough easier that I use it all the time, because it handles all of the little fiddly details for me.

Sidebar: on marking 'root (terminal) windows'

I have a personal twitch where I want all windows where I am root to be clearly visually distinct, so that they instantly stand out when I look at them (even if I'm vaguely distracted). Some people use the shell prompt for this (and I do to a certain extent), but I find that this doesn't stand out quite enough for my tastes, so many years ago I arranged to make the foreground text be a pretty strong red in such windows, instead of my usual black.

In theory one could probably do this with xterm escape sequences. In practice I do it with xterm command line options, which has the drawback that it doesn't work in windows where I started out normal and then su'd to root later. Fortunately I don't do that very much, especially with tools like my rxterm script around.

(gnome-terminal has no command line options to control the foreground text colour. Instead you have to create a new profile with a different text colour and then use a command line option to set the initial profile.)

sysadmin/ToolsSshterm written at 21:13:31; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.