Making iTerm to translate 'meta-key' in th

2020-02-16 05:15发布

In bash shell with emacs key-binding, you can use key combination like M-f, M-b to move one word forward or backward on the shell prompt respectively. Usually, the meta key is mapped to Alt key on Windows and Linux. However, in iTerm, I could not find a way to map this meta key to either Option or Command key on my MacBook Pro.

It seems that in OS X, the meta key is by default mapped to ESC key. So you can use ESC-f, ESC-b on iTerm. However, ESC key is apparently not practical to use. In addition, iTerm does have option that allow you to modifier mapping for the meta key (Bookmarks > Profiles > Keyboard Profiles > Global > Option Key as...), this setting does not seem to work at all.

Therefore, if anyone know what is the solution to this problem, please let me know.

I have upgraded to the latest release, 0.9.6.1012, and this behavior is still persist.

Edit: Some clarification to my question. The key-binding I'm talking about is for bash shell, not in emacs. It just happens that, by default, bash shell also use the same key-binding as emacs.

12条回答
干净又极端
2楼-- · 2020-02-16 06:05

Go to Bookmarks > Manage Profiles. Then select Keyboard Profiles > Global and choose Option Key as +ESC.

Works in iTerm Build 0.9.5.0611 & Build 0.9.6.20090415

查看更多
【Aperson】
3楼-- · 2020-02-16 06:05

I use iTerm2, and for me, this answer just partially solved my problem:

Cmd+, => Profiles => Keys and choose Left option Key acts as: +Esc.

enter image description here

In addition to that, I had to go to Cmd+, => Profiles => Keys and in the Key Mappings list find both Key Combinations: enter image description here and enter image description here, double click them and change their shortcuts to the following:

enter image description here

enter image description here

*Make sure to select Send Escape Sequence action.

查看更多
forever°为你锁心
4楼-- · 2020-02-16 06:07

Going all zombie resurrection here, but for sake of posterity --

This post got it working as you desire for me, for M-b and M-f, while keeping 'Option Key as Meta' set so you don't sacrifice a modifier (I have vim mappings using meta, personally).

In summary, in your Global Keyboard Profile, add two new mappings with settings:

  1. Key as hex code, value of 62 for b, 66 for f (man ascii)
  2. Modifier as Option
  3. Action as send escape sequence, value b or f

The only thing I still miss from Terminal.app is Opt-Backspace to delete by word. There are other workarounds for that, but I'm just trying to train myself to use Ctrl-w.

查看更多
Anthone
5楼-- · 2020-02-16 06:08

Cmd+., Profiles, Keys and choose Left option Key acts as: +Esc.

Works for me in emacs, though I'm not sure if it will have any other undesirable effects.

查看更多
乱世女痞
6楼-- · 2020-02-16 06:13

Go to Bookmarks > Manage Profiles. Then select Keyboard Profiles > Global and choose Option Key as Meta. This works for me in version 0.9.6.1201.

查看更多
SAY GOODBYE
7楼-- · 2020-02-16 06:14

I found some solution on stackoverflow also, just go to keyboard profile and in "Global" change "Option key as" +ESC

that works for me perfectly =) btw some iterm patch exists also look here: http://www.emacswiki.org/emacs/EmacsForMacOS

查看更多
登录 后发表回答