Looking for a way to remap screens C-a or ^a (default command) binding, to Alt-a or ^[a by using an easy to memorize, one-go command / switch. I know this can be possible in 2 steps, but also only from screen itself - however, ideally I'd like to pass some parameter(s) to screens command line, when firing it up. What I'm looking for is something similar to Tmuxs command set prefix M-a (or rather somethin similar, since afaik screen doesn't understand such human-friendly syntax for Alt/Meta key). It would be even better if I could remap this default ^a to AltGr-a

Tried following:

1. $ screen  -e '\0033''\0141' 

Values of those were taken from showkey:

$ # showkey -a                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    Press any keys - Ctrl-D will terminate this program                                                                                                                                                                                                                                                                                                                                                                                                                                       
    ^A        1 0001 0x01            < Ctrl-a                                                                                                                                                                                                      
    ^[a      27 0033 0x1b            < Alt-a yields 2 lines : first line                                                                                                                                                                                                                   
             97 0141 0x61            < Alt-a second line

where the first line was C-a key-press. 2nd and 3rd line was Alt-a single, simultaneous key-press. Screen sees indeed 2 chars (as is required by -e but fails to map them as per my expectation.

  1. From inside screen, I was hoping to do be able to somehow leverage the -k option to bindkey, as per the example here in its manual, where it says:

Command: bindkey [opts] [string [cmd args]]

The argument ‘string’ is the sequence of characters to which an action is bound. This can either be a fixed string or a termcap keyboard capability name (selectable with the ‘-k’ option).

The problem is where to find the 'Termcap' entry for Alt / AltGr key. man termcap shows nothing.

Also, maybe this SE answer would be helpful, but I haven't been able to figure out the right syntax

For those suggesting to switch to Tmux instead:

  • I have to ssh on many different servers and its default keybindings are awkward to me, including changing windows, lack of C-b C-b jumping back to previous one (one has to use C-b l for this);
  • no session locking
  • my screen "muscle memory"
  • and a few others issues, which I'll remember if need be ;)

Even remapping AltGr <-> Ctrl would be a good enough solution provided it doesn't involve any X-related programs, since the servers are X free (non X-polluted).

1 Answer 1


I've often wondered about the choice of ^A as the command char for gnu screen as it's usefulness in readline etc. makes it a keypress I use fairly regularly.

Anyway, I use ^X instead (as it's not often used for anything else).

Add this to your .screenrc:

escape ^Xa

(from https://www.gnu.org/software/screen/manual/screen.html#index-escape-character):

escape xy

Set the command character to x and the character generating a literal command character (by triggering the meta command) to y (similar to the -e option). Each argument is either a single character, a two-character sequence of the form ^x (meaning C-x), a backslash followed by an octal number (specifying the ASCII code of the character), or a backslash followed by a second character, such as ^ or \. The default is ^Aa. ter, such as ^ or \. The default is ^Aa.

  • Thank you for helping maintain my sanity! Ctrl-a Ctrl-d ... Ctrl-d is a very common sequence for me to change a command. By default, it will successively exit screen and any enclosing shells quickly rendering my terminal dead. Commented Jul 6, 2023 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .