在使用 iTerm 的时候,发现 + 方向键不能向系统自带的终端那样跳跃单词,解决的办法很简单,切换一下 iTerm 的键盘模式即可,方法如下:

如图,打开 Profile -> Keys -> Presets(进入键盘设置预置方案),选择 Terminal.app Compability 即可。

66037-koz30su3ee.png

61863-stahqm5zsr.png

这样就跟系统自带的 Terminal 一致了,比较符合笔者的个人习惯。

以下是转自 Coderwall 的一篇文章,讲的是如何手动修改的办法,感觉略有点麻烦,就不翻译了,随便看看吧。

By default in iTerm 2, it's a pain to skip between words.

Here's how you can configure iTerm 2 on OSX to allow you to use + and + to do just that.

First you need to set your left ⌥ key to act as an escape character.

67873-eaxmvorofhn.png

Second you need to either locate the current shortcut for ⌥ ← or create a new one, in the Profile Shortcut Keys, with the following settings:

  • Keyboard Shortcut: ⌥←
  • Action: Send Escape Sequence
  • Esc+: b

31233-7ssk1vqtfh6.png

Third, repeat for the ⌥→ keyboard shortcut with the following settings:

  • Keyboard Shortcut: ⌥→
  • Action: Send Escape Sequence
  • Esc+: f

You're done! Now you can skip entire words on the command line by holding down the left ⌥ key and hitting ← or →

To make this work for the right option key you need to set the key modifier to act as an Escape Sequence, a la the first step.

标签: macos, iterm

添加新评论