Terminal Options
Technical Stuff About 14 zillion different settings are associated with each terminal or pseudo-terminal attached to a UNIX system, any of which you can change with the stty command. More than 13 zillion of the 14 zillion shouldn’t be messed with, or else your terminal vanishes in a puff of smoke (as far as UNIX is concerned), and you have to log in all over again or even get your system administrator to undo the damage. You can, however, safely change a few things.All the special characters that control the terminal, such as Backspace and Ctrl+Z, are changeable. People often find that they prefer characters other than the defaults, for any of several reasons: They became accustomed to something else on another system, the placement of the keys on the keyboard makes some choices more natural than others, or their terminal emulator is dumb about switching Backspace and Delete. The special characters that control the keyboard are described in Table 7-1.Name | Typical Character | Meaning |
---|---|---|
erase | Ctrl+H | Erases (backspaces over) the preceding character |
kill | Ctrl+U | Discards the line typed so far |
eof | Ctrl+D | Marks the end of input to a program |
swtch | Ctrl+Z | Pauses the current program (see Chapter 13) |
intr | Ctrl+C | Interrupts or kills whichever program is running |
quit | Ctrl+\ | Kills the program and writes a core file |
To tell stty to change any of these control characters, you give it the name of the special character to change and the character you want to use. If, as is common, you want to use a control character, you can type a caret (^ — the thing above the 6 on the key in the row of keys across the top of the keyboard) followed by the plain character, both enclosed in quotation marks. As a special case, ^? represents the Del or Delete key. The Tab key is represented as ^I . The Backspace key is usually ^H . To make the Delete key the erase character and Ctrl+X the kill character, for example, type this line:
stty erase ‘^?’ kill ‘^X’
If you’re feeling perverse, you can set the various control characters to whatever you want. You can make the erase character q and the intr character 3 , although doing so makes getting any work done difficult because you couldn’t use q or 3 in anything you type.The other thing you can change is terminal output stop mode, which controls whether background jobs can display messages on your terminal. (Chapter 13 explains what this statement means.) To allow output from background jobs to display on your terminal, turn off output stop mode by typing
stty -tostop
To prevent output from background jobs, or, more exactly, to make background jobs stop and wait when they want to display something, turn on output stop mode by typing this line:
stty tostop
All these stty commands usually go in the .login or .profile file so that the terminal is set up the way you want every time you log in.