Have you ever sat down at a terminal where the "erase" key (the character that deletes the last thing you typed) wasn't where you thought it would be? If you have, you know how disorienting this can be! The command gives you a way of changing the erase character (along with several others) so you can restore some order to your world.
stty takes two kinds of input. If you want to give the command
char is the key you
normally use for erase - BACKSPACE, DELETE, whatever - followed by
RETURN. This will do the trick, provided that the character you
type isn't already used for something. If the character is in use, or if you're
putting stty commands into your .login or .profile file,
to "spell these characters out." "Control" characters in
.login are allowed, but they aren't a great idea. If you like
to use the BACKSPACE key as the erase key, add the line below:
stty erase ^h
If you want to use the DELETE key, quote the
so the shell won't treat it as a
stty erase ^\?
That is: stty lets you represent a control key with the two-character
^ is the literal key
x is any single character.
You may need to put a
\ before the
x to prevent the
shell from interpreting it as a wildcard [and a
\ before the
^ to prevent some Bourne shells from interpreting it as a
Of course, you're not limited to the BACKSPACE or DELETE
keys; you can choose any other key you want. If you want to use "Z" as
your DELETE key, type
Z. Just make sure you never want to type a real
Table 5.1 lists functions that stty can change.
|Character||Function||Good Setting||See Article|
|erase||Erases the previous character.||^\? (DELETE)||5.9|
|kill||Erases the entire line.||^u (CTRL-u)||9.2|
|werase||Erases the previous word.||^w (CTRL-w)||9.2|
|intr||Terminates the current job.||^c (CTRL-c)||38.9|
|quit||Terminates the current job, makes a core file.||^\\ (CTRL-\)||38.9|
|susp||Stops the current job (so you can put it in the background).||^z (CTRL-z)||12.1|
|rprnt||Redisplays the current line.||^r (CTRL-r)||9.3|
The command stty everything (for BSD UNIX) or stty -a (for System V) shows all your current terminal settings. The werase and rprnt characters aren't implemented on many System V versions.
As a historical note: the erase character was originally
#, and the
kill character was originally
@. These assignments go back to
when terminals printed with real ink on real paper
and made lots of noise. However, I'm told that there are some modern
systems on which these settings are still the default.
NOTE: Terminal emulators, editors, and other programs can fool around with all of this stuff. They should be well-behaved and reset your terminal when you leave them, but that's often not true. So: don't expect your settings to work within a terminal emulator; they may, or they may not. And don't expect your settings to be correct after you exit from your terminal emulator. Again, they may, or they may not. The tset program also with key settings. Therefore, in your , put stty after tset.