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