How to get macOS hotkeys working in iTerm
macOS has a bunch of great Emacs-derived keyboard shortcuts for editing text -- ⌃a
, for instance, will take you to the start of the line you're editing. These keyboard shortcuts work throughout the vast majority of applications on macOS, which means you have access to robust text manipulation shortcuts even when you aren't inside a proper text editor. People at Apple have clearly put a lot of deep thought into how experts use their software, because macOS' keyboard shortcuts are leagues better than on Windows and Linux.
The ultimate killer feature is the ability to incrementally search application menu bars to discover keyboard shortcuts. It's infinitely better to holding alt on Windows to reveal keyboard accelerators, and the only downside is that it doesn't work when applications don't put all of their functionality in the menubar as is the case with Zoom.
(If macOS had decent in-built window management... but that's what Magnet or Rectangle are for.)
Unfortunately, the navigation shortcuts using command (⌘)/option (⌥) and an arrow key don't work in terminal emulators like iTerm, and it's not entirely obvious how to add them to iTerm manually. While all of these do have control-key equivalents, the command/option variants might be easier to use for you. Here's how you can do it:
- Open iTerm
- Navigate: ⌘ + , → Profiles -> Keys -> Key Mappings
- Click the + button for each of the following:
- Keyboard shortcut: ⌘ + →; Action: Send hex code
0x05
- Keyboard shortcut: ⌘ + ←; Action: Send hex code
0x01
- Keyboard shortcut: ⌘ + ⌫; Action: Send hex code
0x15
- Keyboard shortcut: ⌥ + →; Action: Send esc sequence
b
- Keyboard shortcut: ⌥ + ←; Action: Send esc sequence
f
- Keyboard shortcut: ⌥ + ⌫; Action: Send hex code
0x17
- Keyboard shortcut: ⌘ + →; Action: Send hex code