Elliott's Blog | Life Through Math, Algorithms and Code

Sep/10

18

Delete key issues with ^H (Ctrl-H) and ssh on OS X

If you live in a Terminal window like I do and frequently connect to servers and other machines through ssh you’ve run across an issue where the delete key doesn’t seem to work when connected to a remote server in OS X with ssh. I find this happens when you ssh to an Ubuntu machine and then run an editor like vim/emacs/pico/etc. The suggested fix is to check the checkbox under Preferences > Settings > Advanced called “Delete sends Ctrl-H”. Once this is checked the delete key works as expected… well almost!

You’ll soon find that with this enabled the delete key doesn’t seem to work when you’re typing in certain contexts in the Terminal and not connected to a remote server. An easy way to experience this is to run php and type some text and then hit delete. You’ll see the text ^H appear in the window but nothing will be deleted.

The issue here is that the local erase character is not configured to be ^H, but is instead ^? which means that while Ubuntu now understands the delete key, OS X doesn’t. Doh.

The fix is easy. Add this line to your .bash_profile in your home directory.

stty erase ^H

Now the delete key will work as expected on both OS X and when connected to remove servers.

No tags

No comments yet.

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me