Things that are worth the bloat #2: tmux

by debianjoe

tmacs

One of the things that I’ve been using since I first discovered it is tmux.  The idea of being able to make new sessions in new windows or panes without being required to log into virtual tty’s has to be one of the best ideas ever.

As I’ve perhaps alluded to, I’m highly predictable as to what my needs will be at any given time.  The above image is actually started via a simple shell script when I log into my fbterm.  I really am a huge fan of being able to control the layout of the page with something as basic as shell scripts, because they can then be tied to an alias and you can use them to totally restructure your environment at will.

The above is my “standard layout” which means that I’m simply going to begin doing something that’s within the realm of normal use.  There’s no reason for me to over-complicate the “main window” for any particular purpose, so I try to leave it flexible.  If my ‘tmacs’ script is launched without arguments, it runs this little bit of scripting to create the above:

++++++++++

if [ $# -lt 2 ]
then
    tmux new-window -a -n Window2
    tmux rename-window “T-macs”
    tmux split-window -h
    tmux last-pane
    tmux send-keys “emacs -nw” C-m
    tmux last-pane
    tmux split-window -p80
    tmux last-pane
    tmux split-window -h
    tmux send-keys “tty-clock” C-m
    tmux last-pane
    tmux send-keys “cal” C-m
    tmux last-pane
++++++++++

There’s probably a far cleaner way to write this part of the script, but I’ll be the first to admit that I’m not the best example of bash/shell scripting.  It does suit my needs, and that’s really all that matters to me.  This option starts by creating a totally new window, so that previous section can be returned to with a simple “C^a p”.  (I always bind the ‘control’ pattern to Ctrl+A for tmux, as it conflicts with to many other hotkeys if I don’t.)  This allows a really simple way to manage what is essentially virtual desktops without the need for an xserver.

Ironically, I discovered tmux when using X.  Despite the ability to control multiple windows, I found that one of the things that I needed was to keep ssh sessions open in one area, while having local access to a shell on the machine that I was working from.  Since then, I have found myself really amazed at the depth of such a simple tool.  I would strongly recommend trying out tmux if you’ve ever needed more than a single terminal open at once.  It’s flexible and very practical…with or without X.

Advertisements