screen CheatSheet

~/.screenrc

Example screen config file: .screenrc

# Clear e.g. vim, less buffers at the end
altscreen on

## Mouse scrolling enabled
termcapinfo xterm * ti @: te @

defbce on
term xterm-256color

# Cache 30000 lines for scroll back
defscrollback 30000

# caption always "%{= kc}%H (system load: %l) %-21<%=%D %Y-%m-%d %02c:%s"
hardstatus alwayslastline "%{= kc}%H (load: %l) %-21<%=%D %Y-%m-%d %02c:%s"

Start a new screen session

$ screen

Start a new screen session with session name

$ screen -S <name> 

List screen sessions

$ screen -ls

Attach a screen session

<name> can be the part of the session name (search term) if there is no conflict. If the search term match multiple session names, the attach will fail.

$ screen -x <name>

Detach a screen session

Cltr+a d (or ^a d) – detach without existing screen session, so you can attach again later.

Inside screen session, press Control+a d

$ ^a d

Exit a screen session

Terminate the screen session when you don’t need to re-attach later.

Inside screen session, type exit

$ exit

Examples

$ screen
...
$ ^a d
[detached from 24320.ttys000.a2mbp]


$ screen -S workspace-1
...
$ ^a d
[detached from 24921.workspace-1]


$ screen -ls
There are screens on:
	24320.ttys000.a2mbp	(Detached)
	24921.workspace-1	(Detached)


$ screen -x 24320.ttys000.a2mbp
...
$ exit
[screen is terminating]


$ screen -ls
There is a screen on:
	24921.workspace-1	(Detached)


$ screen -x work

Leave a Comment

Your email address will not be published.

one × three =