With iTerm2 on Mac, how to delete forward a word from cursor on command-line?
Preferences
→ Profile
→ Keys
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
if you use zShell)
⌥←Delete Send Hex Code 0x1B 0x08
⌘Del→ Send Hex Code 0x0b
⌥Del→ Send Escape Sequence d
I don't have a mac handy, but ESC d should in theory do the same thing that ALT-d does.
NOTE: this means hitting ESC, releasing it, then hitting d. Look ma, no key chords.
Just to add to Alexsander's answer the easiest way to replicate this behaviour is to select the option "Left option key acts as +Esc" in the Preferences->Profiles-> Keys screen.