03 April, 2008

Alt-Delete in iterm

There are two ways you can backwards delete a word out of the box with iterm:
Ctrl+w
Esc, Ctrl+h or Esc, Delete

Finally, using some unix trickery, I got option+delete working. First, I used the bind command to map Esc, d to backwards delete word. Edit ~/.bash_profile in your favorite text editor and add the line:

bind '"\M-d": backward-kill-word'

(Make sure you have all those quotes, otherwise it doesn't work.)

Now that you have an escape sequence that doesn't require the Ctrl key, you can map option+delete to it in iTerm.

In iTerm, go to Bookmarks > Manage Profiles. Choose Keyboard Profiles > Global and click the + button to add a key binding. Choose delete from the dropdown, check the option checkbox, and then in the Action: dropdown choose escape sequence. In the text field that appears, type d. I also checked the High interception priority checkbox for good measure.
http://hackaddict.blogspot.com/2008/01/delete-backwards-word-with-optiondelete.html

No comments: