Skip to content

Instantly share code, notes, and snippets.

@jimmyhillis
Last active April 17, 2024 08:39
Show Gist options
  • Save jimmyhillis/8552424 to your computer and use it in GitHub Desktop.
Save jimmyhillis/8552424 to your computer and use it in GitHub Desktop.
iTerm 2 Mac-ready key binding additions.

Standard bindings

  • Move left between words: ⌥← | send escape sequence | b
  • Move right between words: ⌥→ | send escapes sequence | f
  • Start of the line: ⌘← | send escape sequence | [H
  • End of the line ⌘→ | send escape sequence | [F
  • Delete previous word ⌥←Delete | send hex code | 0x1B 0x08
  • Delete entire line ⌘←Delete | send hex code | 0x15

Don't forget the amazing icons ⌘ = command and ⌥ = options/alt (why oh why?).

ZLE bindings

Oh-my-zsh have made some changes to use ZLE which you can see talked about issue and commit so there are different bindings for that.

  • Start of the line: ⌘← | send escape sequence | OH
  • End of the line ⌘→ | send escape sequence | OF
@drobakowski
Copy link

Thanks for sharing! Unfortunately the hex codes 0x1B 0x08 for ⌥←Delete are not working for me with iTerm 2 Build 3.0.14 / fish 2.5.0 / bash 4.4. Instead I had to use 0x17 - see https://coderwall.com/p/ds2dha/word-line-deletion-and-navigation-shortcuts-in-iterm2 for more details.

@FullStackAlex
Copy link

0x1B 0x08 works just fine in iTerm2 build 3.3.9. It does delete a word until the next special character (whereas 0x17 deletes the whole word regardless any special chars)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment