Julia Evans
@b0rk.jvns.ca
41K followers 320 following 6.7K posts
programming and exclamation marks blog: jvns.ca zines: wizardzines.com
Posts Media Videos Starter Packs
b0rk.jvns.ca
it's silly because "this is why it feels good to me to do those things" was right there
b0rk.jvns.ca
I use Affinity Designer right now! I used to use the Notability ipad app before that, and the Squid Android app before that
b0rk.jvns.ca
meet the terminal emulator wizardzines.com/comics/meet-...

(from The Secret Rules of the Terminal, out now! (wizardzines.com/zines/termin...)
your terminal emulator has two main jobs

    turn your actions (typing & clicking) into bytes and send them
    receive bytes and display them visually

Illustration of a terminal emulator, with a winking cursor face, and a program, represented by a box with a smiley face. The program has a heart above it, and there are arrows going back and forth between them labelled “bytes”
a little bit of history

it’s called an “emulator” because in the 80s a “terminal” was a separate machine from the computer

Illustration of a bulky old monitor, with a keyboard attached with a spiral cord, and a wire running to a panl of buttons and displays, labelld “mainframe”. There are arrows going back and forth between them labelled “bytes”

We still use the same 80s protocol!
what are these “bytes”?

the bytes are either:

    text (like cat blah.txt)
    escape codes (for example to tell the terminal what colour to display the text in)
    control characters example Ctrl+C is the byte 3)

it’s in charge of copy and paste

your terminal emulator lets you select text and copy/paste it (usually with Ctrl+Shift+C (Linux) or Cmd+C (Mac))

(copy & paste tips on page 18!)
it manages colours and fonts!

some terminal emulators come with a big theme library of different colourschemes!

if yours doesn’t, this site has colourschemes for many terminal emulators: iterm2colorschemes.com
fun fact: how Ctrl-X gets translated to bytes

Ctrl-A => 1
Ctrl-B => 2
...
Ctrl-Z => 26

Ctrl is the only modifier key I trust in the terminal, all of the others can work differently depending on the situation
b0rk.jvns.ca
ah yeah I imported some tweets from Twitter using
@en.blueark.app and it causes more confusion than I'd like. If you click on it you can see the "original" date it was posted (in 2013)
b0rk.jvns.ca
haha i’m going to tell everyone that’s the reason
b0rk.jvns.ca
it's in there! :)
b0rk.jvns.ca
added a cheat sheet to the official Git website

(with a lot of help from other folks who work on the website)

git-scm.com/cheat-sheet
Git Cheat Sheet
git-scm.com
b0rk.jvns.ca
TERM

wizardzines.com/comics/term/

(from "The Secret Rules of the Terminal", out now! wizardzines.com/zines/termin...)
different terminal emulators use different escape codes

