tmux + screen cheatsheet.
tmux sessions
tmux # start
tmux new -s work # named
tmux ls # list
tmux attach # attach last
tmux attach -t work
tmux kill-session -t work
tmux kill-server
Prefix
Default Ctrl-b. After prefix:
Windows
c new window
, rename
n / p next/prev
0-9 switch by number
w list/select
& kill
Panes
% split vertical
" split horizontal
arrow move between
o cycle
x close pane
z zoom toggle
{ } swap
space cycle layouts
! break pane to window
q show pane numbers
Resize
prefix + ctrl-arrow resize
prefix + alt-arrow resize bigger
Sessions inside
d detach
s switch session
$ rename session
( prev session
) next session
Copy mode
[ enter copy mode
space start selection
enter copy
] paste
In vi mode: prefix + [ then v to start, y to yank.
Sync panes
prefix + :setw synchronize-panes on
Send input to all panes.
Useful config (~/.tmux.conf)
# Better prefix
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Start at 1
set -g base-index 1
setw -g pane-base-index 1
# Mouse
set -g mouse on
# vi mode
setw -g mode-keys vi
# Reload config
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Split same dir
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Status bar
set -g status-bg colour235
set -g status-fg colour255
set -g status-right "#{?client_prefix,#[fg=red]^A,} %H:%M %d-%b-%y"
# Longer scrollback
set -g history-limit 50000
# Faster escape
set -g escape-time 0
screen (legacy)
screen # start
screen -S work # named
screen -ls # list
screen -r work # reattach
screen -d -r work # detach others, reattach
# Inside (prefix: Ctrl-a)
c new window
n / p next/prev
" window list
ctrl-d detach
k kill window
S split horizontal
| split vertical
tab switch
Persistent shells
Both survive SSH disconnect:
tmux new -s work
# ssh dies
# reconnect
tmux a -t work
For services that “must outlive shell”: prefer systemd.
tmuxinator / tmuxp (sessions as config)
# project.yml
name: myapp
windows:
- editor: vim
- server:
panes:
- logs: tail -f /var/log/app.log
- shell:
- db: psql -d myapp
mux start project
Useful for repeatable dev environments.
tmux + ssh
ssh -t host 'tmux new -ADs work' # attach or create
-A: attach if exists. -D: detach others. -s: name.
Pair programming
tmux new -s pair
# share .tmux socket via group perms
Or use teleconsole / tmate (built for this).
brew install tmate
tmate
# Outputs SSH URL to share
Common mistakes
- Forgetting
prefixfor commands → typed into shell. - Mouse mode + scroll wheel → exit copy mode quirk.
- Long-running tasks in tmux on workstation (use systemd).
- Mismatched tmux versions client/server (don’t mix).
Read this next
If you want my tmux + neovim setup, it’s at rajpoot.dev .
Building something AI-, backend-, or data-heavy and want a second pair of eyes? I do consulting and freelance work — see my projects and ways to reach me at rajpoot.dev .