Email or username:

Password:

Forgot your password?
Top-level
Julia Evans

someone in the replies elsewhere pointed out that Ctrl+J = 10 in the ASCII table = LF ("line feed") = Enter (because J is the 10th letter of the alphabet)

so Ctrl+J is the same as pressing enter

which I don't have any practical use for but is kind of cool

(edit: some corrections in this reply: pgh.social/@ben/11275223526492)

183 comments
David Monniaux

@b0rk that sort of thing had some meaning when one worked on an Apple // or similar

DELETED

@b0rk This is the kind of thing I'll hear of now, and in 5 years when my enter key switch has gone bad, I'll be more distracted by figuring out what you said vs. just ripping the switch out and plugging a new one in. <3

Chris Gerhard :bt:

@b0rk it's useful if the terminal type is wrong.

Robbie Coleman :verified:

@b0rk
I remember a sysadmin at a company I worked at in 1993 used bat files to program CLIs for users. It would list options where your response would be the file name of that action's bat file, and to "secure" certain options, he would include special ASCII characters in the file name.

Ben Cox

@b0rk This isn't quite right in a few ways. LF is decimal 10, ascii 0x0a. It is 10 because it's the 10th letter of the alphabet, though. But it's not the same as pressing enter except in cooked tty modes, where the terminal driver converts the return key (^M, \r, ASCII 13 / 0x0d) to a newline (^J, LF, 10/0xa) which your program then sees as its input.

Ben Cox

@b0rk NP, sorry if that came off as "reply guy". I once spent a weekend curled up with stty.

Julia Evans

@ben not at all, appreciate it -- edited the original post to link to your comment

Danny Whitt

@b0rk Oh my! This brings memories of ‘\n’ vs. “\r\n” handling back to me, and not in a good way. stackoverflow.com/a/3821814/37

Aurélien Gâteau 🇺🇦

@b0rk Funny that the J character also looks a bit like the ↵ character :)

And the fact that `j` is VIM key to move the cursor down!

Coincidence? I think not!

Ben Cox

@b0rk Old Skool: shift = "subtract 32" / ctrl = "subtract 64" / alt = "subtract (or add!) 128"

Peter Hosey

@b0rk Also Ctrl-H is the backspace character (no matter what your backspace key enters), Ctrl-I is horizontal tab, and Ctrl-L is form feed.

That's also why Ctrl-L is so often the “clear/reset screen” command.

Jamie McCarthy

@boredzo @b0rk For those who didn’t use the paper terminals of the 1970s, “form feed” means the typewriter-style roller, and likely the tractor-feed treads, would engage, to literally roll the paper up a few inches, enough so you could read it, and maybe tear it off for easy transport. The placement of the print apparatus, including the print head or typewriter ball itself, often made it difficult to see clearly what had just been typed

terminals-wiki.org/wiki/index.

@boredzo @b0rk For those who didn’t use the paper terminals of the 1970s, “form feed” means the typewriter-style roller, and likely the tractor-feed treads, would engage, to literally roll the paper up a few inches, enough so you could read it, and maybe tear it off for easy transport. The placement of the print apparatus, including the print head or typewriter ball itself, often made it difficult to see clearly what had just been typed

Ange

@b0rk yes, direct mapping from ctrl codes to characters. Many quirks in this “table” - a lot more than the original “ASCII”.

Luke Harby

@Ange This is like a gorgeous piece of concrete poetry.

D C Ross

@Ange @b0rk
And a lot of those "control character quirks" have just become "how things are done" without anyone ever thinking about how it happened.

You can still use Control-D to exit a shell, Control-G sounds a bell and Control-H is either backspace or delete depending on what kind of computer you're using.

ednl 🇪🇺

