Screen

From Leo's Notes
Revision as of 06:22, 1 September 2019 by Leo (talk | contribs) (Text replacement - "Category:Linux{{Navbox Linux}}" to "{{Navbox Linux}}Category:Linux")
This page was last edited on 1 September 2019, at 06:22.

Disable Visual Bell

To disable the visual bell for the current screen instance, hit:

Ctrl+a Ctrl+g

For a permanent fix, put the following into the ~/.screenrc file

vbell_msg "bell: window ~%" # Message for visual bell
vbellwait 2 # Seconds to pause the screen for visual bell
vbell off # Turns visual bell off


Force Background Redraw

Screen will sometimes mess with any background colors set by programs such as vim. This will cause weird visuals in the terminal where background colors are only rendered where there is text.

You can force screen to redraw the entire area such that the background colors are preserved by putting the following in your .screenrc file:

defbce on


Scrollback Buffer

Edit .screenrc with:

defscrollback 5000

Scroll back in a screen terminal by hitting: Ctrl-a [

Navigate using:

Key Movement
h Move the cursor left by one character
j Move the cursor down by one line
k Move the cursor up by one line
l Move the cursor right by one character
0 Move to the beginning of the current line
$ Move to the end of the current line.
G Moves to the specified line (defaults to the end of the buffer).
C-u Scrolls a half page up.
C-b Scrolls a full page up.
C-d Scrolls a half page down.
C-f Scrolls the full page down.
/ Search forward
? Search backward

Rename Screen Session

In a screen terminal, enter Ctrl-a :sessionname followed by the new name.

Eg:

# screen -ls
There are screens on:
        8570.test       (Attached)
## Hit Ctrl-a :sessionname Hello
# screen -ls
There are screens on:
        8570.Hello      (Attached)

Lock a Session

You can use screen to lock the virtual terminal by using the Ctrl-x key.

Running a command detached

To run a command in a screen session in the background, use: screen -S screenname -dm command

Running screen through su

If you are running screen not directly through the terminal (such as through su), you will get the following error message:

$ screen 
Cannot open your terminal '/dev/pts/0' - please check.

You can remedy this using script:

$ script /dev/null
$ screen  # Rerun script while in a typescript session

Serial

You can use screen as a serial console as well.

screen /dev/ttyS0 <baud>[,<options>]

Common baud rates are 9600 or 115200.