Bash vs. Gnu screen : Replace Ctrl-A with Ctrl-Shift-A

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)


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

No need for the workaround.
To move to the beginning of the line while using screen in bash, use

Control-A (release and then) A


In general, if there's a screen control character conflicts with a bash shortcut, the bash shortcut's first Control will be replaced with Control-A

Likewise for other line editing shortcuts.


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.


I use this .screenrc

escape ^bb

Example: To detach you type ctrl-b d