Tags:
create new tag
view all tags

Screen - terminal multiplexer

The Unix screen command is an old and reliable tool for creating detachable windowed terminal sessions. It also allows from multiple terminal windows to be split and displayed in a single window.

Here is a cheat sheet of basic commands for using screen.

# keybindings
All command keybindings start with Ctrl-a

^a ? for help screen


#start session with name
screen -S mysession

# list available sessions that are running
screen -ls

# exit a terminal/session
type exit in a terminal to exit the terminal as you normally would. If you exit the last or final running terminal the screen session will exit as well
with the following message

[screen is terminating]


# create a new terminal in a screen session
^a c

# split current pane horizontally
^a S


## Switching focus between panes
# switch toggle through panes [tab] is the tab key
^a [tab]

screen commands for switching between regions are: focus up,
focus down, focus right and focus left.
To type these commands (or any other screen command, for that matter) you
type Ctrl-a :focus up, for example.

These commands are tedious to type, so you can create key
bindings in your ~/.screenrc file.

a Vim user could opt for these lines in ~/.screenrc file:

bind j focus down
bind k focus up
bind l focus right
bind h focus left

With these bindings ^a h would move the focus one pane to the left


# split panel vertically
^a |

# select a terminal window from a list of all running session terminals
^a "

then use arrow keys to scroll to a terminal and click ENTER to display in this panel

# close current focused pane (this does not exit the terminal it just closes the display to it)
^a X

# previous and next - in the current pane, switch to the previous or next terminal
^a p -previous
^a n -next

display the previous or next pane into this pane.

so if there are 3 panes 0,1,2

if current pane focus is 0 prev=2 next=1
if current pane focus is 1 prev=0 next=2

# detach the screen session leaving all terminals running in the
background
^a d

[detached from 26831.mysession]

# re-attach to the session
screen -r # if only one session is running

# if multiple sessions are running
screen -ls
screen -r 26831 #where 26831 is the number of the session we viewed with the screen -ls command

# exit terminals/session
You can exit individual terminals as normal with exit

You can terminate the entire session by exiting the last remaining
terminal OR by killing the screen process itself

pkill screen

-- Dave Costello - 2020-05-05

Topic revision: r1 - 2020-05-05 - DaveCostello
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback