Managing Terminals Within Screen

There are a number of commands that help you manage the terminal sessions you run within screen.

To copy text, you can use this sequence:

Ctrl-a [

This will give you a cursor that you can move with arrow keys or h,j,k,l keys (like vi). Move to where you want to start copying, and hit “Return” or “Enter”. Move to the end of where you’d like to copy and hit “Return” or “Enter” again. The text is then copied to your clipboard.

One thing to be aware of is that this is also screen’s mechanism for scrolling. If you need to see some text that is off the screen, you can hit “Ctrl-a [“ and then scroll up off of the screen.

We can paste text that we copied with the right bracket.

Ctrl-a ]

Another thing you might want to do is monitor programs that are executing in another screen window.

Let’s say that you’re compiling something in one window and you want to know when it’s completed. You can ask screen to monitor that window for silence with the “Ctrl-a _” sequence, which will tell you when no output has been generated for 30 seconds.

Let’s try it with a simpler example. Let’s have screen tell us when our window is finished pinging google 4 times.

ping –c 4
Ctrl-a _
 The window is now being monitored for 30 sec. silence.

Now we can do work in another window and be alerted when the task in this window is complete.

Ctrl-a 1
Window 2: silence for 30 seconds

We can also do the opposite and be alerted when there is activity happening on a specific window. We accomplish this with the “Ctrl-a M” sequence.

sleep 20 && echo “output”
Ctrl-a M
Window 2 (bash) is now being monitored for all activity.

We will now be alerted when the command produces output.

Ctrl-a 1
Activity in window 2

Let’s say we are going to be doing some important changes and we want to have a log of all of the commands we run. We can log the session with:

Ctrl-a H
Creating logfile "screenlog.1".