Sunday, December 24, 2006

stty is your friend. stty (man stty) allows you to set your "terminal line settings". When you are using a shell in a window, that window is showing you a terminal.

There are a bunch of important stty settings that should be set, most get set by default. One that sometimes doesn't is
 stty erase ^H 
If you have ever been trying to delete characters on the command line with backspace, or when you try to backspace in less or more, and all you see is a whole bunch of ^H^H^H^H^H, this stty setting isn't set.

Another super cool one that I just found stty very useful for was in the mysql client. I instinctively would press ctrl-C to cancel a command, in the mysql client, this issues the quit command. So, undaunted, I just did the following, which emulates pretty closely the behaviour I really want:
 stty intr ^t stty kill ^c 
This resets the Interrupt signal (intr) to a key I don't use very much, ctrl-t, and sets ctrl-c to kill, which deletes the current line.

Neat, eh?

No comments: