Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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)
share|improve this answer
    
Thanks. I used the key binding proposed by @cjm –  Yotam May 2 '11 at 9:17

Create ~/.screenrc containing:

escape ^Zz

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

share|improve this answer

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.