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
⌘+Delete→ Send Hex Codes: