developing with tmux
Sat, Jan 25, 2014
Many years I used to work almost exclusively in two development environments. Visual Studio and SoftICE, the latter making me a bit of a digital hermit which I wrote about a few years ago. Back then I’d realised the eremitic connotations of software development and they’ve hovered like a presence in the background throughout my softare development career.
Since leaving the driver days behind, that hermit’s cave of SoftICE has been replaced, in turn, by multiple Windows command prompt windows all crammed into a tiny monitor, fighting for space not only on the screen but in my brain’s limited short term memory banks. Where’s the apache window? I need those applicationg logs, now where did I put them?
Moving on, the monitor has become much much bigger and had an even bigger one planted next to it. The smaller has housed the IDE while the larger has a plethora of OS X terminal windows open. With the same problem as before. Where is that log window?
Then came iTerm2 and its tabs and its scripting capabilities. Getting fed up opening tabs and navigating to various development directories I knocked up a script to do it all for me:
However, the problem remained. Where is the tomcat tab?
Plus the constant context switching of moving from compiling to fumbling for the mouse, to clicking tabs until I found the right one, to typing commands, to more fumbling to find the right tab again degraded the whole development process.
And then I heard about tmux, a ‘terminal multiplexor’. Lots of people were raving about it and I was a little sceptical of the claims. After all, it’s just a fancy terminal. Plus I was used to the mouse by now, even if it was chipping away at my concentration, stealing cycles, leaking memory. But downloaded it, read a really good book on it and knuckled down to some scripting.
The above script create a tmux session called MatrixBlackboardPanel. It’s a project I’m working on to develop a client side single page application to talk the to Blackboard building block I developed for provisioning the VLE. You just create windows, send commands to them and eveything’s set up in an instant. I have another script that splits windows into panes for another project but this is nice and simple. Another feature I’m planning to try out is remote sessions. I can leave a tmux session running on my big Mac in the office and connect to it from home. Groovy!
So now my development environment looks like this:
Has tmux really boosted my productivity? I’d say yes. I’d also say in a pretty big way. I’ve rempped the command PREFIX to CTRL-A and moving from window to window is a breeze:
PREFIX 1 to move to the mvn window. Build and deploy. PREFIX 5 to move to the tomcat window. Start it up and tail the logs. CMD TAB to Chrome, Refresh. Not a mouse in sight. If I’ve forgotten a window number it’s just a case of hitting PREFIX w to see the list but the most used ones are stored in my register memory.
The memory hogging visual patterns of tab navigation by mouse have been optimised down to single key instructions capable of being stored in registers, leaving real memory free for developing.
Eremitic software development is alive and well. I just have to remember to go for a walk now and then to stretch the old legs. Get out of the digital hermit’s cave for nice fresh air.