Using stty
There is several functions that can be done by typing in a
particular character in your shell. The stty function can
be used to find out what character and to set/unset that character as
well (as I demonstrated with removing the 'stop').
Getting the current characters
This is simple enough, simply type:
$ stty -a speed 38400 baud; rows 44; columns 111; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol =; eol2 = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
So you can see for example, intr = ^C. The
^C represents a 'control character'. So in this case
holding down the 'Ctrl' key and the 'c' key will produce
^C. This is, of course, the interrupt to stop a program
from running. Note that the shift key has no effect on control
characters, ^c and ^C are the same.
So lets just run through all the various items:
- erase
- The erase function is probably one that you use all the time.
It will delete the last character you typed. If you have
^?like I do above, then the key Delete will work. Another common one for erase is^Hwhich is the Backspace key. - werase
- The word erase will erase the last word that you typed. In
this case my terminal has that set to
^W. - kill
- This is a line kill, it will delete all the text in the
current line of the shell. In this case
^Uis for my terminal. In some setups this is^Kor even@. - intr
- The interrupt key will abort the current running command. Some
setups will use the Delete key for that and therefore
you will see
^?. - stop
- The stop function will cease the flow of the terminal, it is
intended for when you have text is flowing very quickly, too quick
to read. Then you can stop it, and start it again. In this case
^Sis set. - susp
- The suspend function, will stop a job being run but instead of
aborting it will just freeze the job. You can then use the
fgorbgcommands to start the job again.
Assigning Characters
If you find that the characters that are set aren't to your liking
or maybe don't fit your keyboard very well then you can use
stty to set your prefered characters.
For example you can do this:
$ stty intr ^c
That will set the interrupt function to the Ctrl and c key press.
stty gives you the power to setup your terminal in the
manner you wish.
