Saturday, August 25, 2012

Using tmux to hack Clojure in a shared terminal

After our experiences trying and failing to get swarm working at the recent Clojure dojo (probably because I don't have emacs 24), we had a play with using tmux directly, which seemed to work quite well. Here are the steps that we went through

First, you need tmux. I'm not sure about other platforms but, on Ubuntu, it's available in the default repositories:

$ sudo apt-get install tmux

Next, you'll need a user id to run the terminal in, unless you really trust your friends. We used the user id that we had already created in our failed attempt to run swarm:

$ sudo useradd swarm

Once your new user account is set up the way that you want, you can su to that user and run the following to create your tmux session:

$ tmux new -s swarm

Your friends can now ssh to your machine (you'll need to share a password or set up some other form of authentication) and run the following to connect to the session:

$ tmux attach-session -t swarm

We were then able to run emacs -nw to launch emacs within the terminal; it should be possible to run vi  just as easily.

One slight annoyance was having to set up emacs starter kit and leiningen for the new user id but it wasn't too onerous.

Once all that was done, you get something that looks like this:


It's not insanely flashy but it's enough to give you something to share on a projector screen and start coding.

You could probably improve this massively by configuring the user id to connect to the tmux session at login time but, for now, this was enough for us and our little dojo.


No comments: