stty
stty: show or change the terminal’s line settings.
Synopsis
stty
stty setting…
stty -g
Description
stty reads and changes the line settings (termios flags) of the tty on its standard input, as Linux’s stty does. With no arguments it lists every flag on one line, sorted, a flag that is off with a - before it, then min and time.
Each setting is applied in order; the flags are written back to the tty once all have been read. An invalid setting stops it before anything is changed.
Settings
- flag
- Turns flag on.
- -flag
- Turns flag off.
- min n
- A read in raw mode (with -icanon ) waits for n bytes (0 to 255; VMIN).
- time n
- A read in raw mode waits up to n tenths of a second (0 to 255; VTIME): for the first byte with min 0 (it reads nothing when the time passes); with min over 0, from each byte to the next. With min 0 time 0 a read takes what’s there now, nothing if nothing is.
- raw or -cooked
- Turns off icanon, echo, isig and icrnl, and sets min 1 time 0.
- -raw or cooked
- Turns those four back on.
- sane
- Puts every flag below back on (Linux’s defaults).
- size
- Prints the terminal’s rows and columns, as two numbers on a line.
- -g
- Prints every setting as one word that stty takes back as a setting: save it, change the settings, and put them back with stty “$saved”.
Flags
- icanon
- Line editing: input is read a line at a time, with Backspace, ^U and ^D.
- echo
- Typed characters are shown.
- echoe
- Backspace erases the character on the screen.
- echoctl
- Control characters are echoed as ^X.
- isig
- ^C sends SIGINT to the terminal’s foreground process group.
- icrnl
- Enter (a carriage return) comes in as a new line.
- onlcr
- A new line goes out as carriage return and new line.
- iutf8
- Backspace erases a whole UTF-8 character.
Exit status
0 on success; 1 when standard input isn’t a tty, a setting is invalid, or the settings can’t be set.
Examples
stty -echo
stty -icanon min 0 time 5
stty raw
stty sane
stty size
Notes
These are the tty’s settings, kept by the kernel. A terminal’s own modes (cursor keys, the alternate screen) are set with escape sequences, not with stty. The only special-character settings are min and time (no intr ^C), and there are no speeds. What -g prints is mcos’s own (the flags and min and time, joined by colons), as GNU’s is its own.
See also
sh(1), clear(1)