I'm working with emacs (on the terminal) and I use screen to switch between terminals. The key combination Ctrl+A is grabbed by screen. Is there a way to change screen key binding?


Sure, you can change the binding in either Screen or Emacs.

I use Ctrl+\ in Screen, which is used by very few applications. It's used in the terminal to send the QUIT signal — a stronger version of Ctrl+C, which fewer applications catch and may produce a core dump. That's rarely useful, and if you need it you can press Ctrl+\ \. A bigger argument against Ctrl+\ is that it's hard to type on some keyboard layouts. Anyway, pick the key you prefer.

To change the Screen escape key, use the escape directive in ~/.screenrc:

escape ^\\\

In Emacs, C-a normally moves to the beginning of the line; you can use Home instead. C-x C-a is not bound. That leaves modes with custom bindings for C-a or C-x C-a or C-c C-a. If you choose C-\, it's normally bound to toggle-input-method, which is useful if you write in multiple languages and useless otherwise. You can rebind it to a different key with global-set-key in your ~/.emacs:

;; overrides a binding for `suspend-frame', which is also bound on `C-x C-z'
(global-set-key "\C-z" toggle-input-method)

Create ~/.screenrc containing:

escape ^Zz

Then use Ctrl-Z instead of Ctrl-A to control screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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