Fixing Delete and Backspace in OS X Terminal

I’m constantly having trouble with getting the backspace and delete keys to work properly in OS X. Whenever it works right on the Mac, one or the other key is broken when I  SSH to a Linux or FreeBSD box.

After some searching, I’ve found this solution, which seems to be working:

  1. First, got to the Terminal menu, and choose Preferences… Under the Settings section, choose the Advanced tab. Make sure Delete sends Ctrl-H is checked.
  2. Then, in the same window, go to the Keyboard tab (right next to Advanced). Find the line for forward delete, and set it to this value:
    \033[3~
  3. Lastly, you need to run the following line at the terminal. The trick with the line below though is that you need to type the ^H by pressing Control-V and then Control-H. You can not just cut and paste the line below, you need to type it:
    echo -e "stty erase ˆH" >> ~/.bash_profile


Now you can restart Terminal, and your backspace and delete should work correctly everywhere!

For further reading on this topic check out these two links:

This problem, and various solutions are documented all over the net, but I found and used this page most recently.

About Josh

Josh is a software architect and engineer with a fine arts background. You can connect with him on Google+.
This entry was posted in Tech and tagged , , , , , , , . Bookmark the permalink.

One Response to Fixing Delete and Backspace in OS X Terminal

  1. Brandon says:

    This fixes the shell, but it breaks emacs (^H is used for opening the help window in emacs, which you’ll now do everytime you hit the backwards-delete key). It also doesn’t fix the forward-delete key (at least on the system I’m logging into) which gives a ~ every time I use it.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>