[Previous] [Contents] [Index] [Next]

stty

Set tty attributes (POSIX)

Syntax:

stty [-a|-g] [operands] [< device]

Options:

-a
Display all settings.
-g
Display in "getable" form.

Description:

The stty utility sets and/or reports terminal I/O characteristics for the device that is its standard input. If no operands are specified, stty displays the settings. If operands are given, then stty changes the terminal state to reflect those settings.

Terminal settings fall into two major categories:

edit mode
The user can edit the input data. It's made available to programs only when a CR is pressed. Output data is normally presented in a human-readable format.
raw mode
All data flows to and from the terminal with little extra processing.

If you're at a shell prompt, your terminal is probably in the default system edit mode. A full-screen program such as an editor, on the other hand, typically puts the terminal into raw mode.

Normally, stty displays only significant settings relative to the system default settings for edit or raw, and displays only the defined control characters. If -a or -g is specified, then stty displays all the settings.

The stty utility manages a very large number of potential terminal attributes and control characters. Most of these parameters are very device-specific and seldom need to be changed by the user. Programs often change these terminal attributes in the course of their operation, and upon occasion (such as abnormal termination) may leave the terminal settings in an unknown state. The stty +edit option is a convenient method of restoring a terminal to a usable state.

Supported operands

The tables below list the operands supported by stty. In these tables, the following conventions are used:

number
A decimal integer number (e.g. 9600).
name
A string of characters (e.g. vt100).
value
A single character (e.g. ~) or a 2-digit hexadecimal number (e.g. 1B) or one of the following character pairs:
Char pair Hex
^- 00 (undefined)
^A to ^Z 01 to 1A
^[ 1B
^\ 1C
^] 1D
^^ 1E
^_ 1F
^? 7F

Some options can start with either + or -:

+
Turn the option on.
-
Turn the option off.

If you don't specify + or -, + is assumed.

Also note that the = character is optional in operands of the form keyword=value.


Note: The following descriptions give the action taken when the option is on.

Line control parameters

Parameter Defines
baud=number Input and output baud rates
ispeed=number Input baud rate
ospeed=number Output baud rate
par=none No parity (same as -parenb)
par=odd Odd parity (same as +parenb, +parodd, -parstk)
par=even Even parity (same as +parenb, -parodd, -parstk)
par=mark Mark parity (same as +parenb,+parodd, +parstk)
par=space Space parity (same as +parenb, -parodd, +parstk)
bits=5 5-bit characters
bits=6 6-bit characters
bits=7 7-bit characters
bits=8 8-bit characters
stopb=2 2-stop bits
stopb=1 1-stop bits
{+|-}parenb Enable parity
+parodd Odd parity
-parodd Even parity
{+|-}parstk Stick parity
+cs5 Same as bits=5
+cs6 Same as bits=6
+cs7 Same as bits=7
+cs8 Same as bits=8
+cstopb Same as stopb=2
-cstopb Same as stopb=1
number Same as baud=number
+evenp Same as par=even, bits=7
-evenp Same as par=none, bits=8
+parity Same as par=even, bits=7
-parity Same as par=none, bits=8
+oddp Same as par=odd, bits=7
-oddp Same as par=none, bits=8
{+|-}hupcl Hangup on last close
{+|-}hup Same as hupcl
{+|-}cread Enable receiver
{+|-}clocal Assume no modem control
{+|-}ihflow Enable hardware input flow control
{+|-}ohflow Enable hardware output flow control
{+|-}isflow Enable software input flow control
{+|-}osflow Enable software output flow control
{+|-}lkhflow Lock hardware flow control (ihflow/ohflow)
{+|-}lksflow Lock software flow control (isflow/osflow)
{+|-}ihpaged Input is paged by hardware flow control
{+|-}ohpaged Output is paged by hardware flow control
{+|-}ispaged Input is paged by software flow control
{+|-}ospaged Output is paged by software flow control

Input processing parameters

Parameter Defines
{+|-}ignbrk Ignore received hardware breaks
{+|-}brkint Generate SIGINT upon break
{+|-}ignpar Ignore parity errors
{+|-}parmrk Mark parity errors
{+|-}inpck Enable software parity checking
{+|-}istrip Strip 7th bit from received characters
{+|-}inlcr Map NL into CR on input
{+|-}onlcr Map NL into CR on output
{+|-}igncr Ignore received CR
{+|-}icrnl Map CR into NL on input
{+|-}ixon Same as osflow
{+|-}ixoff Same as isflow
{+|-}isig Generate signals upon receipt of special characters
{+|-}icanon Enable input line editing
{+|-}iexten Enable "extra" special characters
{+|-}echo Echo received characters
{+|-}echoe Erase character erases displayed character
{+|-}echok Kill character erases displayed line
{+|-}echonl Echo NL, even if ECHO is off
{+|-}noflsh Don't flush I/O after INTR, QUIT, or SUSP
min=number Minimum characters required to satisfy raw input
time=number Timeout value for raw input
{+|-}tostop Send SIGTTOU for background output.
+nl Same as +icrnl
-nl Same as -icrnl, -inlcr, -igncr
+sane Reset all parameters to sane values based on current mode (edit/raw)
+fix Same as +sane
+edit Reset parameters to system default edit mode
+flush Flush all pending input and output
+raw Reset parameters to system default raw mode

Output processing parameters

Parameter Defines
{+|-}opost Post-process output data

Special control characters

Parameter Defines
eof=value End-of-file character
eol=value End-of-line character
erase=value Delete previous character
kill=value Delete entire line character
intr=value Generate SIGINT character
quit=value Generate SIGQUIT character
susp=value Generate SIGTSTP character
stop=value Stop output
start=value Resume output
+ek Resets ERASE and KILL to system defaults

Extended line-editing character sequences

QNX Neutrino supports multicharacter sequences to support editing capabilities in addition to the basic "erase" and "kill" functions. All of these sequences are assumed to start with an (up to) 4-character prefix, a single-character action, followed by an (up to) 4-character suffix. Typically, the cursor keys on your terminal are used for these functions.

Parameter Meaning
+load Set editing keys based on currently defined terminal type
term=name Set editing keys for the specified type of terminal
pr1=value First character of prefix
pr2=value Second character of prefix
pr3=value Third character of prefix
pr4=value Fourth character of prefix
sf1=value First character of suffix
sf2=value Second character of suffix
sf3=value Third character of suffix
sf4=value Fourth character of suffix

Action characters

The following are action characters when preceded by prefix (subsequent suffix are discarded).

Parameter Meaning
up=value Recall previous line
down=value Recall next line
left=value Move cursor left
right=value Move cursor right
ins=value Toggle insert mode
del=value Delete current character
rub=value Delete previous character
can=value Delete entire line character
home=value Move cursor to beginning of line
end=value Move cursor to end of line

Examples:

Display settings of the terminal to which stty is attached:

stty

Display settings of a specified device:

stty < /dev/ser1

Change the baud rate of a specified device:

stty baud=1200 < /dev/ser1

Put terminal into a fixed, sane state:

stty +sane

Set editing keys to VT100 values:

stty term=vt100

Restore settings from a shell variable:

stty $saveterm

Exit status:

0
Success.
>0
An error occurred.

Caveats:

The stty utility quietly accepts all of the documented options, but some of the current managers might not support them.


[Previous] [Contents] [Index] [Next]