terminal emulator 1: if you print out ESC[2J I’ll clear the screen!

terminal emulator 2: for me it’s ESC[HESC[J!
your system has a database called “terminfo” with escape codes in it

how if plays out when you press Ctrl+L to clear the screen:

program, with a little heart over it, thinking:
ah, she wants fo clear the screen! I’ll look up how to do that in the terminfo database…

(on my machine, the database is in /usr/share/terminfo)

program: ESC[HESC[J

terminal emulator, thinking: ok, clearing the screen!
how programs know what terminal you’re using: TERM

your terminal emulator sets the TERM environment variable when it starts

fun fact: terminal emulators often say they’re “xterm-256color” even if they’re not
this can break when SSHing into an old system with a new terminal emulator

(in a VERY annoying way)

happy little stick fiture: I am using ghostty

program, with a little heart over it: NOPE never heard of it
some ways to fix TERM

    install the terminfo file for your terminal emulator on the system
    use a different terminal emulator
    just set TERM=xterm-256color, it’ll often sort of work
b0rk.jvns.ca
finally (after literally everyone else *) I got my print copy of The Secret Rules of the Terminal!

wizardzines.com/zines/termin...

(* or I hope after literally everyone else, please send us a support email if you didn't get your preordered copy yet!)
The Secret Rules of the Terminal, by Julia Evans - The cover illustration depicts three people doing arcane terminal magic in a temple with a smoking censer in the background. Each of the three people has curly brown hair and light brown skin. They are all wearing dresses, billowing cloaks, and utility belts with keyboard symbols on them. The one on the left holds a palette of paints and a brush. The one on the right has a staff with a $ symbol on it and a starfish at the top. The one in the centre has a sword and is reading from a book whose cover says “>_” and “./”, which rests on a lectern with a smiling snake wrapped around it.
b0rk.jvns.ca
meet the TTY driver

wizardzines.com/comics/meet-...

(from "The Secret Rules of the Terminal", out now!)
the TTY driver is the most obscure part of the system

You almost never need to think about it, but when I’ve wanted to do something weird (like put a terminal in a web browser) understanding the driver is SO USEFUL
when you start your terminal emulator, it asks the OS to create a “pseudoterminal pair” which is a pair of two files

terminal emulator <-> TTY <-> TTY driver <-> TTY <-> program
a “TTY” is the program’s side of the pair

programs use it to:

    communicate with the terminal emulator by reading/writing bytes
    configure the TTY driver (more on the next page!)

Run tty fo see the current TTY!
the TTY driver is why Ctrl+C does the same thing relatively consistently

program: you press Ctrl+C, I send a signal!
well, unless the program tells me it wants the raw bytes!
some things the TTY driver is in charge of

(you might think “these are unrelated” and you’d be right)

    storing the terminal window’s size
    sending a SIGHUP signal when you close your terminal
    a basic mode for entering text called “canonical mode”
    pausing the output and confusing you when you press Ctrl+S
    tracking which process is in the “foreground” and sending what you type there
b0rk.jvns.ca
oops, should be fixed now, thanks! (minus some DNS caching issues which might take a while to resolve)
b0rk.jvns.ca
I've been using White Squirrel for fulfillment for years for wizardzines.com and they're the best.
whitesquirrel.com
Due to popular demand, we are setting up a heavily discounted fulfillment service for artists outside the US that are scrambling after the recent tariff / customs policy put in place for shipments to the USA.
b0rk.jvns.ca
what was Try Git?
b0rk.jvns.ca
oh interesting do you use it? I've been using a solarized light color palette for a long time, but I remember having issues with the "official" solarized terminal color palette -- IIRC it made all of the "bright" versions of the colours different shades of gray which I didn't like
b0rk.jvns.ca
ooh this is great, I've never seen it before!
b0rk.jvns.ca
thanks, did you like learning from it?
b0rk.jvns.ca
ooh the MIT missing semester is a great idea, thanks!
b0rk.jvns.ca
when you learned Git for the first time, what resources did you use? Did you like them? Mostly looking for answers from folks who learned Git in the last 5 years or so.

Looking for resources to potentially add to the Git website
b0rk.jvns.ca
yeah canadian spelling is a mix of british and american
b0rk.jvns.ca
terminal colours

wizardzines.com/comics/colou...

(from "The Secret Rules of the Terminal", out now!)
your terminal emulator has 16 configurable colours
	normal 	bright
black 	0 	0
red 	1 	1
green 	2 	2
yellow 	3 	3
blue 	4 	4
purple 	5 	5
cyan 	6 	6
white 	7 	7
these are called “ANSI colours”

you can configure them in your terminal emulator’s settings

OR

run a script that prints escape codes to magically set up your colours https://wzrd.page/scripts
(my favourite way!)
programs can use ANSI colours by printing an escape code

echo -e "\033[34m blue text"

3 means “normal fg colour”
4 means “blue”
the default ANSI colours often have bad contrast

ls --color often displays directories in ANSI “blue” which can look like this:

[bar of illegibly dark text against a dark background, which says “can you read this?”]

ANSI “yellow” on white also often has bad contrast
“minimum contrast”

Picking ANSI colours which always have good contrast is impossible.

the only real solution is to use a terminal emulator which has a “minimum contrast” feature (like iTerm or kitty) which will fix contrast issues
usually if a program is writing to a pipe, it’ll disable colours

$ grep blah file.txt | less

grep, represented by a box with a smiley face: better turn off colours so that I don’t accidentally show someone `^[[34ntext here]
b0rk.jvns.ca
job control

wizardzines.com/comics/job-c...

(from The Secret Rules of the Terminal, which is out now!)
your shell lets you run many programs (“jobs”) in the same terminal tab

programs can either be:

    foreground
    background
    stopped (which is more like “paused”)

& runs a program in the background

for example I like to convert 100 files in parallel like this:

for i in `seq 1 100`
do
   convert $i.png $i.jpg &
done

jobs lists backgrounded & stopped jobs

$ jobs
[1] Running python blah.py &
[2] Stopped vim

use the numbers to bring them to the foreground or background (like fg %2), kill them (kill %2), or disown them
when you close a terminal tab all jobs are killed with a SIGHUP signal

you can stop this with disown or by starting the program with nohup: disown %1 (job number goes here) nohup my_program &
a trick to kill programs if Ctrl+C doesn’t work

    press Ctrl+Z to stop the program
    run kill %1 to kill it (or kill -9 %1 if you’re feeling extra murderous)

a little flowchart

Three boxes, labelled “running in foreground”, “stopped”, and “running in background”

Ctrl+Z goes from “running in foreground” to “stopped” fg goes from “stopped” to “running in foreground” fg goes from “running in background” to “running in foreground” bg goes from “stopped” to “running in background”