GNU Screen

Session Management

Sessions (default escape: Ctrl-a)
# Create named session
screen -S infra

# Detach: Ctrl-a d

# List sessions
screen -ls

# Reattach
screen -r infra                          # reattach
screen -x infra                          # multi-attach (share session)
screen -D -r infra                       # detach remote + reattach here

# Kill session
screen -X -S infra quit

Windows and Regions

Window operations (Ctrl-a +)
# Windows
# c     create window
# A     rename window
# n/p   next/previous
# 0-9   jump to window
# "     list windows
# k     kill window
# w     window list (interactive)

# Regions (splits)
# S     horizontal split
# |     vertical split (screen 4.1+)
# Tab   move between regions
# X     close current region
# Q     close all regions except current

Copy and Scrollback

Copy mode
# Enter copy mode: Ctrl-a [
# Navigate with vi or emacs keys
# Mark start: Space
# Mark end and copy: Space
# Paste: Ctrl-a ]

# Set scrollback size
# defscrollback 10000

Configuration

~/.screenrc essentials
# Disable startup message
startup_message off

# Large scrollback
defscrollback 10000

# Status line
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%{g}][%= %{= kw}%-w%{+b ky}(%n %t)%{-}%+w %=%{g}][%{B}%Y-%m-%d %{W}%c%{g}]'

# Visual bell
vbell on

# Encoding
defutf8 on

Screen vs tmux

Feature screen tmux

Default prefix

Ctrl-a

Ctrl-b

Config file

~/.screenrc

~/.tmux.conf

Vertical split

4.1+ only

Built-in

Scriptability

Limited

Full CLI

Mouse support

Limited

Full

True color

No

Yes