Today I learned about TTYs and PTYs and the command tty
and stty
.
tty
outputs the tty/pty the shell is running on. while stty
sets tty/sty options and params. Those include AURT related configs, line discipline configs, and TTY driver’s configs.
# display all configs
stty -a
The output will be something like the following:
# tty general settings
speed 38400 baud; rows 59; columns 224; line = 0;
# special characters
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
# switches (-) for off.
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
Here are examples of setting up some configs.
# change height of a tty
stty -F <tty> rows <number>
# change width of a tty
stty -F <tty> columns <number>
# Change baud rate (ignored for pty)
stty -F <tty> speed <speed-in-baud>
# Change intr char from ^C to "o"
stty -F <tty> intr o
# Toggle the canonical(line based) mode
stty -icanon