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 05:53

In Menu bar Iterm2 => Preferences => Profiles choose the keys tab and select

left Option key act as +Esc

enter image description here

worked for me as well in irssi.

查看更多
Root(大扎)
3楼-- · 2020-02-16 05:55

It's easier in iTerm2. Go to preferences->bookmark->keyboard and select Option sends +ESC. In iTerm2 you can configure the left and right option keys separately, so remember to change both if that's what you want. Link for iTerm2: http://sites.google.com/site/iterm2home/

查看更多
老娘就宠你
4楼-- · 2020-02-16 05:56

Here is what worked for me: Bookmarks > Manage Profiles > Keyboard Profiles > Global/xterm > Option Key as +Esc. With this, I can use Option+Enter in Midnight Commander and the currently selected file/directory name shows up in the command string, as it should. Option Key as Meta did not work for me. My build of iTerm is 0.10.

查看更多
Viruses.
5楼-- · 2020-02-16 05:59

I couldn't get the Alt key working either but there is a workaround that makes it at least function for word navigation via the cursor keys:

Skip to Next or Previous Word in iTerm Using Alt / Option + Left or Right Arrow Keys

查看更多
萌系小妹纸
6楼-- · 2020-02-16 06:00

Try "export LANG=C". I'm not emacs expert, but I found this enables emacs on OS X to recognize the Option key as the Meta key in iTerm,

查看更多
我命由我不由天
7楼-- · 2020-02-16 06:04

I don't know about iTerm, but you can do this in Terminal. Instructions can be found here:

Emacs on Mac OS X Leopard key bindings

查看更多
登录 后发表回答