Change the escape keystrokes in screen

One of my favorite (and most used) applications on any Linux machine is screen. Once you fire up a screen session, you can start something and keep it running indefinitely. Even if your internet connection drops or you accidentally close your terminal window, the screen session will remain open on the remote server.

Detaching from a screen session is done by pressing CTRL-A and then d (for detach). However, when I'm on my Mac, CTRL-A and CTRL-E send my cursor to the beginning and end of lines, respectively. Once I launch screen, I lose the CTRL-A functionality because screen thinks I'm trying to send it a command.

Luckily, this can be changed in your ~/.screenrc:

escape ^Ww

With this change, you can press CTRL-W, then press d, and you'll detach from the screen session. For all of the screen options, run man screen on your local machine or review the man page online.

Printed from: http://rackerhacker.com/2010/01/07/change-the-escape-keystrokes-in-screen/ .
© Major Hayden 2012.

4 Comments   »

  • Twirim says:

    screen is an absolute essential for me on any server, from the two angles. Firstly the screen multiplexing which makes life so much easier. Almost always will have "tail -f relevant.log" running on one screen for quick checking, or when writing perl I'll have one screen where I'm editing the file, and one where I'm testing it saving me from faffing about with :wq'ing and such like.

    The other angle is the disconnect one, particularly if I'm running something possibly destructive on the server when the last thing you want is a network glitch to disconnect you. I've had it happen in the past and had to do disaster recovery due to an inopportune disconnect. screen has saved my bacon more times than I can count, particularly when sysadmining over a 2G network connection :D

  • Eric says:

    You don't need to change it, to get CTRL-A inside a screen just press "CTRL-A A" That's how to get the CTRL-A sequence inside screen.

  • Surge says:

    Ctrl-A A works, but the extra keystroke is both an inconvenience and a confusion factor, since I do command line editing and emacs both on screen and non-screen terminals.

    I like Ctrl-\, since it is not commonly bound to anything in emacs, but have had some trouble with it sticking on certain machines and/or keyboards - not sure what's responsible and resetting it is easy enough, so I have not investigated.

    Byobu is a manager/configurator layered on top of screen, that I started using recently and I like it a lot. Also gives me a spiffy status line at the bottom of the window.

  • Kadu says:

    I've trying to set C-. to be my escape sequence but can't get it to work any idea how I can do it?

    Cheers

RSS feed for comments on this post

Leave a Reply

 

  • Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you find the information useful. If you spot something that's incorrect or confusing, please write a comment and let me know. Drop me a line if there's something you want to know more about and I'll do my best to write a post on the topic.
    -- Major Hayden

    Flattr this