How to Control screen from Within Other screen Sessions

2010-05-19

Today a tip for all the GNU screen fans out there. It's really nothing special and the manpage readers might already know this but as I only figured this out lately I thought I would share it anyway:

By default control sequences in screen begin with C-a (pressing Ctrl and a at the same time). But what if you are logged in to multiple hosts all running a screen session? Just use the C-a a command to send the command to the next screen session. Add a second a to execute the command on the third screen session and so on.

So for changing the title of the third screen session use C-a a a A.

This may sound confusing at fist but makes a lot more sense if you try it in practice.

The following image shows a screen session on host C started from within a screen session on host B started from within a screen session on host A. Host C on top, host A on the bottom, the blurred areas just showed the real user and hostnames.

For a consistent look I used the default grml screenrc file on all three hosts. A link to this configuration file can be found on their FAQ page.

If you are using a shell more or less regularly and somehow managed to survive without knowing screen do yourself a favor and get it now: http://www.gnu.org/software/screen/.

Post to Twitter