Skip to content

Instantly share code, notes, and snippets.

@mul14
Forked from ezekg/profile.md
Created October 26, 2018 00:35
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save mul14/32cb303493b4c8057a6ca147010276a0 to your computer and use it in GitHub Desktop.
Save mul14/32cb303493b4c8057a6ca147010276a0 to your computer and use it in GitHub Desktop.
iTerm key bindings

Open the iTerm preferences ⌘+, and navigate to the Profiles tab (the Keys tab can be used, but adding keybinding to your profile allows you to save your profile and sync it to multiple computers) and keys sub-tab and enter the following:

Delete all characters left of the cursor

⌘+←Delete Send Hex Codes:

  • 0x18 0x7f – Less compatible, doesn't work in node and won't work in zsh by default, see below to fix zsh (bash/irb/pry should be fine), performs desired functionality when it does work.
  • 0x15 – More compatible, but typical functionality is to delete the entire line rather than just the characters to the left of the cursor.

Delete all characters right of the cursor

⌘+fn+←Delete or ⌘+Delete→ Send Hex Codes:

  • 0x0b

Delete one word to left of cursor

⌥+←Delete Send Hex Codes:

  • 0x01b 0x08

Delete one word to right of cursor

⌥+fn←Delete or ⌥+Delete→ Send Hex Codes:

  • 0x01b 0x64

Move cursor to the front of line

⌘+← Send Hex Codes:

  • 0x01

Move cursor to the end of line

⌘+→ Send Hex Codes:

  • 0x05

Move cursor one word left

⌥+← Send Hex Codes:

  • 0x1b 0x62

Move cursor one word right

⌥+→ Send Hex Codes:

  • 0x1b 0x66

Undo

⌘+z Send Hex Codes:

  • 0x1f

Redo

Typically not bound in bash, zsh or readline, so we can set it to a unused hexcode which we can then fix in zsh.

⇧+⌘+Z or ⌘+y Send Hex Codes:

  • 0x18 0x1f

Stolen from: http://stackoverflow.com/questions/6205157/iterm2-how-to-get-jump-to-beginning-end-of-line-in-bash-shell#answer-29403520

@neaumusic
Copy link

PreferencesProfileKeys add the following shortcuts:


Send Escape Sequence Esc+ b

Send Escape Sequence Esc+ f

Send Escape Sequence Esc+ [H

Send Escape Sequence Esc+ [F

←Delete Send Hex Code 0x18 0x7f (add bindkey "^X\\x7f" backward-kill-line to .zshrc)

←Delete Send Hex Code 0x1B 0x08

Del→ Send Hex Code 0x0b

Del→ Send Escape Sequence d

@maximvl
Copy link

maximvl commented Oct 20, 2023

Thank you so much for this arcane knowledge!

@alexbowers
Copy link

0x17 mapped with Alt backspace to delete by word

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