xref: /openbsd/bin/stty/stty.1 (revision 404b540a)
1.\"	$OpenBSD: stty.1,v 1.36 2009/02/08 17:15:09 jmc Exp $
2.\"	$NetBSD: stty.1,v 1.10 1995/09/07 06:57:14 jtc Exp $
3.\"
4.\" Copyright (c) 1990, 1993, 1994
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" the Institute of Electrical and Electronics Engineers, Inc.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)stty.1	8.5 (Berkeley) 6/1/94
35.\"
36.Dd $Mdocdate: February 8 2009 $
37.Dt STTY 1
38.Os
39.Sh NAME
40.Nm stty
41.Nd set the options for a terminal device interface
42.Sh SYNOPSIS
43.Nm stty
44.Op Fl a | Fl e | Fl g
45.Op Fl f Ar file
46.Op Ar operands
47.Sh DESCRIPTION
48The
49.Nm
50utility sets or reports on terminal
51characteristics for the device that is its standard input.
52If no options or operands are specified, it reports the settings of a subset
53of characteristics as well as additional ones if they differ from their
54default values.
55Otherwise it modifies
56the terminal state according to the specified arguments.
57Some combinations of arguments are mutually
58exclusive on some terminal types.
59.Pp
60The options are as follows:
61.Bl -tag -width Ds
62.It Fl a
63Display all the current settings for the terminal to standard output
64as per
65.St -p1003.2 .
66.It Fl e
67Display all the current settings for the terminal to standard output
68in the traditional
69.Tn BSD
70.Dq all
71and
72.Dq everything
73formats.
74.It Fl f Ar file
75Open and use the terminal named by
76.Ar file
77rather than using standard input.
78The file is opened using the
79.Dv O_NONBLOCK
80flag of
81.Xr open 2 ,
82making it possible to
83set or display settings on a terminal that might otherwise
84block on the open.
85.It Fl g
86Display all the current settings for the terminal to standard output
87in a form that may be used as an argument to a subsequent invocation of
88.Nm
89to restore the current terminal state as per
90.St -p1003.2 .
91.El
92.Pp
93The following arguments are available to set the terminal
94characteristics:
95.Ss Control modes
96Control mode flags affect hardware characteristics associated with the
97terminal.
98This corresponds to the
99.Li c_cflag
100in the termios structure.
101.Bl -tag -width Fl
102.It Cm parenb Pq Fl parenb
103Enable (disable) parity generation
104and detection.
105.It Cm parodd Pq Fl parodd
106Select odd (even) parity.
107.It Cm cs5 cs6 cs7 cs8
108Select character size, if possible.
109.It Ar number
110Set terminal baud rate to the
111number given, if possible.
112If the
113baud rate is set to zero, modem
114control is no longer
115asserted.
116.It Cm ispeed Ar number
117Set terminal input baud rate to the
118number given, if possible.
119If the
120input baud rate is set to zero, the
121input baud rate is set to the
122value of the output baud
123rate.
124.It Cm ospeed Ar number
125Set terminal output baud rate to
126the number given, if possible.
127If
128the output baud rate is set to
129zero, modem control is
130no longer asserted.
131.It Cm speed Ar number
132This sets both
133.Cm ispeed
134and
135.Cm ospeed
136to
137.Ar number .
138.It Cm hupcl Pq Fl hupcl
139Stop asserting modem control
140(do not stop asserting modem control) on last close.
141.It Cm hup Pq Fl hup
142Same as
143.Cm hupcl
144.Pq Fl hupcl .
145.It Cm cstopb Pq Fl cstopb
146Use two (one) stop bits per character.
147.It Cm cread Pq Fl cread
148Enable (disable) the receiver.
149.It Cm clocal Pq Fl clocal
150Assume a line without (with) modem
151control.
152.It Cm crtscts Pq Fl crtscts
153Enable (disable) RTS/CTS flow control.
154.El
155.Ss Input modes
156This corresponds to the
157.Li c_iflag
158in the termios structure.
159.Bl -tag -width Fl
160.It Cm ignbrk Pq Fl ignbrk
161Ignore (do not ignore) break on
162input.
163.It Cm brkint Pq Fl brkint
164Signal (do not signal)
165.Dv INTR
166on
167break.
168.It Cm ignpar Pq Fl ignpar
169Ignore (do not ignore) parity
170errors.
171.It Cm parmrk Pq Fl parmrk
172Mark (do not mark) parity errors.
173.It Cm inpck Pq Fl inpck
174Enable (disable) input parity
175checking.
176.It Cm istrip Pq Fl istrip
177Strip (do not strip) input characters
178to seven bits.
179.It Cm inlcr Pq Fl inlcr
180Map (do not map)
181.Dv NL
182to
183.Dv CR
184on input.
185.It Cm igncr Pq Fl igncr
186Ignore (do not ignore)
187.Dv CR
188on input.
189.It Cm icrnl Pq Fl icrnl
190Map (do not map)
191.Dv CR
192to
193.Dv NL
194on input.
195.It Cm iuclc Pq Fl iuclc
196Translate (do not translate) upper case to lower case
197on input.
198.It Cm ixon Pq Fl ixon
199Enable (disable)
200.Dv START/STOP
201output
202control.
203Output from the system is
204stopped when the system receives
205.Dv STOP
206and started when the system
207receives
208.Dv START ,
209or if
210.Cm ixany
211is set, any character restarts output.
212.It Cm ixoff Pq Fl ixoff
213Request that the system send (not
214send)
215.Dv START/STOP
216characters when
217the input queue is nearly
218empty/full.
219.It Cm ixany Pq Fl ixany
220Allow any character (allow only
221.Dv START )
222to restart output.
223.It Cm imaxbel Pq Fl imaxbel
224The system imposes a limit of
225.Dv MAX_INPUT
226(currently 255) characters in the input queue.
227If
228.Cm imaxbel
229is set and the input queue limit has been reached,
230subsequent input causes the system to send an ASCII BEL
231character to the output queue (the terminal beeps at you).
232Otherwise, if
233.Cm imaxbel
234is unset and the input queue is full, the next input character causes
235the entire input and output queues to be discarded.
236.El
237.Ss Output modes
238This corresponds to the
239.Li c_oflag
240of the termios structure.
241.Bl -tag -width Fl
242.It Cm opost Pq Fl opost
243Post-process output (do not
244post-process output; ignore all other
245output modes).
246.It Cm onlcr Pq Fl onlcr
247Map (do not map)
248.Dv NL
249to
250.Dv CR-NL
251on output.
252.It Cm ocrnl Pq Fl ocrnl
253Translate (do not translate) carriage return to newline on output.
254.It Cm onocr Pq Fl onocr
255Carriage return is output (is not output) at column 0.
256.It Cm onlret Pq Fl onlret
257Newline performs (does not perform) carriage return on output.
258.It Cm olcuc Pq Fl olcuc
259Translate (do not translate) lower case to upper case on output.
260.It Cm oxtabs Pq Fl oxtabs
261Expand (do not expand) tabs to spaces on output.
262.It Cm onoeot Pq Fl onoeot
263Discard (do not discard) EOFs on output.
264.El
265.Ss Local modes
266Local mode flags (lflags) affect various and sundry characteristics of terminal
267processing.
268Historically the term "local" pertained to new job control features
269implemented by Jim Kulp on a
270.Tn Pdp 11/70
271at
272.Tn IIASA .
273Later the driver ran on the first
274.Tn VAX
275at Evans Hall, UC Berkeley, where the job control details
276were greatly modified but the structure definitions and names
277remained essentially unchanged.
278The second interpretation of the
279.Sq l
280in lflag is
281.Dq line discipline flag
282which corresponds to the
283.Li c_lflag
284of the termios structure.
285.Bl -tag -width Fl
286.It Cm isig Pq Fl isig
287Enable (disable) the checking of
288characters against the special control
289characters
290.Dv INTR , QUIT ,
291and
292.Dv SUSP .
293.It Cm icanon Pq Fl icanon
294Enable (disable) canonical input
295.Pf ( Dv ERASE
296and
297.Dv KILL
298processing).
299.It Cm iexten Pq Fl iexten
300Enable (disable) any implementation
301defined special control characters
302not currently controlled by
303.Cm icanon ,
304.Cm isig ,
305or
306.Cm ixon .
307.It Cm echo Pq Fl echo
308Echo back (do not echo back) every
309character typed.
310.It Cm echoe Pq Fl echoe
311The
312.Dv ERASE
313character shall (shall
314not) visually erase the last character
315in the current line from the
316display, if possible.
317.It Cm echok Pq Fl echok
318Echo (do not echo)
319.Dv NL
320after
321.Dv KILL
322character.
323.It Cm echoke Pq Fl echoke
324The
325.Dv KILL
326character shall (shall
327not) visually erase the
328current line from the
329display, if possible.
330.It Cm echonl Pq Fl echonl
331Echo (do not echo)
332.Dv NL ,
333even if echo
334is disabled.
335.It Cm echoctl Pq Fl echoctl
336If
337.Cm echoctl
338is set, echo control characters as
339.Ql ^X .
340Otherwise control characters echo as themselves.
341.It Cm echoprt Pq Fl echoprt
342For printing terminals.
343If set, echo erased characters backwards within
344.Ql \e
345and
346.Ql / .
347Otherwise, disable this feature.
348.It Cm noflsh Pq Fl noflsh
349Disable (enable) flush after
350.Dv INTR , QUIT , SUSP .
351.It Cm tostop Pq Fl tostop
352Send (do not send)
353.Dv SIGTTOU
354for background output.
355This causes background jobs to stop if they attempt
356terminal output.
357.It Cm altwerase Pq Fl altwerase
358Use (do not use) an alternate word erase algorithm when processing
359.Dv WERASE
360characters.
361This alternate algorithm considers sequences of
362alphanumeric/underscores as words.
363It also skips the first preceding character in its classification
364(as a convenience since the one preceding character could have been
365erased with simply an
366.Dv ERASE
367character).
368.It Cm mdmbuf Pq Fl mdmbuf
369If set, flow control output based on condition of Carrier Detect.
370Otherwise
371writes return an error if Carrier Detect is low (and Carrier is not being
372ignored with the
373.Dv CLOCAL
374flag).
375.It Cm flusho Pq Fl flusho
376Indicates output is (is not) being discarded.
377.It Cm pendin Pq Fl pendin
378Indicates input is (is not) pending after a switch from non-canonical
379to canonical mode and will be re-input when a read becomes pending
380or more input arrives.
381.It Cm xcase Pq Fl xcase
382Upper and lower case is (is not) handled canonically on input and output
383with
384.Cm iuclc
385and
386.Cm olcuc .
387.El
388.Ss Control characters
389.Bl -tag -width Fl
390.It Ar control-character Ar string
391Set
392.Ar control-character
393to
394.Ar string .
395If string is a single character,
396the control character is set to
397that character.
398If string is the
399two character sequence
400.Ql ^-
401or the string
402.Dq undef
403the control character
404is disabled (i.e., set to
405.Pf { Dv _POSIX_VDISABLE Ns } ) .
406.Pp
407Recognized control-characters:
408.Bd -ragged -offset indent
409.Bl -column character Subscript
410.It control-
411.It character	Subscript	Description
412.It _________	_________	_______________
413.It eof Ta Dv VEOF	EOF No character
414.It eol Ta Dv VEOL	EOL No character
415.It eol2 Ta Dv VEOL2	EOL2 No character
416.It erase Ta Dv VERASE	ERASE No character
417.It werase Ta Dv VWERASE	WERASE No character
418.It intr Ta Dv VINTR	INTR No character
419.It kill Ta Dv VKILL	KILL No character
420.It quit Ta Dv VQUIT	QUIT No character
421.It susp Ta Dv VSUSP	SUSP No character
422.It start Ta Dv VSTART	START No character
423.It stop Ta Dv VSTOP	STOP No character
424.It dsusp Ta Dv VDSUSP	DSUSP No character
425.It lnext Ta Dv VLNEXT	LNEXT No character
426.It reprint Ta Dv VREPRINT	REPRINT No character
427.It status Ta Dv VSTATUS	STATUS No character
428.El
429.Ed
430.It Cm min Ar number
431.It Cm time Ar number
432Set the value of min or time to
433number.
434.Dv MIN
435and
436.Dv TIME
437are used in
438non-canonical mode input processing
439(-icanon).
440.El
441.Ss Combination modes
442.Bl -tag -width Fl
443.It Ar saved settings
444Set the current terminal
445characteristics to the saved settings
446produced by the
447.Fl g
448option.
449.It Cm evenp No or Cm parity
450Enable parenb and cs7; disable
451parodd.
452.It Cm oddp
453Enable
454.Cm parenb ,
455.Cm cs7 ,
456and
457.Cm parodd .
458.It Fl parity , evenp , oddp
459Disable
460.Cm parenb
461and set
462.Cm cs8 .
463.It Cm \&nl Pq Fl \&nl
464Enable (disable)
465.Cm icrnl .
466In addition,
467.Fl \&nl
468unsets
469.Cm inlcr
470and
471.Cm igncr .
472.It Cm ek
473Reset
474.Dv ERASE
475and
476.Dv KILL
477characters
478back to system defaults.
479.It Cm sane
480Resets all modes to reasonable values for interactive terminal use.
481.It Cm tty
482Set the line discipline to the standard terminal line discipline
483.Dv TTYDISC .
484.It Cm crt Pq Fl crt
485Set (disable) all modes suitable for a CRT display device.
486.It Cm kerninfo Pq Fl kerninfo
487Enable (disable) the system generated status line associated with
488processing a
489.Dv STATUS
490character (usually set to
491.Ql ^T ) .
492The status line consists of the
493system load average, the current command name, its process ID, the
494event the process is waiting on (or the status of the process), the user
495and system times, percent CPU, and current memory usage.
496.It Cm columns Ar number
497The terminal size is recorded as having
498.Ar number
499columns.
500.It Cm cols Ar number
501This is an alias for
502.Cm columns .
503.It Cm rows Ar number
504The terminal size is recorded as having
505.Ar number
506rows.
507.It Cm dec
508Set modes suitable for users of Digital Equipment Corporation systems
509.Pf ( Dv ERASE ,
510.Dv KILL ,
511and
512.Dv INTR
513characters are set to ^?, ^U, and ^C;
514.Dv ixany
515is disabled, and
516.Dv crt
517is enabled).
518.It Cm extproc Pq Fl extproc
519If set, this flag indicates that some amount of terminal processing is being
520performed by either the terminal hardware or by the remote side connected
521to a pty.
522.It Cm raw Pq Fl raw
523If set, change the modes of the terminal so that no input or output processing
524is performed.
525If unset, change the modes of the terminal to some reasonable
526state that performs input and output processing.
527Note that since the terminal driver no longer has a single
528.Dv RAW
529bit, it is not possible to intuit what flags were set prior to setting
530.Cm raw .
531This means that unsetting
532.Cm raw
533may not put back all the setting that were previously in effect.
534To set the terminal into a raw state and then accurately restore it,
535the following shell code is recommended:
536.Bd -literal -offset indent
537save_state=$(stty -g)
538stty raw
539\&...
540stty "$save_state"
541.Ed
542.It Cm size
543The size of the terminal is printed as two numbers on a single line,
544first rows, then columns.
545.El
546.Ss Compatibility modes
547These modes remain for compatibility with the previous version of
548the stty command.
549.Bl -tag -width Fl
550.It Cm all
551Reports all the terminal modes as with
552.Cm stty Fl a
553except that the control characters are printed in a columnar format.
554.It Cm everything
555Same as
556.Cm all .
557.It Cm cooked
558Same as
559.Cm sane .
560.It Cm cbreak
561If set, enables
562.Cm brkint , ixon , imaxbel , opost ,
563.Cm isig , iexten ,
564and
565.Fl icanon .
566If unset, same as
567.Cm sane .
568.It Cm new
569Same as
570.Cm tty .
571.It Cm old
572Same as
573.Cm tty .
574.It Cm newcrt Pq Fl newcrt
575Same as
576.Cm crt .
577.It Cm pass8
578The converse of
579.Cm parity .
580.It Cm tandem Pq Fl tandem
581Same as
582.Cm ixoff .
583.It Cm decctlq Pq Fl decctlq
584The converse of
585.Cm ixany .
586.It Cm crterase Pq Fl crterase
587Same as
588.Cm echoe .
589.It Cm crtbs Pq Fl crtbs
590Same as
591.Cm echoe .
592.It Cm crtkill Pq Fl crtkill
593Same as
594.Cm echoke .
595.It Cm ctlecho Pq Fl ctlecho
596Same as
597.Cm echoctl .
598.It Cm prterase Pq Fl prterase
599Same as
600.Cm echoprt .
601.It Cm lcase Pq Fl lcase
602Same as
603.Cm iuclc ,
604.Cm olcuc
605and
606.Cm xcase .
607.It Cm litout Pq Fl litout
608The converse of
609.Cm opost .
610.It Cm tabs Pq Fl tabs
611The converse of
612.Cm oxtabs .
613.It Cm brk Ar value
614Same as the control character
615.Cm eol .
616.It Cm flush Ar value
617Same as the control character
618.Cm discard .
619.It Cm rprnt Ar value
620Same as the control character
621.Cm reprint .
622.El
623.Ss Control operations
624These operations are not modes, but rather commands to be performed by
625the tty layer.
626.Bl -tag -width Fl
627.It Cm ostart
628Performs a
629.Dq start output
630operation, as normally done by an
631incoming
632.Dv START
633character when
634.Cm ixon
635is set.
636.It Cm ostop
637Performs a
638.Dq stop output
639operation, as normally done by an incoming
640.Dv STOP
641character when
642.Cm ixon
643is set.
644.El
645.Pp
646.Ex -std stty
647.Sh SEE ALSO
648.Xr termios 4 ,
649.Xr tty 4
650.Sh STANDARDS
651The
652.Nm
653utility is compliant with the
654.St -p1003.1-2008
655specification.
656.Pp
657The flags
658.Op Fl ef
659and the operands
660.Cm speed ,
661.Cm crtscts ,
662.Cm iuclc ,
663.Cm imaxlabel ,
664.Cm onlcr ,
665.Cm olcuc ,
666.Cm oxtabs ,
667.Cm onoeot ,
668.Cm echoke ,
669.Cm altwerase ,
670.Cm mdmbuf ,
671.Cm flusho ,
672.Cm pendin ,
673.Cm xcase ,
674.Cm tty ,
675.Cm crt ,
676.Cm kerninfo ,
677.Cm columns ,
678.Cm cols ,
679.Cm rows ,
680.Cm dec ,
681.Cm extproc ,
682.Cm raw ,
683.Cm size ,
684the compatibility modes and the control operations
685are extensions to that specification.
686.Sh HISTORY
687A
688.Nm
689command appeared in
690.At v3 .
691