[Permalink]     blog linux

tmux is the best thing ever. That is all.

No, that is not all. Here is how I make use of tmux to make my life measurably more awesome:

First, my .tmux.conf. This changes tmux's ctrl-b magic key binding to ctrl-a as I've grown far too used to hitting that from when I used screen. I set up a few other screen-like bindings too. Finally, I set a few options that make tmux work better with urxvt.

# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix

# Bind c to new-window
unbind c
bind c new-window -c $PWD

# Bind space, n to next-window
unbind " "
bind " " next-window
unbind n
bind n next-window

# Bind p to previous-window
unbind p
bind p previous-window

# A few other settings to make things funky
set -g status off
set -g aggressive-resize on
set -g mode-keys vi
set -g default-terminal screen-256color
set -g terminal-overrides 'rxvt-unicode*:sitm@'

And then here's what I have near the top of my .bashrc:

# If tmux isn't already running, run it
[ -z "$TMUX" ] && exec ~/bin/tmux

...which goes with this, the contents of ~/bin/tmux:


# If there are any sessions that aren't attached, attach to the first one
# Otherwise, start a new session

for line in $(tmux ls -F "#{session_name},#{session_attached}"); do
    name=$(echo $line | cut -d ',' -f 1)
    attached=$(echo $line | cut -d ',' -f 2)

    if [ $attached -eq 0 ]; then
        tmux attach -t $name

tmux -u

Basically, what happens is that whenever I start a terminal session, if I'm not already attached to a tmux session, I find a session that's not already attached to and attach to it. If there aren't any, I create a new one.

This really tidies up my workflow and means that I never forget about any old sessions I'd detached.

Oh and one last thing, ctrl-a s is the best thing in tmux ever. It shows a list of tmux sessions which can be expanded to show what's running in them and you can then interactively re-attach your terminal to one of them. In short, I can start a terminal from any desktop or vt and quickly attach to something that's happening on any other. I use this feature a lot.

  Simple mail transfer pondering   blog linux   Ramble   blog   Eligarf   blog   Laziness   blog   Netcat   blog linux   Judon't   blog   Things   blog   btw   blog c code   Stuff what I done   blog   Diet?   blog   TODO   blog   Shootah   code games games inactive   Tatil   blog holiday   Things we learned at the LUG meet   blog linux   MarkPoint   code command line desktop inactive other   Luck   blog   Yawn   blog   HBTM :)   blog code git   TODO   blog   Krobes   code games games inactive   Homophones   words   Non-euclidian pork scratching   blog   Lost at C   blog c code   JSTLV   code inactive other web   Ire   blog code   Ire   code command line inactive other   So, so dry   blog code   Gruff   code inactive other web   Things I've written recently   blog code   require("child_process");   blog   JZON   code inactive other web   Wyrm   code games games inactive   Picture Puzzle   code games games inactive   Zoomsite   code inactive other web   Rotate4   code games games inactive   Lines   code games games inactive   BreakIn   code games games inactive   nosef   code inactive javascript server server   Scary stuff   blog   Primes   blog   Hokey Cokey   blog   Web terminal lense book   blog   Strange lunch break   blog   Obfuna   code inactive other programming   Markdown   blog   ploxy   code command line inactive server server   miniserv   code command line inactive server server   Gnowt   code inactive other web   dmenu-notify   code desktop inactive other   Violining a contemptible fellow   blog code git   Break In!   blog games   xmodmap Hints and Tips   blog linux   Black Jack - pick up seven!   blog games   My favourite spoonerisms   words   Good things that have happened in the past week   blog   Good times with git   blog git   It's all Geek to me   blog   Javascript Closures   blog code javascript   Waffle. Move along.   blog   Things I learned today   blog   Hey, at least I'm not rioting   blog   HTML5 and holidays   blog holiday   Blah, cold. Do not want.   blog   Worst.Landlord.Ever   blog   Wheeee   blog   First!!1!one!!eleven   blog