Skip to content
Simon Gene Gottlieb edited this page Sep 16, 2022 · 1 revision

Tmux

The tool tmux πŸ”— can be used to run programs on the server, without the need to be connected all the time. This tool similar to screen but newer and cooler.

Config

Firstly, you should reconfigure tmux by adding the file ~/.tmux.conf on the server:

# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind a send-prefix

This changed the default binding Ctrl-b to Ctrl-a. (screen also uses Ctrl-a, it is cooler!)

Usage

Create a new session

To create a new session type in

tmux new -s someTitleNoOneCares

You got a new session.

Attach to an existing session:

To attach to a random session

tmux attach

Switching sessions

If you are attached to the wrong session, simply Press Ctrl-a and then s, which will give you a list of all available sessions.

Auto create/attach to session

It is wise to do everything inside of session on the server. This way, you never lose your progress if the connection unexpected interrupts. For this you can adjust the ~/.bashrc or ~/.bash_profile (normally it is bashrc but on our server it is bash_profile) and add the following lines:

if [ -z $TMUX ]; then
	tmux attach || tmux new -s defaultTitle;
fi

Now create a new connection and you will see it Automatically connects to an existing session or creates a new one.

Advanced

Splitting panels

If you press Ctrl-a followed by % or " it will split your panel horizontally or vertically.

Closing a panel

Just hit Ctrl-D or type in exit to close your current panel.

Listing all windows

Type Ctrl-a followed by w to get a list of all sessions and windows

Clone this wiki locally