Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm a new user to GNU Screen. I've been using Bash for a very long time, and I want to give GNU Screen a try.

As you know, GNU Screen uses 'C-a' (Control-A) as as the command character. Trouble is, this interferes with the Line Editing feature in Bash (and GNU Readline), because Control-A in Bash will Move to the start of the line."

I know I can set the Command Character to another key sequence, like "^Q" or "``" (Backtick), but I have trouble finding another key sequence which isn't already in use (^Q is used by the terminal, backtick is used when writing shell scripts). It appears that the Command Character may only be one or two characters in length. Can I set the GNU Screen control character to be something like "Control-Shift-A"?

(I can't use more then one hyperlink yet, so I cannot link to the Bash documentation)

share|improve this question
3  
For the sake of not getting disoriented when using screen on other systems, you might be best off to stick with the default keybindings, or at least to learn them first. ^A a will, by default, send the usual ^A key combo. It is a bit inconvenient if you use that combo a lot; I usually use the HOME key instead because of this. But then that doesn't always work either. –  intuited Jul 6 '10 at 2:14
add comment

5 Answers

up vote 15 down vote accepted

The problem with Control-Shift-A is that most terminal emulation programs do not send a different code for it from the one sent by Control-A, so there would be no way for screen to tell the difference.

You might be able to use C-q if you do stty -ixon to disable “software flow control” on the tty. I usually do this so I can use C-s to search on the command line.

You might consider C-^, since it seems to be usually unbound. It is Control-Shift-6 on US keyboard layouts, but it may be difficult to type on other layouts.

Most people never use the tty control character C-\ to send SIGQUIT. To use it, disable the tty functionality with with stty quit undef and bind it as your prefix key. This is a bit risky though, since if you hit C-\ on a tty where the quit key has not been disabled with stty, you might kill the foreground process instead of activating screen.

I switched to tmux a while ago. Its default is C-b because it was developed under screen and did not interfere with screen's default. I have found that C-b works fairly well for me (I usually use the arrow keys for single character movement on the shell command line—though I use M-b and M-f to move by words).

Incidentally, the author of tmux uses C-a in his primary sessions and always types C-a twice (whether in a tmux session or not). If you are willing to adopt this habit, it seems like a decent compromise since the second C-a should be a no-op in most Emacs-like editing contexts. It would not work so will if you often use programs/contexts outside of screen where the second C-a would not be a no-op.

By default, C-a C-a is bound to the other command (switch to most recently active screen) in screen. To have C-a C-a send an actual C-a and have C-a o switch windows, put the following in your .screenrc:

escape ^A^A
bind o other
share|improve this answer
2  
This sounds good, then I realized that in GNU Screen, typing C-a twice will toggle to the window displayed previously. Maybe I can map "C-a C-a" to something else, although I'm not really sure how to do that (Looks like I need to specify 'escape xy' or 'meta' for this) See gnu.org/software/screen/manual/screen.html#Other-Window –  Stefan Lasiewski May 18 '10 at 23:32
1  
@Stefan Lasiewski: Oops, I forgot that C-a C-a does not send C-a by default. See the addition at the end of the answer for a bit of configuration that makes C-a C-a send C-a and C-a o switch to the previous window. –  Chris Johnsen May 19 '10 at 4:22
    
Works great! C-a C-a will send an actual C-a to the underlying shell and C-a o' will switch to the 'other' window. To send 'C-a' to Bash, hit 'C-a' twice. This should be a no-op outside of screen, and shouldn't cause problems. –  Stefan Lasiewski May 19 '10 at 17:53
add comment

No need for the workaround. For instance, under a screen session you can do C-a a to move to the beginning of the line. Likewise for other line editing shortcuts.

share|improve this answer
    
thanks, i did not now this, even though it's that easy. indeed no need to reconfigure anything. i like your answer best. –  harald May 16 '11 at 15:31
    
+1 ty - this is, by far, the best option. Funny thing is, while trying this out, I hit C-a C-a by accident and found yet another great combo. –  kfmfe04 Feb 19 '13 at 2:13
add comment

I use C-\ for Screen and I can't recommend it enough. You may hit any other key definition on accident but not generally C-\ . That's what I like about it.

share|improve this answer
add comment

I use ctrl-_ (which can also be produced by ctrl+7 and usually ctrl+/) with screen/tmux.

share|improve this answer
add comment

I use ctrl-z most of the time, but also use ctrl-x for some. I don't use the 'stop' interrupt that much, but when it is needed, I can type ^zz. This also allows me to start secondary screen sessions on remote servers that use the default ctrl-a. And if I start a third session (on a third server), then I can use ctrl-x. Ctrl-x is the lockscreen function, which in many environments is not all that usual (since screen is often running inside a terminal emulator).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.