Exploring the Terminal

Micah Cowan <micah@cowan.name>

All resources and materials used for this presentation at micah.cowan.name/projects/term-talk/

About this Talk

Brief Intro to Terminal Multiplexers

Terminal Multiplexing with Ssh

Multiplexer Choices: screen or tmux

Multiplexer Choices: screen or tmux (cont’d)

A demo of terminal features

[ demos/ansi/all.sh ]

(links to these on final slide)

Terminal problem situations
you can find yourself in

Fixing those terminal problems

(15 mins?)

Sending terminal controls with tput

[ demos/sgr/cmd.sh ]

[ demos/interact/cmd.sh ]

[ PLAY AROUND: demos/interact/tmux.sh ]
NOTE: The above demo requires tmux to work.

A Look at the ASCII Table

  0 1 2 3 4 5 6 7
0 NUL DLE   0 @ P ` p
1 SOH start ! 1 A Q a q
2 STX DC2 " 2 B R b r
3 intr stop # 3 C S c s
4 eof DC4 $ 4 D T d t
5 ENQ kill % 5 E U e u
6 ACK SYN & 6 F V f v
7 BEL werase ' 7 G W g w
8 BS CAN ( 8 H X h x
9 HT EM ) 9 I Y i y
A LF susp * : J Z j z
B VT ESC + ; K [ k {
C FF quit , < L \ l |
D CR GS - = M ] m }
E SO RS . > N ^ n ~
F SI US / ? O _ o DEL
  • In terms, unlike X or Aqua, control shifts blue region chars to green region
  • Control representations: ^A versus C-a
  • There are only 33 control characters (including DEL)
  • You can't just use all of them (You can't make C-i, C-m, or C-j do special things in Emacs)
  • You (almost) never have to hold shift for controls
  • Special keys, like arrows or Page Up, can also have controls, but it works differently

Basic terminal controls

[ demos/ctrls/cmd.sh ]

30 mins?

Intro to prompt-jobs.sh

[ demos/pjobs/cmd.sh ]

Controlling kernel-layer terminal behavior with stty

[ demos/stty/cmd.sh ]

Browse the stty(1) manual for info on cr/nl stuff, and flow control xon/xoff.

stty < terminal file # to configure a different terminal than the one we're running on.

DEL/^? versus BS/^H

Carriage Return (^M) and Line Feed (New Line) (^J)

Animation of a teletype machine illustrating carriage-return and line-feed
  • From line printer days: CR returns the carriage to type at beginning of (same) line, LF feeds one line's worth of paper in the printer.
  • Often called NL (for New Line) instead of LF, on video terminals.
  • Different systems have different line-ending conventions for text files and such.

Automatic CR NL translations in the Terminal

Unix uses NL alone for line endings, but the terminal still interprets the original meanings exactly as for line printers. So how do things still work? Why does the cursor still return to the beginning of the line for NL alone?

Graphical effects using BS/^H or CR/^M

[ demos/man/cmd.sh ]

Ever wonder why ASCII has characters like back-tick (`), circumflex (^), and the tilde (~)?

Excerpt from ECMA 6 (ASCII):

An image snapshot of section 7 of the ECMA 6 (ASCII) specification

Escape Sequences

Making Interactive Demos with Script,
Teseq, and Reseq

Advanced terminfo

Mouse mode

More terminfo stuff

Software Links

ANSI Terminal Animations

Specification Links

(Freely available!)

Thank you and good night!