Desktop and Terminal Hacks

You are here: Andrew Ho > Software > Desktop Hacks

When I do work on a computer, I am usually using Windows XP, and I make heavy use of just a couple pieces of software: an SSH terminal (VanDyke SecureCRT) and a web browser (Mozilla FireFox). Here are some of the customizations that make my life easier.

Desktop Tools

This is the basic set of tools I need to be comfortable with a GUI.

Mapping Caps Lock to Control

Like many programmers, I use the Ctrl key a lot, and I never use the Caps Lock key. I use Ctrl2Cap from the Sysinternals folks to turn the Caps Lock key into another Ctrl key.

Remapping keys is much easier these days; on Windows XP, in fact, you can simply edit your registry to remap Caps Lock. I still use Ctrl2Cap because I've been doing it since Windows 95 and it still works.

Virtual Window Manager

Vern screenshot

I typically have two mail/IRC windows, four shell windows for programming, and a browser running. I use Vern by One Guy Coding to manage all these windows.

On the right you can see a screenshot of what my window layout typically looks like. The bottom left hand corner is mail/IRC, and I leave the bottom right free for temporary workspace.

Focus Follows Mouse

As an old school X Window System user, I like "focus follows mouse" behavior, which basically means that whichever window the mouse pointer is on top of receives input focus. To get this on Windows, download the Tweak UI application, part of the free Windows XP PowerToys software bundle. The option in Tweak UI is under the "Mouse > X-Mouse" tree, and is called "Activation follows mouse."

Remote Server Access

Here are some tools to make accessing remote systems (like servers at work) easier.

SSH Tunnelling for Windows

To access remote systems I generally use SSH tunnelling instead of VPN whenever I can, because it's easier for me to debug when things break. I generally use a passphrase-less SSH command key that can only run a single bogus command (see my nothing script for an example). I use VanDyke Entunnel to do SSH tunnelling under Windows. It has a friendly GUI interface and auto-reconnects after network failures.

See my ssh-tunnel script if you use Cygwin or just want an auto-reconnecting SSH tunnel script that runs from the command line. I use this for tunnelling CVS and web accesses from shell boxes, and for the OscarCam.

SSH Agent Persistence

I generally use SSH public key authentication, but I hate typing passphrases. I use ssh-agent to get around this, but when using multiple windows on the same server, I don't like having to remember to type the ssh-agent command. To get around this I have a couple scripts that I use to cache ssh-agent session information:

I also include commands like the following in my .bashrc:

# Convenient ssh-agent aliases
alias sa=eval `ssh-agent-persist`
alias sakill=eval `ssh-agent-kill`

# Source host-specific cached ssh-agent script, if any
if [ "x$hostname" != "x" ]; then
    if [ -f ~/.ssh-agent/"$hostname" ]; then
        eval `cat ~/.ssh-agent/"$hostname"`

I type sa when a machine has recently rebooted, or if for some reason my ssh-agent process is killed. Between this and SecureCRT support for SSH agent, I rarely have to type passphrases.

Remote Session Management

Using the below hacks I can get seamless transition between desktops (for example, home and work computers) as well as between different networks (for example, when I move my laptop between home and a WiFi cafe). I can literally close my laptop at home, and re-open it anywhere I have network connectivity, and pick up right where I left off.

Terminal Session Persistence

I usually keep four separate programming shell windows open at a time, and it's nice to be able to pick up where I left off when I travel between computers or wireless hot spots. Many people use VNC (usually the TightVNC variant) to an X Window System desktop for this, but I find VNC over VPN or an SSH tunnel to be a little slow. Instead, I use a carefully managed GNU screen setup to get seamless session persistence.

GNU screen allows you to name your screen sessions (via the -S command line flag). I use a shell script to create or reconnect a named screen session. SecureCRT lets you script logins per session (Options > Session Options > Connection > Logon Scripts), so I have four separate sessions, each of which does something like exec sn 1 or exec sn 2 at login.

On my laptop, I've experimented with setting these sessions to auto-reconnect. With that setting, I can be doing work, close my laptop, go somewhere else, re-open my laptop, and be working in the same windows I was working in before, without touching any keys to make the session come back. Cool!

One interesting habit I've picked up from this setup is to always detach from screen rather than log out.

Automatic Terminal Window Positioning

The final piece to my session management puzzle is to get Windows to open windows for me in their proper spots. For this, I have a Windows script to open SecureCRT windows in prearranged positions. Each window is associated with a SecureCRT session that uses the Logon Scripts feature to select a named screen (see Terminal Session Persistence above for details on this).

I leave the Windows script in my "My Documents" folder, and have a shortcut on my Start Menu to get to it. Whenever I am at a desktop and want to do some work programming, I just click that menu option and am reconnected to the sessions I was using before.

Andrew Ho (