Tmux

Installing tmux

yum -y install tmux

Installing tmuxinator

yum -y install ruby rubygems gem install tmuxinator

cf. https://github.com/aziz/tmuxinator

Configuring Tmux

Tmux comes with bad defaults, so it is important to use better ones and save these. To do this, make a Tmux config file and save and then make it active.

Apply settings from tmux.conf: tmux source-file /root/jgs/tmux.conf

I use a config like this:

# Act like GNU Screen unbind C-b set -g prefix ^A set -g prefix2 ^A bind a send-prefix # set -g prefix C-a # Look good set -g default-terminal "screen" set-window-option -g window-status-current-fg black set-window-option -g window-status-current-bg white setw -g window-status-current-attr reverse set -g automatic-rename off

Sessions

Tmux cannot save sessions to disk, so it is important to use another program on top of Tmux to do this. Tmuxinator (https://github.com/aziz/tmuxinator) is a good way to do this. You can then define a saved Tmux session.

Common operations within Tmuxinator: 1. Make a new saved session 1. tmuxinator open 2. Start that session 1. tmuxinator start

To define a new session/"project", run tmuxinator open <session_name> and, in the resulting file that opens, write something similar to the following (delete the superfluous extras):

project_name: tst project_root: ~/jgs/ tabs: - db: export TMUX="" && tmuxinator start tstdb - adm: export TMUX="" && tmuxinator start tstadm

This will create four windwos that will each null out their TMUX variables (eplained in the "Multi-leveled sessions" section) and then start sub tmux sessions (each defined in their .yml file, respectively).

To create the leaf nodes that are actually logged into the remote machines, you can use an SSH command:

Multi-leveled sessions

It is important to be able to create multi-leveled sessions because just having windows 0-9 only allows for 10 windows, and there are often more than 10 hosts that you will need to connect to. To do this, you need to trick a Tmux session into thinking that it is not a Tmux session because the makers of Tmux do not believe that there are more than 10 hosts that you need to connect to. The trick is to run export TMUX="" inside any Tmux level, which will allow you to make another level of Tmux windows. In this way, you can get a maximum of 10^x sessions open, where /x/ is the number of levels.

Hotkeys

The following commands work after you press the control key (Ctrl+b by default, remapped to Ctrl+a).

General

List bindings.......? Session Detach..............d Redraw..............r Rename..............$

Window

Create..............c Kill................& Rename.............., List................w

Pane

Split...............% Switch..............o Kill................x

Appendix I - Common Problems

Terminal behavior (e.g., htop not opening, less complaining)

export TERM="screen"

Editor behavior (e.g., "Permission denied" when using "tmuxinator open")

export EDITOR="vim"

Others are attached (and you want to detach them)

    • Connect to your session with the following command ("JGS" was the project_name inside the .yml file)

      • tmux attach-session -t JGS -d

    • List sessions:

      • tmux list-sessions

    • Kill a session:

      • tmux kill-session -t myname

Appendix II - Resources

Reduce escape delays

[Edit]