Tmux (Terminal Multiplexer) allows you to run multiple terminal sessions inside a single window. It also keeps processes running in the background even if you disconnect from SSH.
Installation
# Debian/Ubuntu
sudo apt install tmux
# Arch Linux
sudo pacman -S tmux
# macOS
brew install tmuxSession Management
Run these commands in your regular terminal.
tmux # Start a new session
tmux new -s mysession # Start a new session with name "mysession"
tmux ls # List active sessions
tmux a # Attach to the last active session
tmux a -t mysession # Attach to "mysession"
tmux kill-session -t mysession # Kill "mysession"
tmux kill-server # Kill all tmux sessionsPrefix Key
Inside Tmux, all shortcuts start with a prefix key.
By default, the prefix is Ctrl + b.
Window Management (Tabs)
After pressing Ctrl + b:
c: Create a new windoww: List all windows and choose onen: Go to next windowp: Go to previous window0to9: Go to a specific window number,: Rename current window&: Kill current window
Pane Management (Splits)
After pressing Ctrl + b:
%: Split pane vertically (left/right)": Split pane horizontally (top/bottom)Arrow Keys: Switch between panesx: Kill current panez: Toggle pane zoom (fullscreen)Space: Cycle through pane layouts{/}: Swap pane with the next/previous pane
Configuration (~/.tmux.conf)
You can customize the prefix and appearance in ~/.tmux.conf. After changing it, reload with tmux source-file ~/.tmux.conf.
# Change prefix to Ctrl + a (like GNU Screen)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Enable mouse support
set -g mouse on