As a software engineer, I find myself using the terminal every day to run all sorts of commands. My current terminal of choice is iTerm2 which I’ve been using happily for many years.
Whenever I set up iTerm2 on a new Mac, one of the first things I do is to configure familiar keyboard shortcuts for common navigation and edit actions in the command prompt. For example, I typically configure the ⌥← shortcut which jumps me to the start of the word under the cursor.
To configure custom keyboard shortcuts in iTerm2, open the preferences dialog and navigate to the Profiles › Keys › Key Mappings tab:
Click the “+” button to add a new key mapping, or double-click an existing key mapping to edit it. For the “Jump to start of word” command, select the “Send Escape Sequence” action and send the escape sequence
Now, whenever you're typing a command in iTerm2, it's really easy to jump back to the start of the word (or even multiple words) to insert more text or delete part of the command — no more need for repeatedly pressing the ← key to navigate back character by character.
Here's the full list of keyboard shortcuts that I configure for various jump and delete commands:
|⌥←||Jump to start of word||Send Escape Sequence||
|⌥→||Jump to end of word||Send Escape Sequence||
|⌘←||Jump to start of line||Send Hex Codes||
|⌘→||Jump to end of line||Send Hex Codes||
|⌥⌫||Delete to start of word||Send Hex Codes||
|⌘⌫||Delete entire line||Send Hex Codes||