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 found this online:

bindkey "\261" select 1
bindkey "\262" select 2 
bindkey "\263" select 3 
....

Basically it maps alt+1 to "select 1"; alt+2 to "select 2". So when you press alt+1, it is supposed to jump to screen window 1.

This works in xterm but not but in gnome-terminal. I know gnome-terminal already uses alt+N to switch to tab n. So I turned off this key mapping for gnome terminal in gnome configure editor. But it still doesn't work.

Seems that when I press alt+1, it is received by bash, not by the GNU screen program, so it puts a special character on the bash or puts "arg: 1".

Any solutions? Thanks a lot!

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

The problem is caused by different treatment of the Meta key (Alt on PC keyboards) by Xterm and GNOME Terminal.

In Xterm, holding the Meta key will (by default) set the highest bit on the characters (Meta+1 becomes \261), while GNOME Terminal and most other terminal emulators leave the character unmodified but prefix it with an ESC (the same keypress becomes \033\061).

There doesn't seem to be a way to configure the handling of Meta key in GNOME Terminal (printf '\033[?1036l' may work, but I cannot test it), so you will have to somehow bind \033\061 to "select 1" and so on. (It's highly unlikely that it'll actually work, and if it did, it would probably break every other special key out there: arrows, function keys, etc.)

share|improve this answer
    
HI grawity, it works when binding "\033\061" to "select 1". Awesome!!! Thank you so much. Right now, it doesn't break anytings like arrows or function keys. let's see. Again, many thanks! –  vim Jun 10 '11 at 20:26
1  
The reason that GNOME Terminal and most other terminal emulators these days encode Alt as an ESC prefix is that setting the Meta bit collides with character encodings beyond 7-bit ASCII. –  ak2 Jun 12 '11 at 7:17
    
Hi ak2, Thanks for commenting the reason. –  vim Jun 13 '11 at 17:15
    
grawity is right, the binding is breaking some things, for me I cannot type Chinese character 花 anymore. –  gb. Jan 6 '12 at 10:06
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.