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:

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.

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~

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_profileNow you can restart Terminal, and your backspace and delete should work correctly everywhere!