🚀 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.
Ellane learns the command line
Ellane and Johnny have a conversation about the command line.commandline.johnnydecimal.com
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •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/…
Introduction & goals
commandline.johnnydecimal.comJohnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •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/…
What is the command line?
commandline.johnnydecimal.comEllane
in reply to Johnny ‘Decimal’ Noble • • •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!
#LearnCLI
Johnny ‘Decimal’ Noble
in reply to Ellane • • •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/…
Let me show you around your new car
commandline.johnnydecimal.comAndrew Canion :prami:
in reply to Johnny ‘Decimal’ Noble • • •Johnny ‘Decimal’ Noble
in reply to Andrew Canion :prami: • • •Claudine C
in reply to Johnny ‘Decimal’ Noble • • •Johnny ‘Decimal’ Noble
in reply to Claudine C • • •Gordon Pedersen
Unknown parent • •@Ellane W
My theory was just that it was a GUI (Graphical User Interface) element. Part of the Terminal app, but not actually part of the command line.
I didn't even think about interrupting a running process 😆
@Johnny ‘Decimal’ Noble
Ellane likes this.
Gordon Pedersen
in reply to Gordon Pedersen • •Whoops, didn't see the reply from @Jacoby Young which basically said the same thing 😅
@Ellane W
Johnny ‘Decimal’ Noble
in reply to Gordon Pedersen • • •Gordon Pedersen
in reply to Johnny ‘Decimal’ Noble • •micro.blog/xxxx/38517471
I actually had to go to Ellane's profile on pkm.social (in a browser) to see it. I only looked because she replied.
Ah, the perils of federation...
@Jacoby Young @Ellane W
like this
Johnny ‘Decimal’ Noble and Ellane like this.
Johnny ‘Decimal’ Noble
Unknown parent • • •Hmm no, this is not normal.
Here's a little video. I type out `printenv`, hit return, see the result, hit return a few times, do it again. This is what should happen.
You're saying after your first screen of results the window becomes unresponsive?
Try typing vs. pasting, though that shouldn't matter.
share.cleanshot.com/kR2SZnj9
CleanShot 2024-05-31 at 09.22.12
share.cleanshot.comJohnny ‘Decimal’ Noble
Unknown parent • • •Hmm okay let's just keep an eye on that. If it happens again, let me know.
Preparing my response as we speak! Should be there tomorrow.
Johnny ‘Decimal’ Noble
Unknown parent • • •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/…
The structure of a command
commandline.johnnydecimal.comJohnny ‘Decimal’ Noble
Unknown parent • • •I had no idea what `view` did, by the way. Had to type it to see, at which point I realised it was a synonym for `vim`.
You learn something every day…
And you did the right thing hitting the red button aka the ejector seat. 👍
Johnny ‘Decimal’ Noble
Unknown parent • • •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/…
File paths
commandline.johnnydecimal.comHyde 📷 🖋
Unknown parent • • •use quotes. If you do something like :
$ ls "My
[tab]When you press the tab, it will complete the name like :
My folder
My file
Etc ...
Gordon Pedersen
Unknown parent • •My trick is usually to type the first few letters then press the Tab key. It's a handy shortcut most of the time to fill in long file or folder names, but in my experience it also handles the escaping for you as well.
@Johnny ‘Decimal’ Noble
Ellane likes this.
Johnny ‘Decimal’ Noble
in reply to Hyde 📷 🖋 • • •@hyde @death.au No jumping ahead please!
All in good time... I have this all planned out.
Hyde 📷 🖋
in reply to Johnny ‘Decimal’ Noble • • •Johnny ‘Decimal’ Noble
in reply to Hyde 📷 🖋 • • •Hyde 📷 🖋
Unknown parent • • •Johnny ‘Decimal’ Noble
Unknown parent • • •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/…
Escape arguments, completely
commandline.johnnydecimal.comGordon Pedersen
in reply to Johnny ‘Decimal’ Noble • •🙇 Forgive me for skipping ahead, Sensei. Sumimasen.
@Ellane W
like this
Johnny ‘Decimal’ Noble and Ellane like this.
Johnny ‘Decimal’ Noble
Unknown parent • • •Look at this one more closely!
It should be `this\that` — the same backslash that you use for the escape character.
The puzzle is: how do you include the escape character in an argument _if it’s the escape character?_
Johnny ‘Decimal’ Noble
in reply to Gordon Pedersen • • •@death.au @hyde I should apologise and make it clear that I value feedback on this little endeavour.
If I’m not clear, or if I’m wrong — which will for sure happen — please call it out. Corrections will be made.
And I’m sure @ellane won’t go jumping ahead anyways.
😊
Hyde 📷 🖋
in reply to Johnny ‘Decimal’ Noble • • •No worries at all :)
And @ellane good luck with the CLI :)
Since I learnt it, I cant live without it.
Johnny ‘Decimal’ Noble
Unknown parent • • •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/…
Case-sensitivity, ttys, and the prompt
commandline.johnnydecimal.comJohnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •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/…
Flags and options
commandline.johnnydecimal.comConstantin (he/him)
Unknown parent • • •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. 🙏😌
Johnny ‘Decimal’ Noble
Unknown parent • • •15. Less is more.
Let's learn how to view plain text files. Do you have any of those handy?
Oh wait.
---
Then we'll use this same skill to explore the system's built-in 'manual pages', which are more up-to-date than the web link I sent you last time.
These pages are a treasure-trove of information. They tell you, in great detail, how to use any command.
@ellane #LearnCLI
commandline.johnnydecimal.com/…
Less is more
commandline.johnnydecimal.comHyde 📷 🖋
Unknown parent • • •jut m'y two cents, when you do :
$ cd a\ dir\ with\ spaces
you can also use double quotes:
$ cd "a dir
[tab]And it will expand it to ;
$ cd "a dir with spaces"
Constantin (he/him)
Unknown parent • • •I have a question, which is slightly off-topic:
It looks like you have been less technical person in the past? If yes: How do you look on IT and apps, now that you took the red pill and left the matrix?
Do you think that "apps should just do their magic" or that this will help you achieve more? Do you believe that programming or IT Stuff is much more different that you thought and now want to unlearn about the truth?
Im just curious on your perception. 😌
Constantin (he/him)
Unknown parent • • •Thanks for your reply, I fully agree that it will take some more time to fully identify the impact of this exercise.
Needed to ask it early on, it might sit in the back your head so you can tell me closer to the end. 😉🙏
(I started programming as a hobby again after 12 years and I see for myself how the different the world is or how rusty I have become? 😬😅
Johnny ‘Decimal’ Noble
Unknown parent • • •Lots of feedback! I've done some inline comments and I'll keep the next lesson a separate page for neatness.
commandline.johnnydecimal.com/…
#LearnCLI
Lots of feedback
commandline.johnnydecimal.comJohnny ‘Decimal’ Noble
Unknown parent • • •Not at all! This is a whole other world here.
In the years running up to 2018 I tried and stalled and tried and failed to start learning some sort of programming language. Started one, stopped. Changed my mind. Started another.
So many times.
The one thing that finally got me was a JavaScript course, sadly now gone*, by a Google engineer. You should have seen how slowly he went.
Pain. Stakingly. Slowly. Like proper baby-steps slowly.
*It was free and now it’s $300/month.
1/5
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •And that’s what I needed. That was the ah-ha moment.
Now I can do JavaScript, to an okay standard. Nowhere near many people, but good enough for what I need to do.
I still lean on the web. But because I understand the fundamentals, what I find myself needing is the pointer.
I’m in a dark room and you just need to put my hand on the switch. Then I can do the rest myself.
That’s what we’re going for here.
Fundamentals. Deep understanding.
Slowly. Until the light comes on.
2/5
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •*Also*, it’s my job as the teacher to notice and adapt, but that can be hard as we’re just doing this by text.
So if at any point you think we’re going too quickly, please say so.
If there’s a concept that needs to be reinforced, re-explained, whatever: tell me.
3/5
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •I just realised something! You have access to Learn Excel with Lucy.
Re-watch ‘Functions & Formulas’, and in pt. 2 pay close attention to the TEXTJOIN function.
_Syntactically_ it’s totally different to the CLI.
_Conceptually_ it’s **identical**.
- What’s the command?
- Does it have flags?
- Does it have options?
- Does it take arguments?
This is the thing about computers, and languages: once you internalise the _idea_, the rest is just translation.
4/5
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •So the job is to train your brain to think in this really un-human way.
You’re becoming a programmer. The CLI is just a computer to be programmed.
Excel or the CLI. It doesn’t matter.
(For anyone following along, I’ll make that lesson free in the next couple of days and edit this post with a link.)
5/5
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •Johnny ‘Decimal’ Noble
Unknown parent • • •Great. Yeah I was going to write a short summary post to reinforce what’s important to focus on and what’s not. I’ll do it here.
Important:
- The basic <command> <flags/options> <argument> idea.
- This is such a massive leap from clicking a mouse.
- We’ll do a LOT more of this over time.
- Viewing a document; getting around inside there.
Not important:
- Any of the specific flags or arguments to any particular command.
- None of the contents of the man pages! Scary nonsense.
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •Johnny ‘Decimal’ Noble
Unknown parent • • •Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •Okay, terribly late on this one, and I still haven’t written a proper post for our little site. But I figure if I just type this at the kitchen table rather than agonising over perfection, that’s probably better.
(I will update the site later.)
So we’re going to ‘pivot’, as we say in the tech industry. I set out to teach you ‘the CLI’, but that’s a _massive_ undertaking, and your actual goal is to ‘learn plain text accounting, specifically hledger’.
Rather than possibly useless…
1/x
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •…theory, therefore, we’re going to focus on the goal, and cover topics _as required_ on our way to that goal.
In your latest blog post you mentioned that you can read stuff, but you can’t yet edit. So let’s do that now.
Now, this qualifies as a ‘potentially dangerous’ command. Because if you edit the wrong file, you could mess something up! So just make sure you’re in the right place, and maybe create some test files to start.
The command 🥁 is 🥁
pico
2/x
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •That’s it. You can just type `pico` and it’ll open.
And I’m going to leave you there. Because if you look around, I think you’ll work it out. The hints are all on-screen: see the bar along the bottom.
This is a pretty rudimentary text editor. It’s not the legendary `vim`. But it’s easy to use, and it’ll do the job.
And think about this: once this is all set up, there’s no reason to use the CLI to edit your plain text files. They’re just plain text files.
3/x
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •You can use whatever you like to edit them. And just dive down to the CLI as required.
But still, I think this is a valuable exercise. So have a play with pico, create a few files, edit a few files, and let me know how you get on.
Next, we’re going to go straight for the hledger installation page. 😬
4/4
#LearnCLI
Johnny ‘Decimal’ Noble
Unknown parent • • •Okay, we have two possibilities here.
Just like with any other text editor, you can either:
1. Open it ‘empty’, and start typing a new document, or
2. Open it with an existing document.
It never hurts to have a look at the first line of the man page, `man pico`:
`pico [ options ] [ file ]`
So:
- `pico`, then
- some optional [options], then
- optionally, a [file].
Ignoring the optional options, this gives us two paths... which might sound familiar?…
#LearnCLI
Ellane
in reply to Johnny ‘Decimal’ Noble • • •I did it! Pico is more familiar with its ⌃T commands, but you've introduced me to j and k for moving around, and so I've been spoiled with single letter commands!
So… I jumped off the cliff into vim land. And I like it! With :q! under my belt I'm having fun learning how to navigate a doc. #LearnCLI
Johnny ‘Decimal’ Noble
in reply to Ellane • • •Ha! What! This is excellent.
There are many, many fine vim tutorials out there. And really once you’ve got the hang of it, ten commands gets you by.
Next stop: Homebrew. 🚏 Give me a day or so. We’re heading to the National Library to work today, it’s our happy focus place.
#LearnCLI
Claudine C
in reply to Ellane • • •Hyde 📷 🖋
in reply to Johnny ‘Decimal’ Noble • • •maybe vimtutor can do it too !
Just type in your terminal :
$ vimtutor
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •Okay, let's turn in the direction of hledger. We're going to install it.
First, we need to install Homebrew. But first: what is it?
# Package managers
We're all used to installing software, and keeping that software up to date.
How do you install and keep updated applications for your Terminal? There are a bunch of ways, but Homebrew has become the de-facto standard for the Mac. Because it's just really nice.
commandline.johnnydecimal.com/…
#LearnCLI
Homebrew
commandline.johnnydecimal.comJohnny ‘Decimal’ Noble
Unknown parent • • •So the purpose of Homebrew is just to install hledger. How might we do that?
Homebrew's web site is amazing so we might as well double-check. Head over there and search for hledger using the box at the top. You should find yourself on the formulae page for the app.
In this case, the page tells us exactly what we need to do:
`brew install hledger`
cl.jdcm.al/learn/19-install-so…
#LearnCLI
Install some (Homebrew) packages
cl.jdcm.alJohnny ‘Decimal’ Noble
Unknown parent • • •Amazing progress!
So I'm going to throw caution to the wind — because it's Lucy's birthday today and I'm required out back to do chicken-related things — and give you the 'move a file' command.
Be careful with this one, because if you move the wrong file to the wrong place, there's no 'undo' in this world.
The command: `mv`, short for `move`.
And the same command serves as a rename! You just 'move' the file from its old name to its new name.
Check `man mv` but it's pretty obvious.
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •The equivalent to copy a file is `cp`. Maybe create some dummy stuff on your desktop and mess about there for a bit.
When you're sick of that stuff, `rm` (remove) will delete it.
What happens if you try to remove a whole folder? Can you find the (potentially VERY dangerous) flag that allows you to 'recursively' delete an entire folder?
Johnny ‘Decimal’ Noble
Unknown parent • • •What is/isn't hledger doing? Is there an error? Or can you post a screenshot?
The goal of this was to get you using hledger so let's focus our efforts there, and what you learn along the way is what you learn.
Johnny ‘Decimal’ Noble
Unknown parent • • •Nice one!
As a rule, if something's already installed then brew isn't going to want to mess with it. Brew needs to install it so that brew can control it, because files are in different places and were installed in different ways.
So you could remove Firefox and re-install using brew to bring it under its control?
Those SHOUTY THINGS you can ignore.
And you can `brew update` then `brew upgrade` to do a manual upgrade of your installed apps at any time.
Johnny ‘Decimal’ Noble
Unknown parent • • •Little CLI hint: `history` shows you stuff you've previously typed.
If you want to repeat one of them, `!xx`, where xx is the number before the command, will do that.
Hitting the up-arrow repeatedly will also call back previous commands. There's a nice way to improve this that I'll tell you about later.
Nate Dunn
Unknown parent • • •Nate Dunn
Unknown parent • • •OK, here @ellane asks about Control-E vs Control-E, and @johnnydecimal settles on the side of "not case sensitive."
But in the previous lesson, "Less Is More," in learning how to navigate a text file with search, "To find the next instance of the same search, hit `n`. The previous, `N`."
Isn't that an example of case sensitivity? Or is that a rare exception? Seems akin to "`tab` to move forward, `shift-Tab` to move backward" in many forms... 🤔
Nate Dunn
Unknown parent • • •Install some (Homebrew) packages
commandline.johnnydecimal.comJohnny ‘Decimal’ Noble
Unknown parent • • •@natedunnmi Feels like a default that the community has settled on over the years.
Control-[CHARACTER] = not case sensitive, i.e. Ctrl-n doesn't do a different thing to Ctrl-N. Therefore, pick a default, which is to express it as a captial. Maybe that's just clearer?
Whereas 'n' to go forward vs. ‘N' to to back, they're two different commands.
'n' without shift does one thing. 'n' with shift, that is to say ’N’, _does something different_.
Lots of this is just historical decisions…
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •@natedunnmi Also note how Mac + Windows is explicit about 'Shift'.
Ctrl+E on a Mac, means ‘control and the E key’.
You want a shift in there, you have to say it. 'Ctrl-Shift-E’.
Oh yeah, and look at your menus! Copy = ⌘C. But you don't have to press Shift to get a capital C.
Paste and match style = ⌥⇧⌘V. Needs a Shift, so the Shift is explicit.
Johnny ‘Decimal’ Noble
Unknown parent • • •Okay let’s get back on this #LearnCLI horse!
Bookmarks. How do you move quickly to another folder?
1. Define an alias
You can create an ‘alias’ which is like a shortcut. You define <some short thing> which does <some longer thing>.
`alias m='cd ~/Movies'` creates an alias, m, which issues the command to take you to your Movies folder.
So you can create yourself an 'hl' alias, say, which changes you to your hledger folder.
Typing `alias` shows you your defined aliases.
1/x
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •That's great, but you'll notice that these aliases aren't persistent: close the window and it's gone.
To make them persistent, we need to add them to a file which is run whenever a new prompt is launched.
This introduces your first 'dotfile'. So called because it starts with a dot.
Dotfiles are very common in CLI world. They're universally used as configuration files.
Because your system – including the macOS Finder – hides them by default. So they don't get in the way.
2/x
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •This particular dotfile is called .zshrc, and it lives in your home folder. So – and I'm _so proud_ that you're using vim – let's edit that.
vim ~/.zshrc
You might already have one with stuff in it. If not, you'll just see an empty file. Either way, add your alias as a new line.
Hint: lines starting with # are comments. So you might add a section like this:
# Ellane's aliases
alias hl='cd ~/some/deep/path/to/hledger'
to keep things neat.
Save that, open a new window, and test.
3/x
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •While we're in .zshrc, here's another quality-of-life improver that I always add to mine.
Normally when you press up-arrow to search through your history, it's just a dumb list of previous commands.
It's far more useful if you can type the start of a command you know you've previously typed, and have up-arrow search your history. To do that, add these lines:
# Enable history substring search
bindkey '^[[A' history-search-backward
bindkey '^[[B' history-search-forward
4/x
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •And one last hint: rather than having to open a new window every time, you can 'use' your .zshrc in the current window by typing:
source ~/.zshrc
Okay, this is just a quick one but I promise to stick with it now! And what I'll do is let it play out here for a bit, then summarise to the website.
Which, to remind our viewers, is commandline.johnnydecimal.com.
So! Tell me how you're getting on, and what you'd like to do next.
5/5
Ellane learns the command line
commandline.johnnydecimal.comJohnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •Oh yeah, and the point of that history thing is that I often find myself typing
cd ~/path/to
and knowing that this is enough to be able to trigger up-arrow, find what I want in history, and away I go.
Can be quicker day-to-day than defining an alias. Although defining the alias is the better thing to do, long-term.
6/5
Anita Lewis
Unknown parent • • •The filename he gave was
~/.zshrc
You may have named it .zschrc
It's a me, Mauro
Unknown parent • • •It's a me, Mauro
Unknown parent • • •Johnny ‘Decimal’ Noble
Unknown parent • • •Hyde 📷 🖋
Unknown parent • • •@ajlewis2 can you show us your ~/.zshrc ?
And maybe you are not using zsh, but bash
Hyde 📷 🖋
in reply to Johnny ‘Decimal’ Noble • • •mupdf is a viewer ...
To create from markdown, you can use pandoc like this :
$ pandoc file.md -o beautiful.pdf
Hyde 📷 🖋
Unknown parent • • •@mauro @ajlewis2 so it should work !
Can you show us your ~/.zshrc ?
Hyde 📷 🖋
Unknown parent • • •for vim if you have a small budget I recommend this book
pragprog.com/titles/dnvim2/pra…
Practical Vim, Second Edition
pragprog.comHyde 📷 🖋
Unknown parent • • •Anita Lewis
Unknown parent • • •It seems odd that the file was created new rather than having already been there. What do you see with
ls -a .zs*
It seems like there should have already been a .zshrc with something in it.
Also, somewhere in the back of my mind is the need to log off and back on for the change to work. Or you can use the command 'source ~/.zshrc' to make the change work I think.
Note: I know nothing about your OS, so I probably should stay out of this. It's just so puzzling.
Johnny ‘Decimal’ Noble
in reply to Anita Lewis • • •IIRC modern macOS doesn't come with a .zshrc.
Hmm I wonder ... Ellane, what do you see if you do:
cd ~/.zsh
ls -la
Edit: just realised I have a test user account on this machine that I don't configure. No .zshrc anywhere to be seen. So a blank file was to be expected, Ellane.
Johnny ‘Decimal’ Noble
Unknown parent • • •Try this.
share.cleanshot.com/lCKkMr7Y
You can see my current aliases there.
CleanShot 2024-08-30 at 13.49.38
share.cleanshot.comJohnny ‘Decimal’ Noble
Unknown parent • • •I wish you could do syntax highlighting here. It'd be nice to indicate exactly what's a command.
`Backticks`, being used for inline markdown, are often used to delimit the thing to be typed. In almost all cases you should not include them.
Sometimes people (or code blocks on websites) indicate a command with a $ at the front. That represents your prompt and should also not be typed.
(Sometimes when you copy the code block off a website the $ also gets copied! This is wrong.)
Thorsten Zöller
Unknown parent • • •There are many different kinds of shells, and most end with "sh" (standing simply for "shell") - like sh, bash, csh, tcsh, ksh, dash, fish etc. As far as I know, the "z" in "zsh" is the initial of someones name.
The "rc" stands for "run commands" (although there are different interpretations) and indicates that it is a configuration file.
Anita Lewis
in reply to Johnny ‘Decimal’ Noble • • •Ellane
in reply to Johnny ‘Decimal’ Noble • • •Thanks for the vid, I've watched it a few times but don't know what I was seeing. What's lutetium? You typed quotation marks before the cd...?
Sorry I'm not catching on too quickly this time!
Ellane
in reply to Ellane • • •Quelquefois c'est frustrant d'essayer d'apprendre une nouvelle langue !
But once you know the vocab, it comes more easily. One piece at a time.
Anita Lewis
in reply to Ellane • • •Not sure if you got your answer:
Yes there are quotation marks before the cd and at the end of it. These are around the command that ellane equals.
And on the next screen after saving this, notice that he typed
source .zshrc
That lets the shell see this change you've made. The other option is to log off and then login again.
Johnny ‘Decimal’ Noble
in reply to Ellane • • •lutetium is the name of this laptop, so that's just part of my prompt.
The alias I added was:
alias ellane="cd ~/Movies"
(Confusing things by using "double quotes vs. 'single last time. Sorry! But they both work the same.)
Then we exit vim and I 'source' that file to activate the new alias. Or I could have opened another shell.
Because this .zshrc file is run by every new shell on launch. That's what it's for. Hence putting a command in it will make it available in every new shell.
Johnny ‘Decimal’ Noble
in reply to Johnny ‘Decimal’ Noble • • •So you'll want to add something like
alias hl="cd /path/to/your/hledger/directory"
Then save, either 'source' the file or launch a new shell, and then
hl
_should_ jump you there.
You can use the `echo` command to test your .zshrc is being executed. `echo` just types out text. Try it:
echo Help I am stuck in the computer!
So you can put an `echo` in your .zshrc and every time you launch a new shell, you should see what you wrote.