Tmux

From Redbrick Wiki

Tmux is a terminal multiplexer

What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. It is a good alternative to screen.

Installation

$ git clone https://github.com/tmux/tmux.git
$ cd tmux
$ sh autogen.sh
$ ./configure && make

Prefix

Shortcuts are all used by pressing the prefix then the shortcut. The default is

Control + b <shortcut>

The prefix can also be changed. (At the end of the wiki)

Session Management

Sessions are useful for completely separating work environments.

To create a new tmux session named session_name

tmux new -s session_name

To attache to an existing tmux session named session_name

tmux attach -t session_name

To switche to an existing session named session_name

tmux switch -t session_name

To list existing tmux sessions

tmux list-sessions

To detach the currently attached session

tmux detach (prefix + d)

Windows

Tmux has a tabbed interface, but it calls its tabs �Windows�. To stay organized, I rename all the windows I use. (Well I don't because I guess I hate myself.

To create a new window

tmux new-window (prefix + c)

To move to the window based on index

tmux select-window -t :0-9 (prefix + 0-9)

To rename the current window

tmux rename-window (prefix + ,)

To kill just one window

prefix + &

Panes

Panes make everything easier, and better!

splits the window into two vertical panes

tmux split-window (prefix + ")

splits the window into two horizontal panes

tmux split-window -h (prefix + %)

swaps pane with another in the specified direction

tmux swap-pane -[UDLR] (prefix + { or })

selects the next pane in the specified direction

tmux select-pane -[UDLR]

selects the next pane in numerical order

tmux select-pane -t :.+

Helpful tmux commands

lists out every bound key and the tmux command it runs

tmux list-keys

lists out every tmux command and its arguments

tmux list-commands

lists out every session, window, pane, its pid, etc.

tmux info

reloads the current tmux configuration (based on a default tmux config)

tmux source-file ~/.tmux.conf

Helpful Configs

These are some tmux configs:

nano .tmux.conf

Remap prefix to Control + a

set -g prefix C-a
unbind C-b
bind C-a send-prefix

Force a reload of the config file

unbind r
bind r source-file ~/.tmux.conf

Quick pane cycling

unbind ^A
bind ^A select-pane -t :.+