xref: /original-bsd/bin/stty/stty.1 (revision b31c5a61)
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" %sccs.include.redist.man%
8.\"
9.\"     @(#)stty.1	6.17 (Berkeley) 07/10/92
10.\"
11.Dd
12.Dt STTY 1
13.Os
14.Sh NAME
15.Nm stty
16.Nd set the options for a terminal device interface
17.Sh SYNOPSIS
18.Nm stty
19.Op Fl a | Fl e | Fl g
20.Op Fl f Ar file
21.Op operands
22.Sh DESCRIPTION
23The
24.Nm stty
25utility sets or reports on terminal
26characteristics for the device that is its standard input.
27If no options or operands are specified, it reports the settings of a subset
28of characteristics as well as additional ones if they differ from their
29default values.
30Otherwise it modifies
31the terminal state according to the specified arguments.
32Some combinations of arguments are mutually
33exclusive on some terminal types.
34.Pp
35The following options are available:
36.Bl -tag -width Ds
37.It Fl a
38Display all the current settings for the terminal to standard output
39as per
40.St -p1003.2 .
41.It Fl e
42Display all the current settings for the terminal to standard output
43in the traditional
44.Tn BSD
45``all'' and ``everything'' formats.
46.It Fl f
47Open and use the terminal named by
48.Ar file
49rather than using standard input.  The file is opened
50using the
51.Dv O_NONBLOCK
52flag of
53.Fn open ,
54making it possible to
55set or display settings on a terminal that might otherwise
56block on the open.
57.It Fl g
58Display all the current settings for the terminal to standard output
59in a form that may be used as an argument to a subsequent invocation of
60.Nm stty
61to restore the current terminal state as per
62.St -p1003.2 .
63.El
64.Pp
65The following arguments are available to set the terminal
66characteristics:
67.Ss Control Modes:
68.Pp
69Control mode flags affect hardware characteristics associated with the
70terminal.  This corresponds to the c_cflag in the termios structure.
71.Bl -tag -width Fl
72.It Cm parenb Pq Fl parenb
73Enable (disable) parity generation
74and detection.
75.It Cm parodd Pq Fl parodd
76Select odd (even) parity.
77.It Cm cs5 cs6 cs7 cs8
78Select character size, if possible.
79.It Ar number
80Set terminal baud rate to the
81number given, if possible.
82If the
83baud rate is set to zero, modem
84control is no longer
85asserted.
86.It Cm ispeed Ar number
87Set terminal input baud rate to the
88number given, if possible.
89If the
90input baud rate is set to zero, the
91input baud rate is set to the
92value of the output baud
93rate.
94.It Cm ospeed Ar number
95Set terminal output baud rate to
96the number given, if possible.
97If
98the output baud rate is set to
99zero, modem control is
100no longer asserted.
101.It Cm speed Ar number
102This sets both
103.Cm ispeed
104and
105.Cm ospeed
106to
107.Ar number .
108.It Cm hupcl Pq Fl hupcl
109Stop asserting modem control
110(do not stop asserting modem control) on last close.
111.It Cm hup Pq Fl hup
112Same as hupcl
113.Pq Fl hupcl .
114.It Cm cstopb Pq Fl cstopb
115Use two (one) stop bits per character.
116.It Cm cread Pq Fl cread
117Enable (disable) the receiver.
118.It Cm clocal Pq Fl clocal
119Assume a line without (with) modem
120control.
121.It Cm crtscts Pq Fl crtscts
122Enable RTS/CTS flow control.
123.El
124.Ss Input Modes:
125This corresponds to the c_iflag in the termios structure.
126.Bl -tag -width Fl
127.It Cm ignbrk Pq Fl ignbrk
128Ignore (do not ignore) break on
129input.
130.It Cm brkint Pq Fl brkint
131Signal (do not signal)
132.Dv INTR
133on
134break.
135.It Cm ignpar Pq Fl ignpar
136Ignore (do not ignore) parity
137errors.
138.It Cm parmrk Pq Fl parmrk
139Mark (do not mark) parity errors.
140.It Cm inpck Pq Fl inpck
141Enable (disable) input parity
142checking.
143.It Cm istrip Pq Fl istrip
144Strip (do not strip) input characters
145to seven bits.
146.It Cm inlcr Pq Fl inlcr
147Map (do not map)
148.Dv NL
149to
150.Dv CR
151on input.
152.It Cm igncr Pq Fl igncr
153Ignore (do not ignore)
154.Dv CR
155on input.
156.It Cm icrnl Pq Fl icrnl
157Map (do not map)
158.Dv CR
159to
160.Dv NL
161on input.
162.It Cm ixon Pq Fl ixon
163Enable (disable)
164.Dv START/STOP
165output
166control.
167Output from the system is
168stopped when the system receives
169.Dv STOP
170and started when the system
171receives
172.Dv START ,
173or if
174.Cm ixany
175is set, any character restarts output.
176.It Cm ixoff Pq Fl ixoff
177Request that the system send (not
178send)
179.Dv START/STOP
180characters when
181the input queue is nearly
182empty/full.
183.It Cm ixany Pq Fl ixany
184Allow any character (allow only
185.Dv START )
186to restart output.
187.It Cm imaxbel Pq Fl imaxbel
188The system imposes a limit of
189.Dv MAX_INPUT
190(currently 255) characters in the input queue.  If
191.Cm imaxbel
192is set and the input queue limit has been reached,
193subsequent input causes the system to send an ASCII BEL
194character to the output queue (the terminal beeps at you).  Otherwise,
195if
196.Cm imaxbel
197is unset and the input queue is full, the next input character causes
198the entire input and output queues to be discarded.
199.El
200.Ss Output Modes:
201This corresponds to the c_oflag of the termios structure.
202.Bl -tag -width Fl
203.It Cm opost Pq Fl opost
204Post-process output (do not
205post-process output; ignore all other
206output modes).
207.It Cm onlcr Pq Fl onlcr
208Map (not not map)
209.Dv NL
210to
211.DV CR-NL
212on output.
213.It Cm oxtabs Pq Fl oxtabs
214Expand (do not expand) tabs to spaces on output.
215.El
216.Ss Local Modes:
217.Pp
218Local mode flags affect various and sundry characteristics of terminal
219processing.  Historically the term "local" as pertaining
220to the terminal driver meant local to the VAX
221running in CORY hall on the UCB campus where features of the (then) new
222terminal driver that supported job control were first tested.  Alas,
223the terminology has stuck.  The other interpretation of the 'l' in lflag
224is that it stands for ``line discipline flag'', which is equally vacuous.  This
225corresponds to the c_lflag of the termios structure.
226.Bl -tag -width Fl
227.It Cm isig Pq Fl isig
228Enable (disable) the checking of
229characters against the special control
230characters
231.Dv INTR , QUIT ,
232and
233.Dv SUSP .
234.It Cm icanon Pq Fl icanon
235Enable (disable) canonical input
236.Pf ( Dv ERASE
237and
238.Dv KILL
239processing).
240.It Cm iexten Pq Fl iexten
241Enable (disable) any implementation
242defined special control characters
243not currently controlled by icanon,
244isig, or ixon.
245.It Cm echo Pq Fl echo
246Echo back (do not echo back) every
247character typed.
248.It Cm echoe Pq Fl echoe
249The
250.Dv ERASE
251character shall (shall
252not) visually erase the last character
253in the current line from the
254display, if possible.
255.It Cm echok Pq Fl echok
256Echo (do not echo)
257.Dv NL
258after
259.Dv KILL
260character.
261.It Cm echoke Pq Fl echoke
262The
263.Dv KILL
264character shall (shall
265not) visually erase the
266the current line from the
267display, if possible.
268.It Cm echonl Pq Fl echonl
269Echo (do not echo)
270.Dv NL ,
271even if echo
272is disabled.
273.It Cm echoctl Pq Fl echoctl
274If
275.Cm echoctl
276is set, echo control characters as ^X.  Otherwise control characters
277echo as themselves.
278.It Cm echoprt Pq Fl echoprt
279For printing terminals. If set, echo erased characters backwards within ``\\''
280and ``/''.  Otherwise, disable this feature.
281.It Cm noflsh Pq Fl noflsh
282Disable (enable) flush after
283.Dv INTR , QUIT , SUSP .
284.It Cm tostop Pq Fl tostop
285Send (do not send)
286.Dv SIGTTOU
287for background output.  This causes background jobs to stop if they attempt
288terminal output.
289.It Cm altwerase Pq Fl altwerase
290Use (do not use) an alternate word erase algorithm when processing
291.Dv WERASE
292characters.  This alternate algorithm considers sequences of
293alphameric/underscores as words.  It also skips the first preceding character
294in its classification (as a convenience since the one preceding character
295could have been erased with simply an
296.Dv ERASE
297character.)
298.It Cm mdmbuf Pq Fl mdmbuf
299If set, flow control output based on condition of Carrier Detect.  Otherwise
300writes return an error if Carrier Detect is low (and Carrier is not being
301ignored with the
302.Dv CLOCAL
303flag.)
304.It Cm flusho Pq Fl flusho
305Indicates output is (is not) being discarded.
306.It Cm pendin Pq Fl pendin
307Indicates input is (is not) pending after a switch from non-canonical
308to canonical mode and will be re-input when a read becomes pending
309or more input arrives.
310.El
311.Ss Control Characters:
312.Bl -tag -width Fl
313.It Ar control-character Ar string
314Set
315.Ar control-character
316to
317.Ar string .
318If string is a single character,
319the control character is set to
320that character.
321If string is the
322two character sequence "^-" or the
323string "undef" the control character
324is disabled (i.e. set to
325.Pf { Dv _POSIX_VDISABLE Ns } . )
326.Pp
327Recognized control-characters:
328.Bd -ragged -offset indent
329.Bl -column character Subscript
330.It control-
331.It character	Subscript	Description
332.It _________	_________	_______________
333.It eof Ta Tn VEOF	EOF No character
334.It eol Ta Tn VEOL	EOL No character
335.It eol2 Ta Tn VEOL2	EOL2 No character
336.It erase Ta Tn VERASE	ERASE No character
337.It werase Ta Tn VWERASE	WERASE No character
338.It intr Ta Tn VINTR	INTR No character
339.It kill Ta Tn VKILL	KILL No character
340.It quit Ta Tn VQUIT	QUIT No character
341.It susp Ta Tn VSUSP	SUSP No character
342.It start Ta Tn VSTART	START No character
343.It stop Ta Tn VSTOP	STOP No character
344.It dsusp Ta Tn VDSUSP	DSUSP No character
345.It lnext Ta Tn VLNEXT	LNEXT No character
346.It reprint Ta Tn VREPRINT	REPRINT No character
347.It status Ta Tn VSTATUS	STATUS No character
348.El
349.Ed
350.It Cm min Ar number
351.It Cm time Ar number
352Set the value of min or time to
353number.
354.Dv MIN
355and
356.Dv TIME
357are used in
358Non-Canonical mode input processing
359(-icanon).
360.El
361.Ss Combination Modes:
362.Pp
363.Bl -tag -width Fl
364.It Ar saved settings
365Set the current terminal
366characteristics to the saved settings
367produced by the
368.Fl g
369option.
370.It Cm evenp No or Cm parity
371Enable parenb and cs7; disable
372parodd.
373.It Cm oddp
374Enable parenb, cs7, and parodd.
375.It Fl parity , evenp ,  oddp
376Disable parenb, and set cs8.
377.It Cm \&nl Pq Fl \&nl
378Enable (disable) icrnl.
379In addition
380-nl unsets inlcr and igncr.
381.It Cm ek
382Reset
383.Dv ERASE
384and
385.Dv KILL
386characters
387back to system defaults.
388.It Cm sane
389Resets all modes to reasonable values for interactive terminal use.
390.It Cm tty
391Set the line discipline to the standard terminal line discipline
392.Dv TTYDISC .
393.It Cm crt Pq Fl crt
394Set (disable) all modes suitable for a CRT display device.
395.It Cm kerninfo Pq Fl kerninfo
396Enable (disable) the system generated status line associated with
397processing a
398.Dv STATUS
399character (usually set to ^T).  The status line consists of the
400system load average, the current command name, its process ID, the
401event the process is waiting on (or the status of the process), the user
402and system times, percent cpu, and current memory usage.
403.It Cm columns Ar number
404The terminal size is recorded as having
405.Ar number
406columns.
407.It Cm cols Ar number
408is an alias for
409.Cm columns.
410.It Cm rows Ar number
411The terminal size is recorded as having
412.Ar number
413rows.
414.It Cm dec
415Set modes suitable for users of Digital Equipment Corporation systems (
416.Dv ERASE ,
417.Dv KILL ,
418and
419.Dv INTR
420characters are set to ^?, ^U, and ^C;
421.Dv ixany
422is disabled, and
423.Dv crt
424is enabled.)
425.It Cm extproc Pq Fl extproc
426If set, this flag indicates that some amount of terminal processing is being
427performed by either the terminal hardware or by the remote side connected
428to a pty.
429.It Cm raw Pq Fl raw
430If set, change the modes of the terminal so that no input or output processing
431is performed. If unset, change the modes of the terminal to some reasonable
432state that performs input and output processing.  Note that since the
433terminal driver no longer has a single
434.Dv RAW
435bit, it is not possible to intuit what flags were set prior to setting
436.Cm raw .
437This means that unsetting
438.Cm raw
439may not put back all the setting that were previously in effect.
440To set the terminal into a raw state and then accurately restore it, the following
441shell code is recommended:
442.nf
443
444save_state=$(stty -g)
445stty raw
446\&...
447stty "$save_state"
448
449.fi
450.It Cm size
451The size of the terminal is printed as two numbers on a single line,
452first rows, then columns.
453.El
454.Ss Compatability Modes:
455.Pp
456These modes remain for compatability with the previous version of
457the stty command.
458.Bl -tag -width Fl
459.It Cm all
460Reports all the terminal modes as with
461.Cm stty Fl a
462except that the control characters are printed in a columnar format.
463.It Cm everything
464Same as
465.Cm all .
466.It Cm cooked
467Same as
468.Cm sane .
469.It Cm cbreak
470If set, enables
471.Cm brkint , ixon , imaxbel , opost ,
472.Cm isig , iexten ,
473and
474.Cm Fl icanon .
475If unset, same as
476.Cm sane .
477.It Cm new
478Same as
479.Cm tty .
480.It Cm old
481Same as
482.Cm tty .
483.It Cm newcrt Pq Fl newcrt
484Same as
485.Cm crt .
486.It Cm pass8
487The converse of
488.Cm parity .
489.It Cm tandem Pq Fl tandem
490Same as
491.Cm ixoff .
492.It Cm decctlq Pq Fl decctlq
493The converse of
494.Cm ixany .
495.It Cm crterase Pq Fl crterase
496Same as
497.Cm echoe .
498.It Cm crtbs Pq Fl crtbs
499Same as
500.Cm echoe .
501.It Cm crtkill Pq Fl crtkill
502Same as
503.Cm echoke .
504.It Cm ctlecho Pq Fl ctlecho
505Same as
506.Cm echoctl .
507.It Cm prterase Pq Fl prterase
508Same as
509.Cm echoprt .
510.It Cm litout Pq Fl litout
511The converse of
512.Cm opost .
513.It Cm tabs Pq Fl tabs
514The converse of
515.Cm tabs .
516.It Cm brk Ar value
517Same as the control character
518.Cm eol .
519.It Cm flush Ar value
520Same as the control character
521.Cm discard .
522.It Cm rprnt Ar value
523Same as the control character
524.Cm reprint .
525.El
526.Pp
527The
528.Nm stty
529utility exits with a value of 0 if successful, and >0 if an error occurs.
530.Sh SEE ALSO
531.Xr termios 4
532.Sh STANDARDS
533The
534.Nm stty
535function is expected to be
536.St -p1003.2
537compatible.  The flags
538.Fl e
539and
540.Fl f
541are
542extensions to the standard.
543