@Ange @b0rk In there also: the Escape character Ctrl-[ which we still use in ANSI escape sequences. (Might be a fun realisation: ah yes, that's why the left square bracket is there and they're called Escape sequences.)

a spookier jr conlin

@b0rk

I've always been a bit weirded out about all of that.

For those born in the current millennium: pressing Enter is ^M "Carriage Return" because with out linotype machines, that would make sure you didn't type past the paper. Only you also needed the bar to roll, so you had ^J "Line Feed".

For a while systems would send ^M^J when you pressed the enter key, and some still do (Windows). Others just shortened down to ^J with the ^M implied.

^K, ^L, & ^Y are their own stories too.

zgrep

@b0rk Not the same combination, but I've used ^[ as escape when I couldn't quickly or easily find a way to press the key itself. You may have already come across it, but such control character combinations feel slightly more reasonable to me when looking at a 4-column ASCII table showing all of them: garbagecollected.org/2017/01/3

[Edit: Ooh, this view of the table (from elsewhere in the tree of replies) looks interesting as well: mastodon.social/@Ange/11275225]

@b0rk Not the same combination, but I've used ^[ as escape when I couldn't quickly or easily find a way to press the key itself. You may have already come across it, but such control character combinations feel slightly more reasonable to me when looking at a 4-column ASCII table showing all of them: garbagecollected.org/2017/01/3

hyperpape

@b0rk You use ctrl-j in some contexts in Emacs for what I think is roughly that reason? I think it’s things like regex find/replace where you can’t hit enter or you’ll execute the command prematurely? My memory is a bit fuzzy.

Norman Wilson

@b0rk The important corrolary: control-m is carriage return. Once in a while I encounter a situation in which hitting enter sends LF, but I'm talking to something (usually a tiny-brain embedded device) that expects CR and only CR to end an input line.

Todd Campbell

@b0rk one practical use for it is if your terminal becomes wonky. For example, characters not echoing and enter key not actually working. I've seen this when interrupting an ssh connection before being fully established. You can type 'stty sane' followed by a Ctrl+J and get it back. I do this at least four to five times a year.

Brian Campbell

@b0rk I recall that back in the day, when termcap databases were less complete or had worse defaults, there were some systems that I used to telnet/rsh/ssh into (I forget exactly what era this was) where I couldn't use the backspace key but could use Ctrl-H to backspace. Kind of a fuzzy memory, so I may be getting the exact details incorrect, but these kind random things occasionally do come in handy.

cate

@b0rk it is just how it was designed. control plus keys of ascii lines 4x and 5x gives characters in lines 0 and 1 (block C0).And esc will gives lines 8 and 9 so block C1. But now we uses the “7 bits alias” so esc as control [. Much history but less ideal in modern world. usefulness to know c-j? imho just on binary/hex dumps

Julia Evans

also someone elsewhere left a comment like "I CAN’T BELIEVE IT TOOK HER 15 YEARS TO LEARN BASIC READLINE COMMANDS". those comments are very silly and I'm going to keep writing “it took me 15 years to learn this basic thing" forever because I think it's important for people to know that it's normal to take a long time to learn “basic" things

Feoh

@b0rk This is absolutely positively a true statement.

Peter Hosey

@b0rk Anyone who isn't still learning things 15 or more years into their career—even “basic” things (these are not basic)—is so deep in a rut that they can no longer see out of it.

James Cuff

@b0rk 💯 normal and appreciated, I knew you were going to knock that whole terminal piece out of the park. Well played!

emily dogmom

@b0rk wow! people love to make people feel bad on purpose! thanks for doing what you do to normalize actually needing to learn :)

Sashin

@b0rk I feel like it's unlikely that anyone was trying, struggling for fifteen years to learn them. It's more like they never got around to it. And very likely didn't need that specific piece of knowledge for their day to day.

njvack

@b0rk haha yeah I have been doing this a lot longer than 15 years and this is the first time I have really _thought_ about how terminals work

one thing I don't get is: If ^W isn't handled by readline (or friends), what *is* doing it? How do backspace and word-backspace work?

How... does character entry work at all??

Julia Evans

@njvack honestly I didn't dig into that in the post largely because I don't understand it well either, I think it's the "unix terminal driver", but like what is that?? how does it work? it's a weak point for me and I'm hoping to understand it at some point

wfk

@b0rk @njvack I think "man termios" may be a good starting point. This documents the ioctl interface of the line discipline of the tty driver, which is what the tty utility uses to do its magic. It is mostly based on the POSIX standard, with some Linux extensions. Key point is that the driver can operate in different modes. Older commands run in cooked mode where the tty driver does very basic command line editing. Bash, pico, vim, etc use raw mode and handle everything themselves.

pelavarre

@b0rk @njvack

⌃W and ⌃U and ⌃Q and ⌃S and so on hide away deep inside: stty all

for example

$ stty -a
...
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;
...
$

macOS

% stty -a
...
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp = ^Z; time = 0; werase = ^W;
%

part of how you can test for this is to try inside of: cat -

the ⌃W and ⌃U will work there, even when Arrow Keys etc don't work there

<=

macOS lets you spell out 'stty -a' as 'stty all', but Linux doesn't

Linux lets you abbreviate 'stty -a' as 'stty --all', but macOS doesn't

'stty -a' reports the 'stty ixon' vs 'stty -ixon' toggle in a different output line apart from these mentions of ^Q ^S, but you often need to add 'stty -ixon' to make the ⌃S forward-search-history properly undo
the ^R reverse-search-history mentioned
by Bash bind -p |grep C-[rs]
or the ^R history-incremental-search-backward
by Zsh bindkey |grep '\^[RS]'

i can't remember how often Zsh needs this workaround = maybe less often than Bash

@b0rk @njvack

⌃W and ⌃U and ⌃Q and ⌃S and so on hide away deep inside: stty all

for example

$ stty -a
...
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;
...
$

macOS

% stty -a
...
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp...

pelavarre

⌃W and ⌃U are not precisely ^W and ^U, because "^" is pure Ascii and more classic, but ⌃ is the Unicode Up Arrowhead U+2303 that's part of ⌃ ⌥ ⇧ ⌘ ← ↑ → ↓ ⎋ ⏎ ⇥ ⇤

Ray Lee

@b0rk working in software requires people to be lifelong learners. Thanks for setting a good example.

dcbaok

@b0rk there are literally millions of basic things no one can learn all of them no matter how many years they have

Aral Balkan

@b0rk I’ve been coding for 40 years. I still learn new things every day. And forget other ones every day. We’re people, not books.

raphael

@b0rk yes, this! so so much this!

like, what is this fictitious world in which every aspect of every tool is learned right away? everybody looks at things from a perspective informed by where they are at that moment and what they want to do. sometimes, that puts the spotlight away from (otherwise) foundational tools. sometimes that puts one in positions where memorising 1–2 command variations without fully understanding the entire tool is good enough(tm).

and everybody has these ‘blind spots’ – i.e. things that were more front and centre for somebody else.

it’s silly to pretend otherwise.

@b0rk yes, this! so so much this!

like, what is this fictitious world in which every aspect of every tool is learned right away? everybody looks at things from a perspective informed by where they are at that moment and what they want to do. sometimes, that puts the spotlight away from (otherwise) foundational tools. sometimes that puts one in positions where memorising 1–2 command variations without fully understanding the entire tool is good enough(tm).

Kevin Boyd

@b0rk right? That sort of commentary serves no purpose. And there's always new stuff to learn.

There's probably even a better way to do my go-to readline use case, one I haven't discovered yet:

```
read -s PASS
export PASS
```

Nick Aubert

@b0rk I've been using variants of the unix command line for 25 years and I'm still stumbling into new things. Nobody knows *everything*.

klutzagon

@b0rk i too was born naked, screaming and confused. and i still ask my partner if 12 past meridiem is noon or midnight.

it always and will never not confuse me.

Paul J Stevens

@b0rk There are lots of 'basic' things I will never learn. Assuming otherwise seems presumptive at best, basically!

Shane Celis

@b0rk I just found out yesterday there are terminal extensions to get key up events in the terminal. I naively thought for the last 20 years those were already there. sw.kovidgoyal.net/kitty/keyboa

anukul

@b0rk there is something particularly juvenile about people assuming there is one particular order or traversal for how people should learn things – that if someone else doesn’t know a particular bit they are BEHIND or BELOW or BASIC.

it’s NORMAL that we all encounter the staggering diversity of technical details at different times and stages and it doesn’t mean something fundamental about your place in the hiearchy.

Gersande La Flèche

@b0rk Comments like that (which I have heard over and over and over all the way back to my baby web dev days making my first website in 2004) only end up ensuring that overly sensitive autodidacts such as myself write off programming as a viable hobby/career forever…

DELETED

@b0rk and not remember all the details from manuals and documentation. But it’s easy to be a smartass on the web writing silly comments

Sky :veryiffied:

@b0rk there is something a little funny to me about how i was (and effectively now am) going to reply to this about how while i am very seasoned with computers and running infrastructure i struggled with git for a long time and so this post resonated with me

but your pinned toot is about your zine “how git works”!!! which i think i will now have to check out

Alvaro :rstats: :python:

@b0rk you're an internet treasure Julia, thanks for doing what u do.

You're like that kid in class that when a teacher explains something complex in a horrible way raises their hand and says "actually I didn't get any of that" and prompts every other student (who don't feel confident enough to admit they didn't understand) to lower their guard and go "yeah no, please explain that again".

Publicly admitting ignorance is so powerful! Nothing that you don't know already of course :D

Ángela Stella Matutina

@b0rk

WTF? If I don't use some so-called basic thing and therefore I don't need to learn it, so what? Am I learning or working under the person who judges me for their opinion to matter at all?

Eliot Lash

@b0rk That's nonsense, *nix is a complex beast and nobody can be reasonably expected to know everything even after using it for a long time. I've been using it for 24 years and I am still learning stuff including several things from your blog post, such as reverse-i-search being available in all readline programs, and the existence of rlwrap! So thank you for that.

I don't like having to memorize lots of different keybinds so I prefer to use vi mode in bash/zsh but this isn't always possible.

dimsumthinking

@b0rk I always point these things out to my readers-

Spicy Potato

@b0rk Thank you.

I very much appreciate your content, even when it is a topic I know well. Your research is always very thorough, and you do an excellent job of explaining things in an easy to understand form.

There have been a number of times when I've found myself adjusting how I explain things to others because of that, not because I didn't know the topic well, but because I didn't know how to make it relatable to someone who doesn't.

"Basic" is relative, and that's okay.

vksxypants

@b0rk imagine being so committed to lifelong learning that after 15 years you still have the curiosity to discover new things!

Benjamin Braatz

@b0rk 💯 That comment is so 🤦‍♀️. I use a lot of things every day and do not have the time to become an expert on every single one of them, use a tiny fraction of what is possible with readline, bash, (n)vim, … That makes your approach so interesting, because you choose a topic and then do: “Well, I maybe somehow know this exists, maybe even use some of it often, but now I really want to know what's going on and maybe write a zine on it.”

Julia Evans

@HeptaSean i wrote a thread about why I only write zines about topics that I already feel confident with recently social.jvns.ca/@b0rk/112631771

Benjamin Braatz

@b0rk Oh, missed that. That makes the “maybe” a whole lot bigger. And sounds like a really good approach.

Peter Bindels

@b0rk I only know ctrl-K and regular navigation with home/end/arrow keys, and searching with ctrl-R.

The rest of it may come later. Or not.

CEASEFIRE NOW 🇧🇫

@b0rk I hate comments like these because clearly you've been able to do (well-documented) very cool stuff without this "basic" knowledge... so even if it's a "basic" skill, clearly it's not absolutely necessary... 🤷

john fink ok!! :goat:

@b0rk spud, you're somebody I have *for years* looked up to for technical stuff and to hear you say this means an awful lot.

Dawn

@b0rk I can't believe it can take a person 15 years to stumble across documentation of such basic functionality.
Documentation needs to get better.

Nelson Minar 🧚‍♂️

@b0rk Ive been doing Unix for 35 years now and only just learned from you about Ctrl-U and Ctrl-W in the tty driver.

Purple

@b0rk it took me almost 20 years to learn to knot my shoes properly. I learned faster to code than to lace my shoes.

Space Hobo Actual

@b0rk Here's my useful use of this information!

Let's say you have a command that might succeed quickly or fail silently and slowly. How about it's something that connects over the network, and you have an unreliable connection, so sometimes it works but most of the time it hangs.

I will hold down Ctrl with my left hand, and quickly tap out CPJ with my right, to do ^C^P^J (kill job, previous shell command, enter) to restart it. It's like a magic word that resets these little command-line programs to the start!

Space Hobo Actual

@b0rk It's rather amusing to me that @dmarti boosted this, as I once told him this in person while at an event about 20 years ago where Cory Doctorow was speaking. I had a really hard time explaining the finger-choreography in a way that sold the speed this gave you, and he kept lifting his left finger off Ctrl.

It's important not to move your left hand for this trick!

$8Troll

@b0rk

CTRL-J in Chrome leads to the downloads page.

As in: the Masto post dialog box is haunted by Chrome. Ughhh

zellyn

@b0rk In emacs, you tend to use `ctrl-J` for newlines a lot… like to search for or replace with newlines. Also `ctlr-Q ctlr-J` (insert literal ("quote"), newline) is a good way to force-insert a newline without the various indentation/reformatting/alignment/etc. modes trying to be "helpful".

tschenkel

@b0rk

I use a bash extension, which allows multiline commands (scripts) in editable form. And since Enter only goes to the next line in that mode, you need Ctrl-J to execute.

Now I know why.

Tom

@b0rk I actually really enjoy this fact because when I'm coding in Emacs pressing Ctrl+j is easier to reach for than Enter. And on standard keyboards Ctrl+i is easier than Tab :)

Alpha Chen

@b0rk I remember running into this when looking into why zellij wouldn’t work when binding Ctrl+J! It was kind of annoying to dig through all the layers of abstraction between the app and the libraries doing TTY things.

mirabilos

@b0rk depends, sometimes ^M is the same as pressing Enter instead

Martin Seeger

@b0rk Ctrl-M + Ctrl-J for a MS-Dos end if line 😏

Kee Hinckley

@b0rk Given keyboard makers’ fondness of hiding the ESC key, it’s sometimes useful (especially for vi users) to know that ^[ is also ESC.

Roland Crosby

@b0rk that reminds me, I found the first few parts of this tutorial really helpful for understanding what an interactive terminal program has to do to correctly handle input and output, and what input such programs observe when you interact with the terminal: viewsourcecode.org/snaptoken/k

R.I.Pienaar

@b0rk same reason ^d exits your shell - it’s EOF :) saves a bunch of time if you are a heavy tmux user

Anders Roos

@b0rk I don't know how you are supposed to get to know all the features of a tools you use. Are you expected to read the full man pages end to end for a shell? They are one hundred pages or more. It is much more normal to come across a feature whe you search for a solution to a specific problem or watch someone else do something. So easy to miss something really useful for a long time.

Joshua T Corbin

@b0rk so this sort of pattern goes even further: Ctrl+J and such are classic 7-bit C0 control codes ; but there's also an a whole other set of 8-bit C1 control codes ; problem is that you need to somehow quote the C1 controls when writing them in 7-bit form ; this is why we write `ESC [` for the CSI ( control sequence initiator ) -- since it's the same position as the "[" character inside the 5-bit-wide C1 block

Go Up