10 things you didn't know about the terminal
Tags: linux, devops, bash
Published: 2020-09-24 08:49:30

## 1. Why still 80 characters default

We regularly use monitors that have a gazillion of pixels available and yet, the [default terminal width is 80 characters](https://stackoverflow.com/questions/4651012/why-is-the-default-terminal-width-80-characters). Why, oh why? 

TL;DR: we owe this one to IBM and their standardized punchcards, introduced in the 1920s, sporting 80 columns:

<a title="Pete Birkinshaw from Manchester, UK / CC BY (https://creativecommons.org/licenses/by/2.0)" href="https://commons.wikimedia.org/wiki/File:Used_Punchcard_(5151286161).jpg"><img width="1024" alt="Used Punchcard (5151286161)" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Used_Punchcard_%285151286161%29.jpg/1024px-Used_Punchcard_%285151286161%29.jpg"></a>

## 2. Terminal: not the same as the shell or CLI 

Terminal. Shell. Command Line Interface (CLI). Three distinct and different things. Very much related, but they are and do different things: terminal is that window that may host a shell as well as other programs using a textual interface. CLIs are line-oriented, textual interfaces and come in all forms and shapes, for example the `aws` CLI or when you are looking for something (aka: Google search). Learn more about the differences from this [Q&A piece](https://askubuntu.com/questions/506510/what-is-the-difference-between-terminal-console-shell-and-command-line).

## 3. It's literally the end
The word terminal [comes from](https://www.etymonline.com/word/terminus?ref=etymonline_crossreference) Latin "terminus", meaning "an end, a limit, boundary line". Not too surprising: from where the mainframe sits, the people working on [computer terminals](https://en.wikipedia.org/wiki/Computer_terminal) are indeed the end of the communication line.

## 4. Not the real thing? Emulator much!
Unless you're in a museum, you're not really using a terminal these days. What you're using is a program called a [terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator), rather directly emulating a good old video or computer terminal from the 70s. Nice!

## 5. Tame the beast
Since the terminal emulator is a piece of software, one would expect to be able to [configure it](https://tldp.org/HOWTO/Text-Terminal-HOWTO-16.html) to their liking. And indeed there are a number of things you can learn from your terminal's configuration and even set some. Here's what I see when I look at mine (Alacritty on macOS; edited down to only show the beginning):

```
$ infocmp -L -1                                                                                                                                                                                                                                     
# Reconstructed via infocmp from file: /usr/share/terminfo/73/screen-256color
screen-256color|GNU Screen with 256 colors,
        auto_right_margin,
        backspaces_with_bs,
        eat_newline_glitch,
        has_hardware_tabs,
        has_meta_key,
        move_insert_mode,
        move_standout_mode,
        columns#80,
...
```

## 6. Why `vi` and YouTube use `j` and `l`?
Ever used `vi` and wondered why pressing the `j` key sends you a line down? Or, likewise, when you're watching a YouTube video and you want to fast-forward some 10 sec by hitting the `l` key?

Peter has the [answer](https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys):

> When Bill Joy created the `vi` text editor he used the `ADM-3A` terminal, which had the arrows on `hjkl` keys. Naturally he reused the same keys and the rest is history.

So, we can thank Bill Joy's terminal or more specifically its builtin keyboard layout.

## 7. One terminal is not enough!
As the title suggests and your monitor confirms: one terminal is not enough. Sure, you can launch multiple terminal windows or use tabs or whatever is kewl these days. We elderly people [use terminal multiplexer](https://superuser.com/questions/236158/tmux-vs-screen) such as `tmux` (preferred) or `screen` (if you're really, really old). 

## 8. GPU here I come
You have a GPU I'm sure and you don't know how to keep its cache lines warm? Here's a suggestion: ditch your old terminal and give one of the GPU-powered terminals a try. I've personally migrated from iTerm2 to [alacritty](https://github.com/alacritty/alacritty) and have only good things to say about it (moar YAML for config, yay) but there are also other options like [kitty](https://github.com/kovidgoyal/kitty). Might take you a day or so to move over but totally worth it, if you spend more than 50% of your time in the terminal ;)

## 9. Terminal vs. `tty`
Remember when we talked about software terminals in 4., above? I didn't really tell you the whole truth back then. Now that you're a terminal expert: meet `tty` which is short for “teletypewriter.” Learn more about [What is a TTY on Linux? (and How to Use the tty Command)](https://www.howtogeek.com/428174/what-is-a-tty-on-linux-and-how-to-use-the-tty-command/) and thank me later.

## 10. Terminal vs `stdin`, `stdout`, and `stderr` 
In the context of the shell and from programming languages you've almost certainly come across terms like `stdin` or `stdout`. Turns out those are simply per-process fixed files (with well-known file descriptors) that you're using to interact with, in the case of `stdout` … wait for it … your terminal! Read more in [Your terminal is not a terminal: An Introduction to Streams](https://lucasfcosta.com/2019/04/07/streams-introduction.html).

_With that, thanks for stopping by and I'm wondering: what's your favorite thing about the terminal that few people know? Care to share?_

---
Cover image kudos to [AT&T Archives](https://www.youtube.com/watch?v=tc4ROCJYbm0&t=881s), depicting Brian Kernighan rocking an early terminal.