开发工具 iTerm2 中有没有 Home/End 快捷键

camel · 2011年12月31日 · 最后由 felix9ia 回复于 2020年08月24日 · 19279 次阅读

输入一条很长的命令后忽然发现最前面少几个单词,此时只能狂按 Left 把光标从未尾移到开头,非常麻烦。

很多软件中都是 Command+Left=Home,Command+Right=End,很棒

有没有人知道怎么设置一下 iTerm2

Ctrl + A/E 至行首/尾。非 iTerms 专有,OS X 的内转快捷键是也。

利用 Shell 的 key binding 吧。

Ctrl + a:移到命令行首 Ctrl + e:移到命令行尾 Ctrl + f:按字符前移(右向) Ctrl + b:按字符后移(左向) Alt + f:按单词前移(右向) Alt + b:按单词后移(左向)

http://linuxtoy.org/archives/bash-shortcuts.html

如果在 osx 下的话,除了 shell 的 key 外,用 fn+ 左右箭头就是行首行尾

#1 楼 @ashchan #2 楼 @_kaichen hoho.... emacs key binding... :)

#3 楼 @camel 你也可以启动 vim mode,按 esc,然后就各种 b, w shift + i, shift + a.....

#5 楼 @poshboytl shell 里用 vim binding 很蛋疼

如果你发现写的太复杂,可以用 ^X^E 启动 editor 来编辑 fc 可以用编辑器来编辑历史命令

进入 Preferences,Keys,left option 改为+Esc

修改 option+left:action 改为 Send Escape Sequence,Esc+ 为 B 修改 opton+right:action 改为 Send Escape Sequence,Esc+ 为 F 增加 cmd+left:action 改为 Send Escape Sequence,Esc+ 为 [H 增加 cmd+right:action 改为 Send Escape Sequence,Esc+ 为 [F

这样 option+left、right 就是左右移动单词,cmd+left、right 就是移动到行首行尾

@knwang @poshboytl 问一下也使用 iterm2+tmux+shell vim 的同学,请问你们 shell 里面的 vim 能用 meta 件吗?我之前设的许多map <M-xxx>的按键在 shell vim 里面都失效,macvim 则没问题,google 了下也没有很好的解决办法...

进入 Preferences,Keys

Keyboard shortcut: ⌥ + ← Action: Send Hex Code Code: 0x1b 0x62 enter image description here

Keyboard Combination: ⌥ + → Action: Send Hex Code Code: 0x1b 0x66 Move cursor to beginning of line

Keyboard Combination: ⌘ + ← Action: Send Hex Code Code: 0x01 Move cursor to end of line

Keyboard Combination: ⌘ + → Action: Send Hex Code Code: 0x05

需要 登录 后方可回复, 如果你还没有账号请 注册新账号