nrw.social ist einer von vielen unabhängigen Mastodon-Servern, mit dem du dich im Fediverse beteiligen kannst.
Wir sind eine freundliche Mastodon Instanz aus Nordrhein-Westfalen. Ob NRW'ler oder NRW-Sympathifanten, jeder ist hier willkommen.

Serverstatistik:

2,9 Tsd.
aktive Profile

🚀 LAUNCHING A THING TODAY 🚀

My friend @ellane and I are pleased to launch a new mini-course:

🧑‍💻 Ellane learns the command line 🧑‍💻

She mentioned this to me a while ago, so we're going to do it live on Mastodon. Here, in this thread. We're thinking of it like a correspondence course.

You can't fit that much in a post, and formatting here isn't great, so the full posts will be on our mini blog at:

commandline.johnnydecimal.com.

We'd love you to follow along.

commandline.johnnydecimal.comEllane learns the command lineEllane and Johnny have a conversation about the command line.

01. Introduction & goals

On Mastodon, @ellane mentioned that she'd like to 'learn the command line'. What she told Johnny was that she wants to:

- understand what the command line IS
- learn how not to stuff up your machine
- learn what language it speaks
- understand what commands DO, where things go
- what's Homebrew, and why use it and what does it do, and how does it do it?

#LearnCLI

commandline.johnnydecimal.com/

commandline.johnnydecimal.comIntroduction & goalsWhat's this, and why are we here?

02. What is the command line?

A very high-level introduction to the command line. What even is it? Why would we use it?

You can click a button because some designer in Seattle designed the program to have a button.

But what if you want more granular control? What if there isn't a button for the thing you want to do?

Then you crack open the command line.

Over to you, @ellane.

#LearnCLI

commandline.johnnydecimal.com/

commandline.johnnydecimal.comWhat is the command line?A very high-level introduction to the command line. What even is it? Why would we use it?

@johnnydecimal Thanks, Johnny, this is outrageously exciting to my aspiring-geeky heart!

So I've done my assignment re- layers of abstraction. Makes perfect sense.

Just like my car's ignition button, I'm aware there's an organised, predictable series of events that take place once the button is pushed. Each event relies on those that came before it (pistons, oil, petrol, etc), but I don't have to think of any of that when I'm buckling up.

Computers be no different!

04. Let me show you around your new car

@ellane Oh good analogy! That's going to be helpful.

Learning 'the command line' is like learning how to drive. But before we can drive, we need a vehicle.

Let me show you around your new car.

#LearnCLI

commandline.johnnydecimal.com/

commandline.johnnydecimal.comLet me show you around your new carComputers are like cars. Let's head to the showroom and pick you a nice model.

@johnnydecimal

Homework assignment part 1: Figure out how to make it so that when you type `logout`, the window closes.

I poked around in Settings, and found an option under Shell called `When the shell exits`. The default behaviour was `Don’t close the window`, which was just the clue I needed! As I’d hoped, `Close the window` was also an option in the drop down list.

#LearnCLI (1/3)🧵

@johnnydecimal
Homework assignment part 2: Why doesn’t Johnny like closing the window with the red button?

I couldn’t find a clear answer to this, so here’s my best guess: Using the red button might run the risk of closing the window before a process has completed successfully, leading to problems. Is it like leaving the car in a gear other than Park before turning it off? (2/3)🧵

06. The structure of a command @ellane

Commands are all structured in the same way. They all follow one of a few patterns. When you learn those patterns, you learn the syntax of _all commands_.

We know that `pie lunch cook` isn't a valid sentence, even if we're not a chef.

And soon you'll immediately recognise that `--food pie &meal lunch cook` couldn't ever be a valid command: it just doesn't _look_ right.

#LearnCLI

commandline.johnnydecimal.com/

commandline.johnnydecimal.comThe structure of a commandOur first look at the fundamental structure of a command.

@johnnydecimal Okay, this feels like progress! I cd'd myself to the Documents folder on the first go, by typing in `cd Documents`, and used `ls` to see the list of items in that folder. Did the same with the Downloads folder, and was reminded (again) that I really need to clear that one out. I tried a number of things to `cd` to a specific nested folder, with no luck.

One of my attempts had an alarming result:

#LearnCLI (1/2) 🧵

@johnnydecimal When I could see the folder I wanted to `ls` in the `ls` of its parent folder, I typed `view [name of folder]`.
I should have known better than to experiment with unknown commands!

That gave me a blank page with a `1` at the top, and the word `Insert` at the bottom. Logout didn't work, so I committed the press-the-red-dot-to-close-the-window sin. No more jumping ahead of the teacher for me! (2/2) 🧵

