tmux for bubba2

There are various replacements for the traditional screen command in Linux, Byobu and tmux being two good ones. Byobu is good, but after trying tmux on various Linux machines I really wanted it also on the Bubba2.

As tmux doesn’t seems to be in the bubba2 or etch repositories, the next option is to build it from source. Below follow some ideas for doing this.

Note: you may need to install/upgrade gcc and other tools to complete the steps below, if you have a standard, out-of-the-box bubba2 system.

  1. Switch to su and create a directory for source & resulting binaries
    su
    mkdir ~/project
    cd ~/project
  2. Compile proper libevent version
    tmux needs a more recent version of libevent than installed as part of bubba2 standard setup. First remove current libevent, then compile the new one:
    apt-get remove libevent1
    mkdir ~/project/libevent
    cd ~/project/libevent
    wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
    gunzip libevent-1.4.14b-stable.tar.gz
    tar xvf libevent-1.4.14b-stable.tar
    cd libevent-1.4.14b-stable
    ./configure
    make
    make install
  3. Register the new libevent
    Edit /etc/ld.so.conf.d/powerpc-linux-gnu.conf, e.g. by “vim /etc/ld.so.conf.d/powerpc-linux-gnu.conf”, add the line “/usr/local/lib/” (no quotes) at the end.
  4. Reload the new libevent
    Simply run “ldconfig”.
  5. Compile and install tmux
    mkdir ~/project/tmux
    cd ~/project/tmux
    wget http://downloads.sourceforge.net/project/tmux/tmux/tmux-1.5/tmux-1.5.tar.gz
    gunzip http://downloads.sourceforge.net/project/tmux/tmux/tmux-1.5/tmux-1.5.tar.gz
    tar xvf http://downloads.sourceforge.net/project/tmux/tmux/tmux-1.5/tmux-1.5.tar
    cd tmux-1.5
    ./configure
    make
    make install
  6. Configure tmux and start using it
    First, exit from superuser mode by typing “exit”. Then, you probably want to customize tmux, try googling “tmux config file” or similar for samples. I currently use the following:# Make it use C-a, similar to screen..
    unbind C-b
    unbind l
    set -g prefix C-a
    bind-key C-a last-window
    # key bindings for splitting
    unbind %
    bind | split-window -h
    bind h split-window -h
    unbind ‘”‘
    bind – split-window -v
    bind v split-window -v# Reload key
    bind r source-file ~/.tmux.conf#set -g default-terminal “screen-256color”
    set -g default-terminal “xterm”
    set -g history-limit 4096
    # Terminal emulator window title
    set -g set-titles on
    set -g set-titles-string ‘#S:#I.#P #W’# THEME
    set -g status-bg black
    set -g status-fg white
    set -g status-interval 60
    set -g status-left-length 30
    set -g status-left ‘#[fg=green](#S) #(whoami)@#H#[default]’
    # set -g status-right ‘#[fg=yellow]#(cut -d ” ” -f 1-3 /proc/loadavg)#[default] #[fg=blue]%H:%M#[default]’
    set -g status-right-length 75
    set -g status-right ‘#[fg=red]Up #(uptime | cut -f 4-5 -d ” ” | cut -f 1 -d “,”) #[fg=black]#[fg=yellow]#(cut -d ” ” -f 1-4 /proc/loadavg) #[fg=cyan,bold]%Y-%m-%d %H:%M:%
    S#[default]’
  7. Start using tmux
    “tmux” starts tmux. Now you can create new windows/panes, and kill the sessions whenever you want. When you reconnect to the bubba2 over ssh, just type tmux attach and you can continue where you left off.