袋熊的树洞

日拱一卒,功不唐捐

0%

终端快捷键

环境

OS: OS X 10.11.6

Shell: bash and zsh

Other: iTerm2

快捷键列表

快捷键 功能
Option + Left or Right 光标按单词前移或后移
Control + F or B 光标向前或向后移动一个字符
Control + D 删除当前光标的字符
Control + H 删除光标之前的字符
Control + W 删除光标之前的单词
Command + A 移动光标到行首
Command + E 移动光标到行尾巴
Control + U 清除整行内容
Control + K 删除光标之后的内容
Control + C Kill掉当前运行的程序
Control + Z 暂停当前运行程序,要恢复运行使用 fg process_name

快捷键详细信息

Option + Left or Right

如果使用iTerm2作为终端模拟器时,该快捷键不是所预想的功能,此时需要进行设置,这里贴出[4]提供的教程

Step 1: 在 Profiles-Keys 下设置 Left ⌥ key to act as Esc+

Step 2: 添加一个快捷键 ⌥ ←,快捷键设置内容为

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

Step 3: 添加一个快捷键 ⌥ →,快捷键设置内容为

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

参考

  1. iTerm2 快捷键大全
  2. The Best Keyboard Shortcuts for Bash (aka the Linux and macOS Terminal)
  3. 20 Terminal shortcuts developers need to know
  4. Use ⌥ ← and ⌥→ to jump forwards / backwards words in iTerm 2, on OS X