08. File paths @ellane

File paths are core to this whole experience: many things you do involve a file, or being in a specific folder before you take an action. So let's go a bit deeper.

This lesson introduces ~, ., .., and /. Tiny symbols but they mean so much!

We also talk about relative vs. absolute file paths.

#LearnCLI

commandline.johnnydecimal.com/

commandline.johnnydecimal.comFile pathsHow do we get around the file system if the folder we want isn't a direct subfolder of where we are?

@johnnydecimal I’ve managed to change directory to pretty much everywhere, which is cool! Got a bit carried away trying to see the contents of a folder quite deep in multiple subfolders, and got a **zsh: permission denied** message. This was puzzling until I realised I’d forgotten to preface the path with a command! (1/2)🧵

@johnnydecimal Something else I’ve noticed is that the CLI does *not* like word spaces. It returns a **too many arguments** message any time I try to access a folder with a multiple-word name. Is there any way around that, or do I have to rename_everything_to_remove_word_spaces?
Rather than renaming anything, I looked for paths with locations that were one word only and was able to `ls` the contents of the parent folder of the directory I was looking at. So far so good! (2/2)🧵

10. Escape arguments, completely.

By trying to `cd` to a folder with a space in it, you've accidentally given that command two arguments.

So let's talk about **arguments** and what they are. Then I'll show you two ways to get round this problem without renaming_every_folder:

1. Escaping with `\`.
2. Tab autocompletion.

The first is something you need to know. The second is something you'll actually use!

#LearnCLI @ellane

commandline.johnnydecimal.com/

commandline.johnnydecimal.comEscape arguments, completelyThe CLI doesn't handle spaces in file names very well. We use 'escaping' to work around it.

@johnnydecimal Escape Arguments Homework:

I successfully `cd`d to “A_folder_in_quotes” by typing `cd \”A` and then pressing <tab>

Then I navigated to a folder with word spaces inside my Obsidian vault, which is nestled four folders deep (don’t judge), and pressed <tab> to auto complete its name, which is ALL THE NOTES. Terminal completed the string like this: `cd ALL\ THE\ NOTES`. (1/4)🧵

@johnnydecimal It’s good to learn the why behind things that look different to my GUI-trained eyes.

I used to view things like slashes that went the wrong way and underscores between words as tech-virtue signalling: We’re More Technical and Clever Than You So We Wrap Things In Extra Bits Because We Can. Seems silly now! (4/4)🧵

12. Case-sensitivity, ttys, and the prompt.

There’s a bit of feedback here, so I’ve made one post addressing these questions. And in the next post we’ll continue with the concepts.

Case-sensitivity: is your macOS case-sensitive? (A: kinda.)

ttys000: what is it? (A: 1800s technology.)

% vs. $: why? (A: style. 🕺🏽)

@ellane #LearnCLI

commandline.johnnydecimal.com/

commandline.johnnydecimal.comCase-sensitivity, ttys, and the promptTwo follow-up questions.

13. Flags and options.

We almost understand the syntax of a command. To recap, we've met the command, and its (often optional) arguments.

Now let's meet flags and options, which are two sides of the same coin. They modify the _behaviour_ of a command.

@ellane #LearnCLI

commandline.johnnydecimal.com/

commandline.johnnydecimal.comFlags and optionsThe final piece of the command puzzle, we introduce 'flags' and 'options'.

@johnnydecimal Interesting podcast excerpt, thanks. It’s good to know about Macs having a different approach to case than other systems. Seems to me if we’re going to err, it should be on the side of precision—so I’ll play it safe by treating everything as case sensitive from now on.

Thanks for explaining the `ttys000`. I figured it wasn’t something I *needed* to know, but having that confirmed saves me from the distraction of wondering what it is every time I see it. (1/3)🧵

@johnnydecimal As with the colour, we’ll either get to that later or it’ll turn out to be something else I don’t need to worry about.

Referring to the `ls` information at ss64.com/mac/ls.html, I tried `ls-F` as a shorter way of writing `ls -F`, but it returned an error: `zsh: command not found: ls-F`.

Okay. Commands, flags and options, arguments, in that order. Got it. (3/3)🧵

ss64.comls man page Man Page - macOS - SS64.com
Constantin (he/him) :nonazis:

@ellane @johnnydecimal Hi both, just wanted to say thank you for this open and transparent communication about this learning experience!

I work in IT for some time and its not only a great reminder on how things work but also how many things are logical and others are ambiguous and sometimes confusing. 🙏😌

@ConLuegering I'm delighted you're finding some value in it, all your experience notwithstanding! @johnnydecimal