<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="en">
	<title>Ellane learns the command line</title>
	<subtitle>Ellane and Johnny have a conversation about the command line.</subtitle>
	<link href="https://commandline.johnnydecimal.com/feed/feed.xml" rel="self"/>
	<link href="https://commandline.johnnydecimal.com/"/>
	<updated>2024-07-06T07:58:28Z</updated>
	<id>https://commandline.johnnydecimal.com/</id>
	<author>
		<name>Ellane and Johnny</name>
		<email>hello@johnnydecimal.com</email>
	</author>
	
	<entry>
		<title>Install some (Homebrew) packages</title>
		<link href="https://commandline.johnnydecimal.com/learn/19-install-some-packages/"/>
		<updated>2024-07-06T07:58:28Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/19-install-some-packages/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ellane&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Done. I was held up briefly because there was no visual feedback when typing my password; got it on the second try.&lt;/p&gt;
&lt;p&gt;It seems to have worked, as &lt;code&gt;brew help&lt;/code&gt; is showing me a list of ways to get started. I&#39;ll be (wisely) leaving those alone until you help me learn what they&#39;re all about.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So the purpose of Homebrew is just to install hledger. How might we do that?&lt;/p&gt;
&lt;p&gt;Homebrew&#39;s web site is &lt;em&gt;amazing&lt;/em&gt; so we might as well double-check. Head &lt;a href=&quot;https://brew.sh&quot;&gt;over there&lt;/a&gt; and search for &lt;code&gt;hledger&lt;/code&gt; using the box at the top. You should find yourself &lt;a href=&quot;https://formulae.brew.sh/formula/hledger#default&quot;&gt;on the formulae page for the app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We don&#39;t really need to know how Homebrew works. Just like we don&#39;t really know what&#39;s happening when we launch an installer and &lt;strong&gt;next, next, next&lt;/strong&gt;. But, just briefly, it has what it calls &#39;formulae&#39;, which are just installation scripts. And sometimes you have to add a &#39;cask&#39; (they really push this metaphor) so that you can access these formulae.&lt;/p&gt;
&lt;p&gt;But in this case, the page tells us exactly what we need to do:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;brew &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; hledger&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which is a familiar pattern by now: some command, &lt;code&gt;brew&lt;/code&gt;, followed by some options. Let&#39;s keep reinforcing this with a quick trip to &lt;code&gt;man brew&lt;/code&gt;, which tells us that the syntax for &lt;code&gt;brew&lt;/code&gt; is:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;brew &lt;span class=&quot;token builtin class-name&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;--verbose&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;-v&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;options&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;formula&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let&#39;s drop our command in below that.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;brew &lt;span class=&quot;token builtin class-name&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;--verbose&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;-v&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;options&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;formula&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;# man brew&lt;/span&gt;
brew &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt;                           hledger  &lt;span class=&quot;token comment&quot;&gt;# our command&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So that&#39;s:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;brew&lt;/code&gt;, the main command.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;install&lt;/code&gt;, which is brew&#39;s &#39;command&#39;: you&#39;re saying, &lt;em&gt;brew, please install a thing&lt;/em&gt;.
&lt;ul&gt;
&lt;li&gt;Similarly you can &lt;code&gt;brew remove ...&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Optionally the flags &lt;code&gt;--verbose&lt;/code&gt; &lt;em&gt;or&lt;/em&gt; &lt;code&gt;-v&lt;/code&gt; -- a very common flag that tells the command to be verbose in its output.
&lt;ul&gt;
&lt;li&gt;You tend to use this when you&#39;re trying to troubleshoot something.&lt;/li&gt;
&lt;li&gt;We didn&#39;t specify them in our command. You can if you like.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[options]&lt;/code&gt;, some optional options.
&lt;ul&gt;
&lt;li&gt;Which we&#39;re not using.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[formula]&lt;/code&gt;, which we&#39;re specifying as &lt;code&gt;hledger&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of this is just to get these patterns deeper in your brain. The more familiar they are the more comfortable you&#39;ll be.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;hledger&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;hledger&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/19-install-some-packages/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Assuming there were no errors -- and you should always read the last few lines of the installation output just to be sure -- you&#39;ve now got &lt;code&gt;hledger&lt;/code&gt; installed. Run it!&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;hledger&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So when I ran it I thought two things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Oh that looks cool!&lt;/li&gt;
&lt;li&gt;It&#39;s flashing a cursor ... does it want me to run a command?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://commandline.johnnydecimal.com/img/18.01-hledger-help-2004x1394@2x.png&quot; alt=&quot;hledger&#39;s welcome/help screen&quot; width=&quot;1002&quot; height=&quot;697&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;homework&quot; tabindex=&quot;-1&quot;&gt;Homework &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/19-install-some-packages/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that this is installed, see what you can do with it. I&#39;ve played myself and it &lt;em&gt;is&lt;/em&gt; pretty arcane! So don&#39;t worry if you don&#39;t get too far.&lt;/p&gt;
&lt;p&gt;(You can&#39;t mess this up. If the worst happens, we just remove it and add it again.)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Homebrew</title>
		<link href="https://commandline.johnnydecimal.com/learn/18-homebrew/"/>
		<updated>2024-07-01T07:42:16Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/18-homebrew/</id>
		<content type="html">&lt;p&gt;Okay, let&#39;s turn in the direction of &lt;code&gt;hledger&lt;/code&gt;. We&#39;re going to install it.&lt;/p&gt;
&lt;p&gt;First, we need to install Homebrew. But first: what is it?&lt;/p&gt;
&lt;h2 id=&quot;package-managers&quot; tabindex=&quot;-1&quot;&gt;Package managers &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;We&#39;re all used to installing software, and keeping that software up to date.&lt;/p&gt;
&lt;p&gt;You might use the App Store, which is one-click with invisible updates in the background.&lt;/p&gt;
&lt;p&gt;You might download a &lt;code&gt;.pkg&lt;/code&gt; file, which you double-click and &lt;strong&gt;next, next, next&lt;/strong&gt; your way through. The application it installs then prompts you, over time, to perform updates.&lt;/p&gt;
&lt;p&gt;But how do you install and keep updated applications for your Terminal? There are a bunch of ways, but &lt;strong&gt;Homebrew&lt;/strong&gt; has become the de-facto standard for the Mac. Because it&#39;s just really nice.&lt;/p&gt;
&lt;h2 id=&quot;other-hledger-options&quot; tabindex=&quot;-1&quot;&gt;Other &lt;code&gt;hledger&lt;/code&gt; options &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It&#39;s worth nothing that there &lt;em&gt;are&lt;/em&gt; &lt;a href=&quot;https://hledger.org/install.html&quot;&gt;other installation options&lt;/a&gt; for &lt;code&gt;hledger&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;But given how nice Homebrew is, we&#39;re going to use it.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;install-homebrew&quot; tabindex=&quot;-1&quot;&gt;Install Homebrew &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Okay, right there on the &lt;a href=&quot;https://brew.sh&quot;&gt;home page&lt;/a&gt;. Simply copy paste this command in to Terminal.&lt;/p&gt;
&lt;h1 id=&quot;&quot; tabindex=&quot;-1&quot;&gt;🚨 🛑 ‼️ 🚨 🛑 ‼️ &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;A massive word of caution. Whenever someone, including me, tells you to &#39;simply copy/paste a command in to Terminal&#39;: &lt;strong&gt;don&#39;t do that.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;By now you have an idea of what this thing can do. It&#39;s a window in to the deepest parts of your system. And so entering random commands from the internet is a massive, massive risk.&lt;/p&gt;
&lt;p&gt;So what do we do? Well, we just have to be aware of that, and to trust Homebrew. Because, realistically, we can&#39;t validate this command ourselves. It&#39;s too hard. So unless Homebrew has been hacked, or the people running it suddenly sold out, we&#39;ll be okay.&lt;/p&gt;
&lt;p&gt;Just be aware of the risk.&lt;/p&gt;
&lt;h2 id=&quot;the-installation-command&quot; tabindex=&quot;-1&quot;&gt;The installation command &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;We don&#39;t &lt;em&gt;need&lt;/em&gt; to understand it, but let&#39;s deconstruct it a little just so you&#39;re aware.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/bin/bash -c &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;bin-bash-c&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;/bin/bash -c&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is an absolute path to a command: actually, to the &lt;code&gt;bash&lt;/code&gt; shell itself. Then the flag &lt;code&gt;-c&lt;/code&gt; says to &#39;read the next command from a string&#39;.&lt;/p&gt;
&lt;p&gt;So this just says, &#39;do the rest of this command in a shell&#39;. And we&#39;re already in a shell.&lt;/p&gt;
&lt;p&gt;I&#39;m not sure why this is required, to be honest. I think it&#39;s just the Homebrew people being really, really safe: you should be able to run this command from darned-near anywhere and it&#39;ll work.&lt;/p&gt;
&lt;h2 id=&quot;-1&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;&amp;quot;$( ... )&amp;quot;&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The command to be passed to &lt;code&gt;bash -c&lt;/code&gt; is enclosed in quotes and dollars and brackets for reasons. ;-)&lt;/p&gt;
&lt;h2 id=&quot;curl&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;curl&lt;/code&gt; 🟢 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is what&#39;s doing all of the work.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;curl&lt;/code&gt; gets web pages. Try it out: &lt;code&gt;curl https://jdcm.al&lt;/code&gt; will dump the HTML of my home page in your Terminal.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I&#39;m not sure what the &lt;code&gt;c&lt;/code&gt; is for, but &lt;code&gt;url&lt;/code&gt; as in, a URL.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The flags &lt;code&gt;-fsSL&lt;/code&gt; presumably do important things in this context, which &lt;code&gt;man curl&lt;/code&gt; would explain to us, but I&#39;m not going to go there.&lt;/p&gt;
&lt;p&gt;So what is &lt;code&gt;curl&lt;/code&gt; getting? This:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And that&#39;s just a URL! So we can &lt;a href=&quot;https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh&quot;&gt;view it in a browser&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It&#39;s ... long ... and ... really complicated. But what we&#39;re looking at here is the installation script for Homebrew. I barely understand it.&lt;/p&gt;
&lt;p&gt;Now if we zoom back out and look at the whole installation command, we&#39;ve got:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;bash -c&lt;/code&gt; running something that&lt;/li&gt;
&lt;li&gt;&lt;code&gt;curl -fsSL&lt;/code&gt; downloads, which is&lt;/li&gt;
&lt;li&gt;this script.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It should be obvious why this is risky from a security perspective.&lt;/p&gt;
&lt;h2 id=&quot;caution-to-the-wind&quot; tabindex=&quot;-1&quot;&gt;Caution to the wind &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/18-homebrew/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It&#39;s time, though. Copy the command from the Homebrew home page, paste it in your Terminal, and off you go.&lt;/p&gt;
&lt;p&gt;When the installation finishes, it&#39;ll tell you to do something like:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;- Run these two commands &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; your terminal to &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; Homebrew to your &lt;span class=&quot;token environment constant&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;echo&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;eval &quot;$(/opt/homebrew/bin/brew shellenv)&quot;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; /Users/john/.zprofile
    &lt;span class=&quot;token builtin class-name&quot;&gt;eval&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;/opt/homebrew/bin/brew shellenv&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;/span&gt;
- Run brew &lt;span class=&quot;token builtin class-name&quot;&gt;help&lt;/span&gt; to get started
- Further documentation:
    https://docs.brew.sh&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Yours will be subtly different to mine, so copy them from your screen, not this page. But just so it&#39;s clear, the two commands are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;(echo; echo &#39;eval &amp;quot;$(/opt/homebrew/bin/brew shellenv)&amp;quot;&#39;) &amp;gt;&amp;gt; /Users/john/.zprofile&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;eval &amp;quot;$(/opt/homebrew/bin/brew shellenv)&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;...and then &lt;code&gt;brew help&lt;/code&gt; to check it&#39;s worked. If it hasn&#39;t, closing and re-opening your Terminal window might help.&lt;/p&gt;
&lt;p&gt;That&#39;s enough for today, and I need to go and cook dinner!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>A rapid advance</title>
		<link href="https://commandline.johnnydecimal.com/learn/17-a-rapid-advance/"/>
		<updated>2024-07-01T07:33:31Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/17-a-rapid-advance/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;Just copy/pasting this one from Mastodon. I&#39;m a bit behind, sorry everyone!
–j.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;(I will update the site later.)&lt;/p&gt;
&lt;p&gt;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 &lt;em&gt;massive&lt;/em&gt; undertaking, and your actual goal is to ‘learn plain text accounting, specifically hledger’.&lt;/p&gt;
&lt;p&gt;Rather than possibly useless theory, therefore, we’re going to focus on the goal, and cover topics &lt;em&gt;as required&lt;/em&gt; on our way to that goal.&lt;/p&gt;
&lt;p&gt;In your latest blog post you mentioned that you can read stuff, but you can’t yet edit. So let’s do that now.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;The command 🥁 is 🥁&lt;/p&gt;
&lt;p&gt;&lt;code&gt;pico&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;That’s it. You can just type &lt;code&gt;pico&lt;/code&gt; and it’ll open.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;This is a pretty rudimentary text editor. It’s not the legendary &lt;code&gt;vim&lt;/code&gt;. But it’s easy to use, and it’ll do the job.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;You can use whatever you like to edit them. And just dive down to the CLI as required.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Next, we’re going to go straight for the hledger installation page. 😬&lt;/p&gt;
&lt;h1 id=&quot;ellane-responds&quot; tabindex=&quot;-1&quot;&gt;Ellane responds... &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/17-a-rapid-advance/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Challenge accepted! You’re right about not needing to use the CLI to edit my files; it’s just a vehicle for learning a skill. A mountain to climb, not to build a house on.&lt;/p&gt;
&lt;p&gt;I’m looking forward to the next bit! I messed around with installing hLedger last year, but never understood what I was doing, or how to update to the latest version.&lt;/p&gt;
&lt;h2 id=&quot;later-that-day&quot; tabindex=&quot;-1&quot;&gt;Later that day... &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/17-a-rapid-advance/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Ahah— a challenge for both of us! I&#39;ve followed your instructions to the best of my ability, and am stuck.&lt;/p&gt;
&lt;p&gt;&amp;quot;You can just type &lt;code&gt;pico&lt;/code&gt; and it will open&amp;quot;.&lt;/p&gt;
&lt;p&gt;What will open? I managed to use Terminal to create a new file in the location of my choice, but not to open an existing file. If I type &lt;code&gt;less&lt;/code&gt; I can read the file, but not edit it.&lt;/p&gt;
&lt;p&gt;This is the kind of roadblock that would have made me give up in the past—but not now! I&#39;ll keep trying to work it out.&lt;/p&gt;
&lt;h2 id=&quot;johnny&quot; tabindex=&quot;-1&quot;&gt;Johnny... &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/17-a-rapid-advance/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Okay, we have two possibilities here.&lt;/p&gt;
&lt;p&gt;Just like with any other text editor, you can either:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open it ‘empty’, and start typing a new document, or&lt;/li&gt;
&lt;li&gt;Open it with an existing document.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It never hurts to have a look at the first line of the man page, &lt;code&gt;man pico&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;pico [ options ] [ file ]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;pico&lt;/code&gt;, then&lt;/li&gt;
&lt;li&gt;some optional [options], then&lt;/li&gt;
&lt;li&gt;optionally, a [file].&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ignoring the optional options, this gives us two paths... which might sound familiar?…&lt;/p&gt;
&lt;h2 id=&quot;ellane&quot; tabindex=&quot;-1&quot;&gt;Ellane... &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/17-a-rapid-advance/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I did it! Pico is more familiar with its &lt;code&gt;⌃T&lt;/code&gt; commands, but you&#39;ve introduced me to &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; for moving around, and so I&#39;ve been spoiled with single letter commands!&lt;/p&gt;
&lt;p&gt;So… I jumped off the cliff into &lt;code&gt;vim&lt;/code&gt; land. And I like it! With &lt;code&gt;:q!&lt;/code&gt; under my belt I&#39;m having fun learning how to navigate a doc.&lt;/p&gt;
&lt;h2 id=&quot;johnny-1&quot; tabindex=&quot;-1&quot;&gt;Johnny... &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/17-a-rapid-advance/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Ha! What! This is excellent.&lt;/p&gt;
&lt;p&gt;There are many, many fine &lt;code&gt;vim&lt;/code&gt; tutorials out there. And really once you’ve got the hang of it, ten commands gets you by.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Lots of feedback</title>
		<link href="https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/"/>
		<updated>2024-06-08T06:21:39Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/</id>
		<content type="html">&lt;p&gt;This one has taken me a while to work through, lots to take in.&lt;/p&gt;
&lt;p&gt;Firstly, why &lt;em&gt;yes&lt;/em&gt;, I do happen to have a plain text file or two handy! And I note that &lt;code&gt;.md&lt;/code&gt; seems to fall under the &lt;code&gt;.txt&lt;/code&gt; umbrella. Nice.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Good spotting! And in fact the CLI doesn&#39;t give a hoot about those file extensions. It&#39;s what&#39;s &lt;em&gt;in&lt;/em&gt; the file that counts. You can call it &lt;code&gt;myfile.sausages&lt;/code&gt; and as long as it&#39;s actually text, and not sausages, it&#39;ll open just fine.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;These exercises began with the frustration of it taking me what felt like an age to navigate to a folder with text files long enough to work with. Autocomplete didn&#39;t seem to be working so I reviewed the lesson on that topic. Great! Clear on that at last.&lt;/p&gt;
&lt;p&gt;Until I mistakenly pressed tab to summon auto complete with one quote mark at the beginning of a word—it&#39;s obvious I should have omitted it, but now I&#39;ve got &lt;code&gt;[dquote&amp;gt;&lt;/code&gt; and I don&#39;t know what to do with it. None of the commands I&#39;ve learned thus far helped (including &lt;code&gt;logout&lt;/code&gt;, &lt;code&gt;q&lt;/code&gt;) so I closed the window with the red corner dot and opened a new one.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
I do that all the time! It thinks you want to split that text over multiple lines -- because you&#39;ve opened a quote, but you haven&#39;t closed it yet.&lt;/p&gt;
&lt;p&gt;The easiest way out of this and &lt;em&gt;many&lt;/em&gt; other pickles is to hit &lt;code&gt;control-C&lt;/code&gt;. This (usually) tells the current process to gracefully quit.&lt;/p&gt;
&lt;p&gt;I&#39;ll tell you more about this later but for now that&#39;ll be useful to know.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;bookmarks-shortcuts&quot; tabindex=&quot;-1&quot;&gt;Bookmarks? Shortcuts? &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Is there a way to create a bookmark, a shortcut, to get to a deeply nested folder? Please say yes!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
Yes. I&#39;ve added that to &lt;a href=&quot;https://commandline.johnnydecimal.com/about/#later&quot;&gt;the list&lt;/a&gt; of stuff to get to. For now, a neat trick is that you can drag a macOS folder icon in to Terminal and it&#39;ll appear as a file path.&lt;/p&gt;
&lt;p&gt;So type &lt;code&gt;cd␣&lt;/code&gt;, find the folder you want in Finder, and drag it on to the window.&lt;/p&gt;
&lt;p&gt;(Note the &lt;code&gt;␣&lt;/code&gt; there that we use to represent &#39;a space character&#39; where it might not otherwise be so obvious.)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;using-the-home-row-keys&quot; tabindex=&quot;-1&quot;&gt;Using the home-row keys &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; are much more convenient than searching out the up and down arrow keys.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;q&lt;/code&gt; for quit? It was really that simple?? Good to know. I&#39;ve been stuck on pages like this in the past, not knowing how to get out.&lt;/p&gt;
&lt;p&gt;If spacebar moves down one full page, is there a command to move back up one full page? EDIT: Forget this one—I found it.&lt;/p&gt;
&lt;h2 id=&quot;wrap-at-word-breaks&quot; tabindex=&quot;-1&quot;&gt;Wrap at word breaks? &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I&#39;m seeing character wrapping rather than word wrapping. Is there anything in the Settings to fix this? It disrupts the flow of reading.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
Interesting ... &lt;code&gt;less&lt;/code&gt; doesn&#39;t do that itself, no. I&#39;m surprised.&lt;/p&gt;
&lt;p&gt;But! This gives me a lovely example to use in the next lesson. Watch this space.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;capitalisation-of-things&quot; tabindex=&quot;-1&quot;&gt;Capitalisation of things &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Righteo, that &lt;code&gt;h&lt;/code&gt; brings up shortcuts in the file viewer. Is this a file viewer, or a File Viewer? In my mind the former would be built-in, a CLI system-wide way of navigating a file, whereas the latter would be one flavour, like an app.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
Well in this specific case, we&#39;re in &lt;code&gt;less&lt;/code&gt;. Which is just &lt;em&gt;a&lt;/em&gt; file viewer. Unless I misunderstood the question?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Is &lt;code&gt;Control-E&lt;/code&gt; the same as &lt;code&gt;Control-e&lt;/code&gt;? When I see an upper case letter in a CLI context it feels like pressing Shift is implied. So would &lt;code&gt;Control-E&lt;/code&gt; actually be &lt;code&gt;Control+Shift+E&lt;/code&gt;, or is it case insensitive? Like &lt;code&gt;Command-S&lt;/code&gt; on the Mac, for Save.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
This niggles me too, but I guess it&#39;s an old convention. I &lt;em&gt;think&lt;/em&gt; -- if any readers have more history, let&#39;s have it -- that it&#39;s because &lt;code&gt;control-shift-&amp;lt;character&amp;gt;&lt;/code&gt; just isn&#39;t really a thing in CLI-world. It&#39;s &lt;code&gt;control-&amp;lt;character&amp;gt;&lt;/code&gt; or nothing, so the fact that it&#39;s indicated as &lt;code&gt;E&lt;/code&gt; is just a style thing?&lt;/p&gt;
&lt;p&gt;But this is just me speculating. Short answer: not case-sensitive.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;touch-typing&quot; tabindex=&quot;-1&quot;&gt;Touch typing &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Yes, I touch type. 85 wpm on a good day. (It&#39;s such an important skill in my book that I stooped to bribery, offering each of my children a modest cash prize if they could demonstrate it to my satisfaction. All four did, and now as adults they are proficient where many of their peers are not.)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
I totally agree. I taught myself when I was at uni. The reasons were not noble: I was giving myself a headache copying my mate&#39;s work, looking from the screen to his work to the keyboard.&lt;/p&gt;
&lt;p&gt;So I taught myself and it&#39;s one of the best things I&#39;ve ever done. (They kicked me out of uni.)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;searching-and-navigating&quot; tabindex=&quot;-1&quot;&gt;Searching and navigating &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I pressed &lt;code&gt;/&lt;/code&gt; to search for this string &amp;quot;F..&amp;quot; in my text file by escaping the two periods. So far so good, but what I wanted was to be taken to the first instance, and then to the next when I was ready, etc. Searching like this highlighted the right pattern, but I had to scroll through a very long document to find each instance.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;g&lt;/code&gt; will take you to the top of the document, then &lt;code&gt;n&lt;/code&gt; will take you to the next instance.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I just typed this: &amp;quot;Why doesn&#39;t autocomplete work with the &lt;code&gt;less&lt;/code&gt; command? Do I really have to type out the full name of the file I want to view?&amp;quot; before realising I&#39;d been pressing &lt;code&gt;return&lt;/code&gt; after the first part of the name, rather than &lt;code&gt;tab&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Until this becomes (new) muscle memory, I can see I&#39;m going to have to slow down and compare what I&#39;ve learned with what my fingers are used to doing.&lt;/p&gt;
&lt;p&gt;So. Auto complete worked when searching for a text file to open, but it returned &lt;code&gt;no such file or directory&lt;/code&gt; until I added the file extension to the name. What&#39;s that all about?&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
This should work. Perhaps there were two documents with the same name but different file extensions? Your tab-completion will only take you as far as it can before it hits ambiguity. So did it stop before the extension, but you didn&#39;t notice, so when you hit &lt;code&gt;return&lt;/code&gt; you didn&#39;t actually have the file extension in there?&lt;/p&gt;
&lt;p&gt;As you noted above, yeah, this is a world where you really do need to check everything. Because the CLI will do &lt;em&gt;exactly what you tell it to&lt;/em&gt;, and no more.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I&#39;m mentally framing this quote: &amp;quot;None of it is difficult; it&#39;s just unfamiliar.&amp;quot;&lt;/p&gt;
&lt;p&gt;A year or so ago I spent a week interacting with my &lt;code&gt;.md&lt;/code&gt; notes exclusively in TextEdit (plain text mode), just for the experience. Those raw visuals were a good introduction for becoming familiar with the command line, I now realise.&lt;/p&gt;
&lt;h2 id=&quot;man-man&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;man man&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/16-lots-of-feedback/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Wowza, that&#39;s a lot of reading! I scanned through the man page for &lt;code&gt;man&lt;/code&gt; itself, and for &lt;code&gt;less&lt;/code&gt;. I can see why it&#39;s built in; that&#39;s a lot to remember. Nothing I&#39;m not used to, though. I&#39;m a big keyboard shortcut user in the apps I spend the most time in.&lt;/p&gt;
&lt;p&gt;The &amp;quot;Convention: indicating flags and arguments&amp;quot; section of this lesson feels like deep water. If you&#39;ve never used any of those options to &lt;code&gt;man&lt;/code&gt;, chances are high I never will either.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Johnny&lt;/strong&gt;&lt;br&gt;
Yeah don&#39;t stress about that -- or the volume of information in many other man pages. I showed you that just to drill home the paths-and-options-and-arguments thing, as it&#39;s so fundamental.&lt;/p&gt;
&lt;p&gt;Honestly 90% of man pages I open, skim for the tiny thing I need, and quit. They can be inscrutable and scary.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I&#39;ll leave it here, and spend the next few days playing around with man (oh gosh, the dad jokes around this one must be plentiful!).&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Less is more</title>
		<link href="https://commandline.johnnydecimal.com/learn/15-less-is-more/"/>
		<updated>2024-06-06T08:41:38Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/15-less-is-more/</id>
		<content type="html">&lt;p&gt;Great questions, and we&#39;ll get to &lt;code&gt;drwxr-xr-x&lt;/code&gt; really soon.&lt;/p&gt;
&lt;p&gt;For now, addressing the &lt;code&gt;ls-F&lt;/code&gt; error, let&#39;s introduce you to the built-in help pages: known as &lt;strong&gt;man pages&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The reason the instruction from the &lt;a href=&quot;https://ss64.com/mac/ls.html&quot;&gt;page at ss64&lt;/a&gt; didn&#39;t work is because that page is out of date.&lt;/p&gt;
&lt;p&gt;So how do you view up-to-date information? Well let&#39;s start with how you view &lt;em&gt;any&lt;/em&gt; information.&lt;/p&gt;
&lt;h2 id=&quot;do-you-have-a-plain-text-file-handy&quot; tabindex=&quot;-1&quot;&gt;Do you have a plain text file handy? &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Typing this at my kitchen table I thought, I&#39;ll have to tell her to create a plain text file that she can use to test this next bit. Most people don&#39;t just have a bunch of plain text files knocking about.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://commandline.johnnydecimal.com/img/15.01-facepalm-777x437.jpg&quot; alt=&quot;The Picard facepalm. (If I do say so myself, I bear a resemblance to Jean-Luc.)&quot; width=&quot;777&quot; height=&quot;437&quot;&gt;&lt;/p&gt;
&lt;p&gt;Then I remembered who I was talking to.&lt;/p&gt;
&lt;h2 id=&quot;let-s-view-a-file&quot; tabindex=&quot;-1&quot;&gt;Let&#39;s view a file &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Emphasis on &lt;em&gt;view&lt;/em&gt;: we have no desire to &lt;em&gt;edit&lt;/em&gt; it.&lt;/p&gt;
&lt;p&gt;This gets to one of the general principles in the CLI: the &lt;em&gt;principle of least privilege&lt;/em&gt;.&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot; id=&quot;fnref1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt; If you don&#39;t need to edit a file, don&#39;t open it in a file editor: open it in a file viewer.&lt;/p&gt;
&lt;p&gt;The oldest command, and the one you&#39;ll see referenced most often, is &lt;code&gt;more&lt;/code&gt;. Unfortunately that&#39;s another one that&#39;s in my muscle-memory. Because there&#39;s a better command, and as you&#39;re new you might as well start using it.&lt;/p&gt;
&lt;p&gt;In classic Unix style, it&#39;s called &lt;code&gt;less&lt;/code&gt;.&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot; id=&quot;fnref2&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;We&#39;ll use &lt;code&gt;less&lt;/code&gt;, but if you see &lt;code&gt;more&lt;/code&gt; in online instructions you can either use it, or substitute &lt;code&gt;less&lt;/code&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;less&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;less&lt;/code&gt; 🟢 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; yourself to a folder that has some text files.&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot; id=&quot;fnref3&quot;&gt;[3]&lt;/a&gt;&lt;/sup&gt; And then, as you might expect:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;less&lt;/span&gt; yourfile&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;it-ll-show-the-file&quot; tabindex=&quot;-1&quot;&gt;It&#39;ll show the file &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Big whoop! What&#39;s more interesting is how we move &lt;em&gt;around&lt;/em&gt; the file, because you should assume that your mouse won&#39;t work. (It will probably scroll up and down for you. But don&#39;t do that.)&lt;/p&gt;
&lt;p&gt;Again, there are well-worn conventions that will serve you in many CLI situations.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;space&lt;/code&gt; key will move you down one full page. This is a really nice way to read a long article.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Arrow-up&lt;/code&gt; and &lt;code&gt;arrow-down&lt;/code&gt; will move you up and down a line.
&lt;ul&gt;
&lt;li&gt;But the more CLI way to do it is to use &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;These keys are on the home row. Your fingers are already there.&lt;/li&gt;
&lt;li&gt;And they&#39;re the same keys that &lt;code&gt;vim&lt;/code&gt; uses, so learning them now will be really handy later.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;q&lt;/code&gt; quits.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are tons more, and there&#39;s no point me listing them all: press &lt;code&gt;h&lt;/code&gt; to bring up the help screen.&lt;/p&gt;
&lt;h2 id=&quot;means-the-control-key&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;^&lt;/code&gt; means the &lt;code&gt;control&lt;/code&gt; key &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Another convention, and this one&#39;s universal. &lt;code&gt;^E&lt;/code&gt; means &lt;code&gt;control-E&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;search-is-interesting&quot; tabindex=&quot;-1&quot;&gt;Search is interesting &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you hit &lt;code&gt;/&lt;/code&gt;, you&#39;re in search mode. Type a word, hit return.&lt;/p&gt;
&lt;p&gt;To find the next instance of the same search, hit &lt;code&gt;n&lt;/code&gt;. The previous, &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Again, this is how &lt;code&gt;vim&lt;/code&gt; works.&lt;/p&gt;
&lt;p&gt;When you get used to these shortcuts -- &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt; to search -- you start to move around a lot more quickly.&lt;/p&gt;
&lt;p&gt;(Just curious: do you touch-type?)&lt;/p&gt;
&lt;h2 id=&quot;homework-read-all-of-the-less-help&quot; tabindex=&quot;-1&quot;&gt;Homework: read all of the &lt;code&gt;less&lt;/code&gt; help &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The help page has a lot of nerdy terminology that ties together everything we&#39;ve learned so far. It might look scary to start, but just read it all slowly, try out the various options, and get used to how it all looks.&lt;/p&gt;
&lt;p&gt;Being able to see a screen like this and absorb it all is the superpower we&#39;re aiming for. None of it&#39;s difficult; it&#39;s just unfamiliar.&lt;/p&gt;
&lt;p&gt;Make sure you&#39;re really comfortable with that before we move on&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;man-pages&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;man&lt;/code&gt; pages &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;So this brings us to the &lt;code&gt;man&lt;/code&gt; page, one of the wonders of the modern world.&lt;/p&gt;
&lt;p&gt;Every (well-behaved) command has its own manual page. It tells you everything you need to know about that command: its flags, options, and the arguments that it takes.&lt;/p&gt;
&lt;p&gt;So &lt;code&gt;man&lt;/code&gt; is the command, and it takes flags, options, and arg... well, let&#39;s just have a look.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;man&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;man&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You&#39;re looking at the man page for &lt;code&gt;man&lt;/code&gt;. :-)&lt;/p&gt;
&lt;h2 id=&quot;convention-indicating-flags-and-arguments&quot; tabindex=&quot;-1&quot;&gt;Convention: indicating flags and arguments &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let&#39;s dissect this first line.&lt;/p&gt;
&lt;pre class=&quot;language-txt&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-txt&quot;&gt;man [-adho] [-t | -w] [-M manpath] [-P pager] [-S mansect]
         [-m arch[:machine]] [-p [eprtv]] [mansect] page ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is telling us that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The command is &lt;code&gt;man&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It optionally accepts &lt;code&gt;a&lt;/code&gt; &lt;code&gt;d&lt;/code&gt; &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt;, or any combination thereof, as flags.&lt;/li&gt;
&lt;li&gt;It optionally takes &lt;em&gt;either&lt;/em&gt; &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;w&lt;/code&gt; as flags. But not both.
&lt;ul&gt;
&lt;li&gt;The pipe symbol &lt;code&gt;|&lt;/code&gt; means &#39;or&#39;. One &lt;em&gt;or&lt;/em&gt; the other.&lt;/li&gt;
&lt;li&gt;Or, because they&#39;re both in &lt;code&gt;[square brackets]&lt;/code&gt;, neither!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;It optionally takes &lt;code&gt;M&lt;/code&gt; as an option with a required &lt;code&gt;manpath&lt;/code&gt; argument.&lt;/li&gt;
&lt;li&gt;It optionally takes &lt;code&gt;P&lt;/code&gt; as an option with a required &lt;code&gt;pager&lt;/code&gt; argument.&lt;/li&gt;
&lt;li&gt;It optionally takes &lt;code&gt;S&lt;/code&gt; as an option with a required &lt;code&gt;mansect&lt;/code&gt; argument.&lt;/li&gt;
&lt;li&gt;It optionally takes &lt;code&gt;m&lt;/code&gt; as an option with a required &lt;code&gt;arch&lt;/code&gt; argument, and optionally you can specify &lt;code&gt;arch:machine&lt;/code&gt;. Options-in-options!&lt;/li&gt;
&lt;li&gt;It optionally takes &lt;code&gt;p&lt;/code&gt; as an option with any combination of &lt;code&gt;eprtv&lt;/code&gt; as additional arguments.&lt;/li&gt;
&lt;li&gt;It optionally takes a &lt;code&gt;mansect&lt;/code&gt; argument.&lt;/li&gt;
&lt;li&gt;It requires a &lt;code&gt;page&lt;/code&gt; argument.&lt;/li&gt;
&lt;li&gt;You can supply multiple arguments, denoted by &lt;code&gt;...&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There&#39;s a &lt;em&gt;lot&lt;/em&gt; there, and I&#39;ve never used any of those options to &lt;code&gt;man&lt;/code&gt;. The point of this was just to decipher that stuff at the top.&lt;/p&gt;
&lt;p&gt;So when we did &lt;code&gt;man man&lt;/code&gt;, we typed the command, &lt;code&gt;man&lt;/code&gt;, and supplied the only required argument, &lt;code&gt;page&lt;/code&gt;, which just so happened to also be &lt;code&gt;man&lt;/code&gt;!&lt;/p&gt;
&lt;h2 id=&quot;keep-reading&quot; tabindex=&quot;-1&quot;&gt;Keep reading &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I wonder what &lt;code&gt;-a&lt;/code&gt; does. I can either scroll down with &lt;code&gt;space&lt;/code&gt;, or the smarter way is to search for it with &lt;code&gt;/&lt;/code&gt; then &lt;code&gt;-a&lt;/code&gt; and &lt;code&gt;return&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The first search result shows us this line that we&#39;re reading. Hit &lt;code&gt;n&lt;/code&gt; for the next result, and there we go.&lt;/p&gt;
&lt;pre class=&quot;language-txt&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-txt&quot;&gt;-a   Display all manual pages instead of just
     the first found for each page argument.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, we still don&#39;t really care what this actually does. The lesson here is manoeuvring around the viewer, not understanding all of &lt;code&gt;man&lt;/code&gt;&#39;s options.&lt;/p&gt;
&lt;h2 id=&quot;man-is-less&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;man&lt;/code&gt; is &lt;code&gt;less&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Because &lt;code&gt;man&lt;/code&gt; uses &lt;code&gt;less&lt;/code&gt;. You can prove this by hitting &lt;code&gt;h&lt;/code&gt; to bring up the help.&lt;/p&gt;
&lt;h2 id=&quot;builtin-1&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;BUILTIN(1)&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There&#39;s a small idiosyncrasy if you &lt;code&gt;man cd&lt;/code&gt;. You&#39;ll see the man page for &lt;code&gt;BUILTIN(1)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This is because &lt;code&gt;cd&lt;/code&gt; isn&#39;t considered its own program: it&#39;s so core to everything, it&#39;s built-in to the shell. To see these man pages, type &lt;code&gt;man zshbuiltins&lt;/code&gt;.&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot; id=&quot;fnref4&quot;&gt;[4]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;now-you-can-view-anything&quot; tabindex=&quot;-1&quot;&gt;Now you can view anything &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Check the man pages for stuff we&#39;ve already seen. Now you can see that &lt;code&gt;man ls&lt;/code&gt; doesn&#39;t have that weird &lt;code&gt;ls-F&lt;/code&gt; thing going on.&lt;/p&gt;
&lt;p&gt;Get comfortable with this and we&#39;ll move on. Start browsing and searching some of your own plain text files using &lt;code&gt;less&lt;/code&gt;.&lt;/p&gt;
&lt;hr class=&quot;footnotes-sep&quot;&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn1&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;A better writer would have had this in mind when they titled this post. &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn2&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Apparently there&#39;s an even better version called &lt;code&gt;most&lt;/code&gt;, but a) we don&#39;t need it, and b) it&#39;s not installed by default. &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn3&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;If you&#39;re following along at home and you don&#39;t have a plain text file handy, you can launch &lt;code&gt;less --help&lt;/code&gt; and use the help file to practice navigation. &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn4&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;This one is obviously specific to the more modern &lt;strong&gt;zsh&lt;/strong&gt; vs. &lt;strong&gt;bash&lt;/strong&gt;. &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/15-less-is-more/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
	</entry>
	
	<entry>
		<title>drwxr-xr-x</title>
		<link href="https://commandline.johnnydecimal.com/learn/14-drwxr-xr-x/"/>
		<updated>2024-06-06T08:38:54Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/14-drwxr-xr-x/</id>
		<content type="html">&lt;p&gt;Interesting podcast excerpt, thanks. It&#39;s good to know about Macs having a different approach to case than other systems. Seems to me if we&#39;re going to err, it should be on the side of precision—so I&#39;ll play it safe by treating everything as case sensitive from now on.&lt;/p&gt;
&lt;p&gt;Thanks for explaining the &lt;code&gt;ttys000&lt;/code&gt;. I figured it wasn&#39;t something I &lt;em&gt;needed&lt;/em&gt; to know, but having that confirmed saves me from the distraction of wondering what it is every time I see it.&lt;/p&gt;
&lt;p&gt;Just to check, I opened another window and yep, it said &lt;code&gt;ttys001&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I played with &lt;code&gt;ls -la&lt;/code&gt; for different locations on my hard drive, and the &lt;code&gt;--color=always&lt;/code&gt; one, too. The latter produced mostly one colour, with splashes of another here and there. I suppose we&#39;ll get to the logic behind that later, if it&#39;s important enough to discuss.&lt;/p&gt;
&lt;p&gt;When displaying &lt;code&gt;ls -la&lt;/code&gt; there&#39;s a column on the left with information like &lt;code&gt;drwxr-xr-x@&lt;/code&gt; that I don&#39;t understand.&lt;/p&gt;
&lt;p&gt;As with the colour, we&#39;ll either get to that later or it&#39;ll turn out to be something else I don&#39;t need to worry about.&lt;/p&gt;
&lt;p&gt;Referring to the &lt;code&gt;ls&lt;/code&gt; information at &lt;a href=&quot;https://ss64.com/mac/ls.html&quot;&gt;ss64.com/mac/ls.html&lt;/a&gt;, I tried &lt;code&gt;ls-F&lt;/code&gt; as a shorter way of writing &lt;code&gt;ls -F&lt;/code&gt;, but it returned an error: &lt;code&gt;zsh: command not found: ls-F&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Okay. Commands, flags and options, arguments, in that order. Got it.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Flags and options</title>
		<link href="https://commandline.johnnydecimal.com/learn/13-flags-and-options/"/>
		<updated>2024-06-06T00:35:58Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/13-flags-and-options/</id>
		<content type="html">&lt;p&gt;We almost understand the syntax of a command. To recap, we&#39;ve met the &lt;strong&gt;command&lt;/strong&gt;, and its (often optional) &lt;strong&gt;arguments&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Now let&#39;s meet &lt;strong&gt;flags&lt;/strong&gt; and &lt;strong&gt;options&lt;/strong&gt;, which are two sides of the same coin.&lt;/p&gt;
&lt;h2 id=&quot;behaviour-modifiers&quot; tabindex=&quot;-1&quot;&gt;Behaviour modifiers &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Flags modify the behaviour of a command. Let&#39;s try one out.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That&#39;s a dash/hyphen, then a lowercase letter &#39;ell&#39;.&lt;/p&gt;
&lt;p&gt;Try the un-flagged &lt;code&gt;ls&lt;/code&gt; and then &lt;code&gt;ls -l&lt;/code&gt; and compare the output. The flagged variant gives you a &lt;em&gt;longer&lt;/em&gt; output; more detailed.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;l&lt;/code&gt; stands for &lt;code&gt;l&lt;/code&gt;ong. We&#39;ve said to &lt;code&gt;ls&lt;/code&gt; &lt;em&gt;please exercise your ability to give us a longer output&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Let&#39;s try another.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-a&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There&#39;s &lt;em&gt;more&lt;/em&gt; stuff here: depending on your system you might see &lt;code&gt;.DS_store&lt;/code&gt;, &lt;code&gt;.localized&lt;/code&gt;, and look carefully: our &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/#and-also-have-special-meaning&quot;&gt;friends&lt;/a&gt; &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;..&lt;/code&gt; are now shown.&lt;/p&gt;
&lt;p&gt;By default, some system-level stuff is hidden from a basic &lt;code&gt;ls&lt;/code&gt;. But &lt;code&gt;a&lt;/code&gt; is short for &lt;code&gt;a&lt;/code&gt;ll: you&#39;re asking &lt;code&gt;ls&lt;/code&gt; to &lt;em&gt;show you all the things&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&quot;combining-flags&quot; tabindex=&quot;-1&quot;&gt;Combining flags &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can ask &lt;code&gt;ls&lt;/code&gt; for both things.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-a&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note the order doesn&#39;t matter. But that&#39;s clunky. Dash-l, dash-a. It&#39;d be nicer if we could combine them...&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-la&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This pattern -- &lt;code&gt;ls -la&lt;/code&gt; -- is so common that many people make it their default. We&#39;ll see how to do that later. I just type it instinctively, it&#39;s seared in to my muscle-memory.&lt;/p&gt;
&lt;h2 id=&quot;you-can-still-specify-an-argument-s&quot; tabindex=&quot;-1&quot;&gt;You can still specify an argument(s) &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let&#39;s combine everything we know.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-la&lt;/span&gt; ~/Downloads&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If that doesn&#39;t make you want to clean up that folder, nothing will.&lt;/p&gt;
&lt;p&gt;(We&#39;ll go in to more detail about what &lt;code&gt;ls -l&lt;/code&gt; is showing you later.)&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;conventions&quot; tabindex=&quot;-1&quot;&gt;Conventions &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;There are well-held conventions that are used here. They aren&#39;t hard rules -- developers can and do break them -- but if you use them as a guide you won&#39;t go far wrong.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;command&lt;/strong&gt; always comes first. That is a hard rule.&lt;/p&gt;
&lt;p&gt;Then &lt;strong&gt;flags&lt;/strong&gt; come next. A convention, very widely held. I can&#39;t think of an example where it isn&#39;t the case.&lt;/p&gt;
&lt;p&gt;Then lastly, the &lt;strong&gt;arguments&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;  &lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-la&lt;/span&gt; ~/Desktop
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# │   │  └─ argument(s)&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# │   └──── flag(s)&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# └──────── command&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;flags-as-words&quot; tabindex=&quot;-1&quot;&gt;Flags-as-words &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;-l&lt;/code&gt; isn&#39;t very expressive, and there are only 26 letters of the alphabet. So full-word flags are also totally normal.&lt;/p&gt;
&lt;p&gt;And here&#39;s a well-held convention that I &lt;em&gt;do&lt;/em&gt; see broken: full-word flags should start with &lt;strong&gt;two dashes&lt;/strong&gt;.&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot; id=&quot;fnref1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--color&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;always&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;and-this-is-now-an-option&quot; tabindex=&quot;-1&quot;&gt;...and this is now an option &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I just realised that we&#39;ve moved from a &lt;strong&gt;flag&lt;/strong&gt; to an &lt;strong&gt;option&lt;/strong&gt;. Do you know why?&lt;/p&gt;
&lt;p&gt;Flags are either there or not. On or off. I imagine the analogy is to a raised flag: up, or down.&lt;/p&gt;
&lt;p&gt;Options have more data. What&#39;s with &lt;code&gt;=always&lt;/code&gt;? Well, the other options are &lt;code&gt;=auto&lt;/code&gt; or &lt;code&gt;=none&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can think of this as an argument &lt;em&gt;to the option&lt;/em&gt;. We&#39;ll see a lot more of this as we go on so don&#39;t worry too much about this for now.&lt;/p&gt;
&lt;h2 id=&quot;all-together-now&quot; tabindex=&quot;-1&quot;&gt;All together now &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;As you might imagine, you can mash all of this together.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-la&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--color&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;always ~/Downloads&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h1 id=&quot;everything-is-just-a-variety-of-this&quot; tabindex=&quot;-1&quot;&gt;Everything is just a variety of this &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;First the &lt;strong&gt;command&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Then all of the &lt;strong&gt;flags and options&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;And finally any &lt;strong&gt;arguments&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;That&#39;s the basic structure of every command.&lt;/p&gt;
&lt;h2 id=&quot;homework&quot; tabindex=&quot;-1&quot;&gt;Homework &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;man page&lt;/strong&gt; for &lt;code&gt;ls&lt;/code&gt; is &lt;a href=&quot;https://ss64.com/mac/ls.html&quot;&gt;online here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Try a bunch more options and see what you can get &lt;code&gt;ls&lt;/code&gt; to produce. Soon, I&#39;ll show you how to bring these &lt;strong&gt;man(ual) pages&lt;/strong&gt; up directly in Terminal.&lt;/p&gt;
&lt;hr class=&quot;footnotes-sep&quot;&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn1&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Looking at you, &lt;a href=&quot;https://ss64.com/mac/dscacheutil.html&quot;&gt;Apple&lt;/a&gt;. &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/13-flags-and-options/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
	</entry>
	
	<entry>
		<title>Case-sensitivity, ttys, and the prompt</title>
		<link href="https://commandline.johnnydecimal.com/learn/12-case-and-ttys/"/>
		<updated>2024-06-05T23:41:53Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/12-case-and-ttys/</id>
		<content type="html">&lt;h2 id=&quot;case-sensitivity&quot; tabindex=&quot;-1&quot;&gt;Case-sensitivity &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/12-case-and-ttys/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ellane&lt;/strong&gt;&lt;br&gt;
Question: is case important?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I didn&#39;t know you could do that thing with &lt;code&gt;cd desktop&lt;/code&gt;. I find that a little weird and surprising.&lt;/p&gt;
&lt;p&gt;Traditionally, &lt;a href=&quot;https://en.wikipedia.org/wiki/Unix-like&quot;&gt;*nix&lt;/a&gt; systems &lt;em&gt;are&lt;/em&gt; case-sensitive.&lt;/p&gt;
&lt;p&gt;Your Mac is not. It could be, but it isn&#39;t. There was a really good discussion on ATP recently: check &lt;a href=&quot;https://atp.fm/583&quot;&gt;episode 583&lt;/a&gt; at &lt;code&gt;1:12:10&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pretend like it is and you won&#39;t go far wrong.&lt;/p&gt;
&lt;h2 id=&quot;ttys&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;ttys&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/12-case-and-ttys/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ellane&lt;/strong&gt;&lt;br&gt;
One more question: what&#39;s &lt;code&gt;ttys000&lt;/code&gt;?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/#history-lesson&quot;&gt;When Terminals were the whole computer&lt;/a&gt;, they each had an ID. Just like your computer has a name.&lt;/p&gt;
&lt;p&gt;When you launch a new Terminal window, it gets an identifier in the same way. Because you can launch &lt;em&gt;another&lt;/em&gt; Terminal window, and be running commands in each.&lt;/p&gt;
&lt;p&gt;Your system needs to know which command belongs to which window. So that&#39;s what &lt;code&gt;ttys000&lt;/code&gt; is.&lt;/p&gt;
&lt;p&gt;Fun fact: &lt;code&gt;ttys&lt;/code&gt; is short for &lt;code&gt;t&lt;/code&gt;ele&lt;code&gt;ty&lt;/code&gt;per &lt;code&gt;s&lt;/code&gt;ecure. There&#39;s a &lt;a href=&quot;https://thehistoryofcomputing.net/the-teletype-and-tty&quot;&gt;great history lesson here&lt;/a&gt; -- this stuff goes back &lt;em&gt;centuries&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;We&#39;ll talk about this more &lt;a href=&quot;https://commandline.johnnydecimal.com/about/#later&quot;&gt;later&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;the-prompt&quot; tabindex=&quot;-1&quot;&gt;The prompt &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/12-case-and-ttys/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ellane&lt;/strong&gt;&lt;br&gt;
And why the &lt;code&gt;%&lt;/code&gt; sign? I seem to remember a &lt;code&gt;$&lt;/code&gt; sign being there last time.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is just a style thing.&lt;/p&gt;
&lt;p&gt;Until recently, the language that you were using in your Terminal was &lt;a href=&quot;https://en.wikipedia.org/wiki/Bash_(Unix_shell)&quot;&gt;&lt;strong&gt;bash&lt;/strong&gt;&lt;/a&gt;. The default &#39;prompt&#39; for bash is &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A couple of macOS versions ago they switched to &lt;a href=&quot;https://en.wikipedia.org/wiki/Z_shell&quot;&gt;&lt;strong&gt;zsh&lt;/strong&gt;&lt;/a&gt;, which is more modern. Its default prompt is &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;sh&lt;/strong&gt; part of both of those is short for &#39;shell&#39;. The original shell was just called &lt;strong&gt;sh&lt;/strong&gt;! &lt;a href=&quot;https://en.wikipedia.org/wiki/Unix_shell&quot;&gt;Wikipedia&lt;/a&gt; has a nice overview.&lt;/p&gt;
&lt;p&gt;We won&#39;t use any zsh-specific stuff in this tutorial. And unless they say otherwise, all of the commands you&#39;ll find online that tell you how to install a thing will work in both shells.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>A question of case</title>
		<link href="https://commandline.johnnydecimal.com/learn/11-a-question-of-case/"/>
		<updated>2024-06-04T07:45:26Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/11-a-question-of-case/</id>
		<content type="html">&lt;p&gt;I successfully &lt;code&gt;cd&lt;/code&gt;d to &lt;code&gt;&amp;quot;A_folder_in_quotes&amp;quot;&lt;/code&gt; by typing &lt;code&gt;cd &#92;&amp;quot;A&lt;/code&gt; and then pressing &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Then I navigated to a folder with word spaces inside my Obsidian vault, which is nestled four folders deep (don&#39;t judge), and pressed &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; to auto complete its name, which is &lt;code&gt;ALL THE NOTES&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Terminal completed the string like this: &lt;code&gt;cd ALL&#92; THE&#92; NOTES&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If I was typing it I&#39;d have initially thought to put the backslash close to the next word, but now I can see that it&#39;s immediately preceding the word space, which is the thing we need to escape.&lt;/p&gt;
&lt;h2 id=&quot;this-that&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;this&#92;that&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/11-a-question-of-case/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I tried to &lt;code&gt;cd&lt;/code&gt; to the this/that folder two ways: &lt;code&gt;cd this&#92;/that&lt;/code&gt; didn&#39;t work (and I don&#39;t know why), while &lt;code&gt;cd &amp;quot;this/that&amp;quot; &lt;/code&gt; did.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Johnny: Look at this one more closely!&lt;/p&gt;
&lt;p&gt;It should be &lt;code&gt;this&#92;that&lt;/code&gt; — the same backslash that you use for the escape character.&lt;/p&gt;
&lt;p&gt;The puzzle is: how do you include the escape character in an argument &lt;em&gt;if it&#39;s the escape character?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Classic error! Okay, I&#39;ve named the folder correctly now. The answer is, you use two of them: &lt;code&gt;cd this&#92;&#92;that&lt;/code&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;is-case-important&quot; tabindex=&quot;-1&quot;&gt;Is case important? &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/11-a-question-of-case/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Question: is case important? It doesn&#39;t seem to be. I&#39;ve noticed that &lt;code&gt;cd Desktop&lt;/code&gt; returns &lt;code&gt;ellane@macbook-pro Desktop % &lt;/code&gt;, while &lt;code&gt;cd desktop&lt;/code&gt; returns &lt;code&gt;ellane@macbook-pro desktop %&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It&#39;s the same location each time, so I&#39;ll assume location names aren&#39;t case sensitive unless you tell me otherwise.&lt;/p&gt;
&lt;h2 id=&quot;what-s-a-tty&quot; tabindex=&quot;-1&quot;&gt;What&#39;s a tty? &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/11-a-question-of-case/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;One more question: what&#39;s &lt;code&gt;ttys000&lt;/code&gt;? And why the &lt;code&gt;%&lt;/code&gt; sign? I seem to remember a &lt;code&gt;$&lt;/code&gt; sign being there last time.&lt;/p&gt;
&lt;pre class=&quot;language-txt&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-txt&quot;&gt;Last login: Mon Jun 3 13:29:54 on ttys000
ellane@macbook-pro ~ %&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&#39;s good to learn the why behind things that look different to my GUI-trained eyes.&lt;/p&gt;
&lt;p&gt;I used to view things like slashes that went the wrong way and underscores between words as tech-virtue signalling: We&#39;re More Technical and Clever Than You So We Wrap Things In Extra Bits Because We Can. Seems silly now!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Escape arguments, completely</title>
		<link href="https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/"/>
		<updated>2024-06-03T20:59:57Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/</id>
		<content type="html">&lt;p&gt;Let&#39;s use these annoying spaces to go a little deeper on the concept of &lt;strong&gt;arguments&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;We&#39;ve already met them. We have a &lt;strong&gt;command&lt;/strong&gt; which is &lt;em&gt;optionally&lt;/em&gt; followed by an &lt;strong&gt;argument&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/Desktop
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# └─┬─────┘&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#   the argument&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Command: &lt;code&gt;cd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Argument: &lt;code&gt;~/Desktop&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Arguments are sometimes called &lt;strong&gt;parameters&lt;/strong&gt;. If the command is the thing that &lt;em&gt;does a thing&lt;/em&gt;, the argument is the &lt;em&gt;thing it does it to&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; &lt;em&gt;to where&lt;/em&gt;?&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; &lt;em&gt;which folder&lt;/em&gt;?&lt;/p&gt;
&lt;p&gt;So far we&#39;ve seen zero- and one-argument commands. But many commands can take multiple arguments; many commands &lt;em&gt;need&lt;/em&gt; multiple arguments.&lt;/p&gt;
&lt;p&gt;Think about copying a file: you have to know &lt;em&gt;which file to copy&lt;/em&gt; and then &lt;em&gt;where to copy it to&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Two arguments. And we separate them by ... you guessed it ... a space.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; will accept more than one argument. Just give it more than one folder to list.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; ~/Desktop ~/Downloads
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# └─┬─────┘ └─┬───────┘&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#   first     second&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Command: &lt;code&gt;ls&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;First argument: &lt;code&gt;~/Desktop&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Second argument: &lt;code&gt;~/Downloads&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So now it should be obvious why trying to list out a folder with a space in its name doesn&#39;t work. The CLI doesn&#39;t know that it&#39;s one folder: actually, you gave it two arguments, and neither is the name of a folder!&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;how-to-escape-this-problem&quot; tabindex=&quot;-1&quot;&gt;How to &#39;escape&#39; this problem &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This is obviously a very common issue. The solution is a technique called &lt;strong&gt;escaping&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;When we escape a character, we&#39;re telling the CLI: &lt;em&gt;treat the next character as exactly what it is&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;So if it&#39;s a space, just &lt;em&gt;be a space&lt;/em&gt;. Don&#39;t be &lt;em&gt;the boundary between two arguments&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The escape character in your CLI&#39;s language is &lt;code&gt;&#92;&lt;/code&gt;. Put a backslash before any character to &#39;escape it&#39;.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#   one argument&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# ┌─┴───────────────────┐&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; My&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt; great&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt; folder&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt; name
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#   ^      ^       ^&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#  escape characters&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;not-just-spaces&quot; tabindex=&quot;-1&quot;&gt;Not just spaces &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Create a folder on your Desktop called &lt;code&gt;&amp;quot;A_folder_in_quotes&amp;quot;&lt;/code&gt; and see if you can &lt;code&gt;cd&lt;/code&gt; to it.&lt;/p&gt;
&lt;p&gt;You&#39;ll need to escape those double-quote characters.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/Desktop/&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;&quot;A_folder_in_quotes&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;&quot;
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#           ^                   ^&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#           the escape characters&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&#39;s ugly. You never get used to it; you just have to learn to live with it.&lt;/p&gt;
&lt;h2 id=&quot;remember-any-character&quot; tabindex=&quot;-1&quot;&gt;Remember, &lt;em&gt;any&lt;/em&gt; character &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It&#39;s worth reinforcing that this works before &lt;em&gt;any&lt;/em&gt; character. Not just special characters.&lt;/p&gt;
&lt;p&gt;So in our continuing series of it-works-but-you&#39;d-never-actually-do-it, this is perfectly valid.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;D&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;k&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;t&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;p&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You&#39;re saying &#39;be a D!&#39;, &#39;be an e!&#39;, &#39;be an s!&#39; ... but that&#39;s what they were anyway. So nothing changes.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;tab-completion-saves-the-day&quot; tabindex=&quot;-1&quot;&gt;Tab completion saves the day &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;You&#39;ll drive yourself mad -- and get it wrong very, very often -- if you try to manually escape your file paths. Fortunately, there&#39;s an easier way.&lt;/p&gt;
&lt;p&gt;The CLI will &lt;strong&gt;auto-complete&lt;/strong&gt; a file path for you if you press the &lt;code&gt;tab&lt;/code&gt; key. I&#39;ll denote that as &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; in these code blocks.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/A&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;tab&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There&#39;s only one folder in my home folder that starts &lt;code&gt;A&lt;/code&gt;, and it&#39;s &lt;code&gt;Applications&lt;/code&gt;. Hitting &lt;code&gt;tab&lt;/code&gt; autocompletes it for me.&lt;/p&gt;
&lt;p&gt;Note that it &lt;em&gt;doesn&#39;t&lt;/em&gt; press &lt;code&gt;return&lt;/code&gt; for you. It doesn&#39;t run the command: you might have more to type before you&#39;re ready for that.&lt;/p&gt;
&lt;h2 id=&quot;multiple-results&quot; tabindex=&quot;-1&quot;&gt;Multiple results &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;On this Mac, I&#39;ve got five folders in my home folder that start with &lt;code&gt;D&lt;/code&gt;: &lt;code&gt;Databases&lt;/code&gt;, &lt;code&gt;Desktop&lt;/code&gt;, &lt;code&gt;Documents&lt;/code&gt;, &lt;code&gt;Downloads&lt;/code&gt;, and &lt;code&gt;dev&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So try that:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/D&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;tab&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your CLI will show you the possibilities. Now you can do two things.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Type some more characters to disambiguate your intent, and hit &lt;code&gt;tab&lt;/code&gt; again.&lt;/li&gt;
&lt;li&gt;Mash the &lt;code&gt;tab&lt;/code&gt; key and watch it cycle through all the options for you. Stop when it reaches the one you want.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Pretty cool!&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot; id=&quot;fnref1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;h2 id=&quot;what-s-this-got-to-do-with-spaces&quot; tabindex=&quot;-1&quot;&gt;What&#39;s this got to do with spaces? &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Try tab completion on a folder with a space in it and find out. :-)&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;homework&quot; tabindex=&quot;-1&quot;&gt;Homework &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;h2 id=&quot;1-a-folder-in-quotes&quot; tabindex=&quot;-1&quot;&gt;1. &lt;code&gt;&amp;quot;A folder in quotes&amp;quot;&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Make sure you can &lt;code&gt;cd&lt;/code&gt; in to &lt;code&gt;&amp;quot;A folder in quotes&amp;quot;&lt;/code&gt;. Note the spaces in this version.&lt;/p&gt;
&lt;p&gt;You might have to escape something yourself to get started, but as soon as you can you should use tab completion to finish the job.&lt;/p&gt;
&lt;h2 id=&quot;2-this-that&quot; tabindex=&quot;-1&quot;&gt;2. &lt;code&gt;this&#92;that&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Using Finder, create a folder on your Desktop called &lt;code&gt;this&#92;that&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now, &lt;em&gt;without using tab completion&lt;/em&gt;, try to &lt;code&gt;cd&lt;/code&gt; to it.&lt;/p&gt;
&lt;h2 id=&quot;3-too-much-escaping&quot; tabindex=&quot;-1&quot;&gt;3. Too much escaping &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Earlier, we saw that this worked.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;D&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;k&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;t&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;p&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But this does &lt;em&gt;not&lt;/em&gt; work. Why?&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;~/&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;D&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;k&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;t&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;p
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# ^ extra escape character here&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr class=&quot;footnotes-sep&quot;&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn1&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;For extra nerd points think about how easy this might make navigating a Johnny.Decimal hierarchy... &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/10-escape-arguments-completely/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
	</entry>
	
	<entry>
		<title>It does not like spaces</title>
		<link href="https://commandline.johnnydecimal.com/learn/09-it-does-not-like-spaces/"/>
		<updated>2024-06-03T06:39:02Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/09-it-does-not-like-spaces/</id>
		<content type="html">&lt;p&gt;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 saw a &lt;code&gt;zsh: permission denied&lt;/code&gt; message.&lt;/p&gt;
&lt;p&gt;This was puzzling until I realised I’d forgotten to preface the path with a command!&lt;/p&gt;
&lt;p&gt;Something else I’ve noticed is that the CLI does &lt;em&gt;not&lt;/em&gt; like word spaces. It returns a &lt;code&gt;too many arguments&lt;/code&gt; message any time I try to access a folder with a multiple-word name.&lt;/p&gt;
&lt;p&gt;Is there any way around that, or do I have to rename_everything_to_remove_word_spaces?&lt;/p&gt;
&lt;p&gt;Rather than renaming, I looked for paths with locations that were one word only and was able to &lt;code&gt;ls&lt;/code&gt; the contents of the parent folder of the directory I was looking at.&lt;/p&gt;
&lt;p&gt;So far so good.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>File paths</title>
		<link href="https://commandline.johnnydecimal.com/learn/08-file-paths/"/>
		<updated>2024-06-01T06:34:46Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/08-file-paths/</id>
		<content type="html">&lt;p&gt;You stumbled in to a &lt;a href=&quot;https://thenewstack.io/how-do-you-exit-vim-a-newbie-question-turned-tech-meme/&quot;&gt;meme&lt;/a&gt;! What are the odds.&lt;/p&gt;
&lt;p&gt;We&#39;ll come back to &lt;code&gt;vim&lt;/code&gt;, which it turns out you can also launch by typing &lt;code&gt;view&lt;/code&gt; (I had no idea!), much later.&lt;/p&gt;
&lt;p&gt;But for now, yes, that&#39;s a valuable lesson. There are many situations where guessing a thing is a good idea. The CLI is not one of them.&lt;/p&gt;
&lt;p&gt;(I might ask you to guess things, like &lt;code&gt;cd Documents&lt;/code&gt;, where I&#39;m pretty sure you&#39;re not going to accidentally wipe your hard drive.)&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;cd-ing-to-a-nested-folder&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;cd&lt;/code&gt;&#39;ing to a nested folder &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;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&#39;s go a bit deeper.&lt;/p&gt;
&lt;p&gt;We&#39;ll need a subfolder, which it sounds like you have. But to keep this example simple I&#39;m going to get you to create one on your Desktop; then people following along at home can use the same commands.&lt;/p&gt;
&lt;p&gt;So, using the Mac Finder, create a folder called &lt;code&gt;TestFolder&lt;/code&gt; on your Desktop. Note the lack of a space between the words.&lt;/p&gt;
&lt;h2 id=&quot;the-forward-slash&quot; tabindex=&quot;-1&quot;&gt;The &lt;code&gt;/&lt;/code&gt; forward slash &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is the long way around:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# takes you home if you&#39;re not already there&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; Desktop
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; TestFolder&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;That &lt;code&gt;# takes you home...&lt;/code&gt; bit in grey is a comment. Don&#39;t type that bit, including the first backtick. I&#39;ll use these to add comments to specific lines, or to show you what output to expect.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Or you can do it in a single step by using the &lt;code&gt;/&lt;/code&gt; forward-slash, which separates subfolders.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; Desktop/TestFolder&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your prompt should update, and &lt;code&gt;pwd&lt;/code&gt; will show you where you are.&lt;/p&gt;
&lt;h2 id=&quot;specify-my-home-folder&quot; tabindex=&quot;-1&quot;&gt;Specify &#39;my home folder&#39; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;We know that &lt;code&gt;Desktop&lt;/code&gt; is in our home folder. But we might not be there already, so we have that annoying first &lt;code&gt;cd&lt;/code&gt; to take us there.&lt;/p&gt;
&lt;p&gt;We can skip this by using the shortcut for &lt;em&gt;my home folder&lt;/em&gt; which is &lt;code&gt;~&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/Desktop/TestFolder&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a common shortcut that you&#39;ll see in online instructions. It&#39;s handy because the person writing doesn&#39;t need to know where your home folder is: &lt;code&gt;~&lt;/code&gt; is universal. Keep an eye out for it.&lt;/p&gt;
&lt;h2 id=&quot;and-also-have-special-meaning&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;.&lt;/code&gt; and &lt;code&gt;..&lt;/code&gt; also have special meaning &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A single &lt;code&gt;.&lt;/code&gt; in a file path means &lt;em&gt;the folder that I&#39;m currently in&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;So this works. It&#39;s not useful here, but later we&#39;ll see where we do use this.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/Desktop
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ./TestFolder
&lt;span class=&quot;token builtin class-name&quot;&gt;pwd&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# /Users/ellane/Desktop/TestFolder&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Two periods &lt;code&gt;..&lt;/code&gt; means &lt;em&gt;the parent folder&lt;/em&gt;. You use this one all the time.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/Desktop/TestFolder
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;pwd&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# /Users/ellane/Desktop&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;this-works-everywhere&quot; tabindex=&quot;-1&quot;&gt;This works everywhere &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can use all of these wherever you&#39;d type a file path; it&#39;s not just a &lt;code&gt;cd&lt;/code&gt; thing.&lt;/p&gt;
&lt;p&gt;So you can &lt;code&gt;ls ~/Downloads/some/other/folder&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;you-can-combine-all-of-this&quot; tabindex=&quot;-1&quot;&gt;You can combine all of this &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This crazy thing works. You&#39;d never do it, but it works.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; ~/&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;/john/Desktop/TestFolder/&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;/&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;/././Downloads
&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# lists the chaos of my Downloads folder&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that my username is &lt;code&gt;john&lt;/code&gt;. Substitute for yours: if you&#39;re not sure what it is, &lt;code&gt;whoami&lt;/code&gt; 🟢 will show it. In these lessons I assume it&#39;s &lt;code&gt;ellane&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Make sure you understand &lt;em&gt;why&lt;/em&gt; this works. Make some of your own crazy file paths just for practice.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;relative-vs-absolute-paths&quot; tabindex=&quot;-1&quot;&gt;Relative vs. absolute paths &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;File paths can be &lt;strong&gt;relative&lt;/strong&gt; or they can be &lt;strong&gt;absolute&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If they&#39;re relative, they&#39;re relative to &lt;em&gt;where you are&lt;/em&gt;. This is what we&#39;ve seen so far.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; Desktop &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# relative to your current location&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These are usually shorter and more convenient. But they can go wrong: someone might assume you&#39;re in folder A, and tell you to issue some instruction that includes a relative file path.&lt;/p&gt;
&lt;p&gt;But if you&#39;re actually in folder B, the results are unpredictable.&lt;/p&gt;
&lt;p&gt;So we can specify &lt;strong&gt;absolute&lt;/strong&gt; file paths that work &lt;em&gt;regardless of where you are&lt;/em&gt;. We&#39;ve already seen one.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/Desktop
&lt;span class=&quot;token builtin class-name&quot;&gt;pwd&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# /Users/ellane/Desktop&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt; always reports an absolute file path.&lt;/p&gt;
&lt;h2 id=&quot;users-ellane-desktop&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;/Users/ellane/Desktop&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let&#39;s look at this in detail.&lt;/p&gt;
&lt;p&gt;The first thing to note is that it &lt;em&gt;starts&lt;/em&gt; with a forward-slash. This is another special character: at the beginning of a file path, it means &lt;em&gt;the top of my file system&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Try this.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; /&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Seem familiar? Before you move on, see if you can find this same location in a Finder window.&lt;/p&gt;
&lt;p&gt;You&#39;re looking at a listing of what we call the &lt;strong&gt;root&lt;/strong&gt; of your file system.&lt;/p&gt;
&lt;p&gt;In Finder, it&#39;s what you see if you open the &lt;strong&gt;Macintosh HD&lt;/strong&gt; view.&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot; id=&quot;fnref1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt; Or from your home folder, you can &lt;code&gt;Command-up arrow&lt;/code&gt; twice.&lt;/p&gt;
&lt;p&gt;In Finder, &lt;code&gt;Command-up arrow&lt;/code&gt; takes you up to the parent folder. So if you compare this view to &lt;code&gt;/Users/ellane&lt;/code&gt; -- the absolute path to your home folder -- it should make sense.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The first &lt;code&gt;Command-up arrow&lt;/code&gt; is like typing &lt;code&gt;cd ..&lt;/code&gt;, and takes you to &lt;code&gt;/Users&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The second does the same again, and takes you to &lt;code&gt;/&lt;/code&gt;. The root of your file system.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Absolute paths basically always start with a &lt;code&gt;/&lt;/code&gt;. I&#39;m sure there&#39;s an exception, but if you have that in mind, you won&#39;t go far wrong.&lt;/p&gt;
&lt;p&gt;That slash says, &lt;em&gt;regardless of where you are, go back to the top&lt;/em&gt;. It&#39;s very powerful.&lt;/p&gt;
&lt;h2 id=&quot;keep-playing&quot; tabindex=&quot;-1&quot;&gt;Keep playing &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Of course all of this is interlinked.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; /Users/./ellane/&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;/ellane/Desktop/TestFolder/&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Again, absurd, but you get the idea.&lt;/p&gt;
&lt;h2 id=&quot;the-shared-user&quot; tabindex=&quot;-1&quot;&gt;The &lt;code&gt;shared&lt;/code&gt; user &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Note that there&#39;s another user on your Mac whose home folder is at &lt;code&gt;/Users/Shared&lt;/code&gt; if you want to play around with more paths.&lt;/p&gt;
&lt;h2 id=&quot;this-is-an-exact-science&quot; tabindex=&quot;-1&quot;&gt;This is an exact science &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Pay attention to how you see file paths written online. You will never, ever see someone specify &lt;code&gt;Users/Shared&lt;/code&gt;. Because that&#39;s a relative path.&lt;/p&gt;
&lt;p&gt;If your current directory just happens to be &lt;code&gt;/&lt;/code&gt; then that&#39;s valid. But it probably isn&#39;t. So it&#39;ll always be specified as &lt;code&gt;/Users/Shared&lt;/code&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;get-super-comfortable-with-this&quot; tabindex=&quot;-1&quot;&gt;Get super comfortable with this &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Simple enough concepts but you need to know these backwards. Just have a good play around and let me know if you find anything interesting.&lt;/p&gt;
&lt;hr class=&quot;footnotes-sep&quot;&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn1&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Assuming you haven&#39;t renamed your drive. &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/08-file-paths/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
	</entry>
	
	<entry>
		<title>The One Where Ellane Launches Vim</title>
		<link href="https://commandline.johnnydecimal.com/learn/07-the-one-where-ellane-launches-vim/"/>
		<updated>2024-06-01T00:33:10Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/07-the-one-where-ellane-launches-vim/</id>
		<content type="html">&lt;p&gt;Okay, this feels like progress!&lt;/p&gt;
&lt;p&gt;I &lt;code&gt;cd&lt;/code&gt;&#39;d myself to the Documents folder on the first go, by typing in &lt;code&gt;cd Documents&lt;/code&gt;, and used &lt;code&gt;ls&lt;/code&gt; 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.&lt;/p&gt;
&lt;p&gt;I tried a number of things to &lt;code&gt;cd&lt;/code&gt; to a specific nested folder, with no luck.&lt;/p&gt;
&lt;p&gt;One of my attempts had an alarming result:&lt;/p&gt;
&lt;p&gt;When I could see the folder I wanted to &lt;code&gt;ls&lt;/code&gt; in the &lt;code&gt;ls&lt;/code&gt; of its parent folder, I typed &lt;code&gt;view [name of folder]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I should have known better than to experiment with unknown commands!&lt;/p&gt;
&lt;p&gt;That gave me a blank page with a &lt;code&gt;1&lt;/code&gt; at the top, and the word &lt;code&gt;Insert&lt;/code&gt; at the bottom. &lt;code&gt;logout&lt;/code&gt; didn&#39;t work, so I committed the press-the-red-dot-to-close-the-window sin.&lt;/p&gt;
&lt;p&gt;No more jumping ahead of the teacher for me!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The structure of a command</title>
		<link href="https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/"/>
		<updated>2024-05-31T06:03:06Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/</id>
		<content type="html">&lt;h2 id=&quot;feedback-on-homework&quot; tabindex=&quot;-1&quot;&gt;Feedback on homework &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Regarding &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/05-close-on-exit/#homework-assignment-part-2&quot;&gt;closing the window vs. typing &lt;code&gt;logout&lt;/code&gt;&lt;/a&gt;, not only does it feel like getting out before putting the car in &#39;park&#39;, it feels like opening the door and jumping out while the car is moving!&lt;/p&gt;
&lt;p&gt;Now, this isn&#39;t what actually happens. When you close the Terminal window, it &lt;strong&gt;sends a signal&lt;/strong&gt; to the CLI, and if something important is happening you&#39;ll be warned about it. It&#39;s like how modern cars lock the doors when you start moving: it makes it difficult (but not impossible) to jump out as you&#39;re hurtling down the motorway.&lt;/p&gt;
&lt;p&gt;I think &lt;a href=&quot;https://monrepos.casa/display/0e03068e-2166-586a-170a-1cd580731423&quot;&gt;Gordon hit the spirit of it&lt;/a&gt;. When you&#39;re in the CLI, &lt;em&gt;that&#39;s where your control is&lt;/em&gt;; that&#39;s where you should be issuing commands.&lt;/p&gt;
&lt;p&gt;This is a Windows (as in Microsoft) vs. Unix mindset. Windows people think in the GUI. Unix people think in the CLI. When you&#39;re doing this stuff, put your CLI hat on.&lt;/p&gt;
&lt;p&gt;We&#39;ll come back to this passing-around-of-signals in the future.&lt;/p&gt;
&lt;h2 id=&quot;tech-support-question&quot; tabindex=&quot;-1&quot;&gt;Tech support question &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For those of you following along at home, Ellane&#39;s Terminal window is responsive again. I &lt;a href=&quot;https://hachyderm.io/@johnnydecimal/112532621902965084&quot;&gt;tooted her a video&lt;/a&gt; of &#39;normal behaviour&#39;, which is exactly what you&#39;d expect: after each command, you can type the next command.&lt;/p&gt;
&lt;p&gt;We&#39;re not sure what was going on there, so we&#39;ll keep an eye on it.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;the-structure-of-a-command&quot; tabindex=&quot;-1&quot;&gt;The structure of a command &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Let&#39;s get to the good stuff.&lt;/p&gt;
&lt;p&gt;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 &lt;em&gt;all commands&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;We know that &lt;code&gt;pie lunch cook&lt;/code&gt; isn&#39;t a valid sentence, even if we&#39;re not a chef.&lt;/p&gt;
&lt;p&gt;And soon you&#39;ll immediately recognise that &lt;code&gt;--food pie &amp;amp;meal lunch cook&lt;/code&gt; couldn&#39;t ever be a valid command: it just doesn&#39;t &lt;em&gt;look&lt;/em&gt; right.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;cook --meal lunch pie&lt;/code&gt;, however: while that &lt;em&gt;isn&#39;t&lt;/em&gt; a valid command, it &lt;em&gt;could be&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&quot;the-first-thing-is-always-the-command&quot; tabindex=&quot;-1&quot;&gt;The first thing is always the command &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The command is the thing that decides what happens. Are you moving, copying, deleting, listing, installing, or printing a thing? It doesn&#39;t matter: &lt;strong&gt;but it comes first&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;And sometimes that&#39;s all there is. We&#39;ve already seen this: &lt;code&gt;printenv&lt;/code&gt;. That was it. That was the command.&lt;/p&gt;
&lt;p&gt;Let&#39;s introduce a few that we&#39;ll actually use.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;command-traffic-lights&quot; tabindex=&quot;-1&quot;&gt;Command traffic lights 🚦 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;When I introduce a new command, I&#39;ll always give it a traffic light:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;🟢 Totally safe. There is nothing you could possibly do that could cause harm.&lt;/li&gt;
&lt;li&gt;🟡 Usually safe. You &lt;em&gt;can&lt;/em&gt; cause harm, but it&#39;s really unlikely.&lt;/li&gt;
&lt;li&gt;🔴 Possibility of harm. I&#39;ll tell you how not to, and you probably won&#39;t, but you &lt;em&gt;could&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;reference-page&quot; tabindex=&quot;-1&quot;&gt;Reference page &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I&#39;ll also create a short entry for each command on the new &lt;a href=&quot;https://commandline.johnnydecimal.com/reference/&quot;&gt;reference&lt;/a&gt; page.&lt;/p&gt;
&lt;p&gt;These will be brief, as every command has its own documentation. We&#39;ll see that later.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;new-command-cd&quot; tabindex=&quot;-1&quot;&gt;New command: &lt;code&gt;cd&lt;/code&gt; 🟢 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Many -- most? -- commands are abbreviations of the thing that they do.&lt;/p&gt;
&lt;p&gt;The shorter the command, the older it likely is. &lt;code&gt;cd&lt;/code&gt; stands for &lt;code&gt;c&lt;/code&gt;hange &lt;code&gt;d&lt;/code&gt;irectory and it&#39;s older than me.&lt;/p&gt;
&lt;p&gt;You can use it with no &lt;strong&gt;arguments&lt;/strong&gt;. I&#39;ll introduce and define these soon. But for now, just type it.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should be underwhelmed! Nothing happened? But actually something did.&lt;/p&gt;
&lt;p&gt;For one, you didn&#39;t get an error. Try garbage -- &lt;code&gt;lksjdfl&lt;/code&gt; -- and see what happens.&lt;/p&gt;
&lt;p&gt;Always pay attention to the &lt;em&gt;output&lt;/em&gt; of a command. Never just assume that it worked. If it didn&#39;t work, it&#39;ll &lt;em&gt;always&lt;/em&gt; tell you.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;new-command-ls&quot; tabindex=&quot;-1&quot;&gt;New command: &lt;code&gt;ls&lt;/code&gt; 🟢 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Try this one.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is short for &lt;code&gt;l&lt;/code&gt;i&lt;code&gt;s&lt;/code&gt;t directory contents. And look at the results: seem familiar?&lt;/p&gt;
&lt;p&gt;Pause here until you know exactly what you&#39;re looking at.&lt;/p&gt;
&lt;h2 id=&quot;guess-this-next-bit&quot; tabindex=&quot;-1&quot;&gt;Guess this next bit &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;So we&#39;re looking at the contents of your home folder. That&#39;s where a Terminal window opens to, by default.&lt;/p&gt;
&lt;p&gt;Let&#39;s &lt;code&gt;c&lt;/code&gt;hange &lt;code&gt;d&lt;/code&gt;irectory. Try to guess how to move in to your &lt;strong&gt;Documents&lt;/strong&gt; folder. Type it in.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; Documents&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Again, it doesn&#39;t look like much happened. But notice two things: first, your &lt;strong&gt;prompt&lt;/strong&gt; has changed. It now has the word &lt;code&gt;Documents&lt;/code&gt; before the &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Second, if you try &lt;code&gt;ls&lt;/code&gt; again, you&#39;ll see the contents of your Documents folder.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Change directory. List the contents. Change directory. List the contents.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is something you do &lt;em&gt;all the time&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&quot;arguments&quot; tabindex=&quot;-1&quot;&gt;Arguments &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You just saw your first &lt;strong&gt;argument&lt;/strong&gt;: &lt;code&gt;Documents&lt;/code&gt; was an argument to the &lt;code&gt;cd&lt;/code&gt; command.&lt;/p&gt;
&lt;p&gt;We&#39;ll go in to this in detail later, I just wanted to briefly note it here.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;new-command-pwd&quot; tabindex=&quot;-1&quot;&gt;New command: &lt;code&gt;pwd&lt;/code&gt; 🟢 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This one stands for &lt;code&gt;p&lt;/code&gt;rint &lt;code&gt;w&lt;/code&gt;orking &lt;code&gt;d&lt;/code&gt;irectory. Try it and see what you get.&lt;/p&gt;
&lt;p&gt;You &lt;code&gt;cd&lt;/code&gt;&#39;d to your Documents folder, so it should say something like&lt;/p&gt;
&lt;pre class=&quot;language-txt&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-txt&quot;&gt;/Users/ellane/Documents&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So you know where you are because your prompt gives you a clue, and if you want to be totally certain, you &lt;code&gt;pwd&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This syntax, with the forward slashes, is very specific. I&#39;ll explain it soon.&lt;/p&gt;
&lt;h2 id=&quot;how-to-get-home&quot; tabindex=&quot;-1&quot;&gt;How to get home &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;c&lt;/code&gt;hanging &lt;code&gt;d&lt;/code&gt;irectory to your home folder is such a common task, there&#39;s a shortcut for it.&lt;/p&gt;
&lt;p&gt;We&#39;ve already seen it. Care to guess?&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; with &lt;strong&gt;no arguments&lt;/strong&gt; takes you home.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;take-yourself-on-a-trip&quot; tabindex=&quot;-1&quot;&gt;Take yourself on a trip 🚗 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/06-the-structure-of-a-command/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Use these commands a bunch until you&#39;re really comfortable with them. See where you can go. And see where you &lt;em&gt;can&#39;t&lt;/em&gt; go.&lt;/p&gt;
&lt;p&gt;You might have some questions about how you move around. Let me know. If not, we&#39;ll keep going.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>How to close the Terminal window on &#39;shell&#39; exit</title>
		<link href="https://commandline.johnnydecimal.com/learn/05-close-on-exit/"/>
		<updated>2024-05-31T03:27:44Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/05-close-on-exit/</id>
		<content type="html">&lt;h2 id=&quot;homework-assignment-part-1&quot; tabindex=&quot;-1&quot;&gt;Homework assignment part 1 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/05-close-on-exit/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Figure out how to make it so that when you type &lt;code&gt;logout&lt;/code&gt;, the window closes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I poked around in &lt;strong&gt;Settings&lt;/strong&gt;, and found an option under &lt;strong&gt;Shell&lt;/strong&gt; called &lt;strong&gt;When the shell exits&lt;/strong&gt;. The default behaviour was &lt;strong&gt;Don’t close the window&lt;/strong&gt;, which was just the clue I needed!&lt;/p&gt;
&lt;p&gt;As I’d hoped, &lt;strong&gt;Close the window&lt;/strong&gt; was also an option in the drop down list.&lt;/p&gt;
&lt;h2 id=&quot;homework-assignment-part-2&quot; tabindex=&quot;-1&quot;&gt;Homework assignment part 2 &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/05-close-on-exit/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Why doesn’t Johnny like closing the window with the red button?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Is it like leaving the car in a gear other than Park before turning it off?&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;a-tech-support-question&quot; tabindex=&quot;-1&quot;&gt;A tech support question &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/05-close-on-exit/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This lesson also brought up one of the frustrations I’ve faced in the past when trying to use Terminal.&lt;/p&gt;
&lt;p&gt;I’ve pasted in the string I was given (in this case, &lt;code&gt;printenv&lt;/code&gt;), pressed &lt;code&gt;Enter&lt;/code&gt;, and a process completed successfully. I then wanted to do something else, but nothing I typed showed up on the screen, even though there was a blinking cursor.&lt;/p&gt;
&lt;p&gt;What am I missing? Surely the answer isn’t to close the window and open a new one, is it, but if so, why?&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Let me show you around your new car</title>
		<link href="https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/"/>
		<updated>2024-05-30T02:55:39Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/</id>
		<content type="html">&lt;p&gt;Oh good analogy! That&#39;s going to be helpful.&lt;/p&gt;
&lt;p&gt;Learning &#39;the command line&#39; is like learning how to drive. But before we can drive, we need a vehicle.&lt;/p&gt;
&lt;p&gt;Let me show you around your new car.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Before we start, to save me some typing let&#39;s introduce a shortcut for &#39;the command line&#39;: &lt;strong&gt;CLI&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It stands for &lt;strong&gt;command-line interface&lt;/strong&gt;. I&#39;ll use it from now on.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
&lt;h1 id=&quot;terminal&quot; tabindex=&quot;-1&quot;&gt;Terminal &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;You can&#39;t drive without a car. The car is the framework that gives you the ability to drive: it has a chassis, four wheels, seats, air conditioning, and they come in a variety of models which you pick according to your needs.&lt;/p&gt;
&lt;p&gt;In the same way, you need some sort of application to use the CLI. We call these &#39;terminals&#39;, and your Mac comes with one. Conveniently, it&#39;s called &lt;strong&gt;Terminal.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;history-lesson&quot; tabindex=&quot;-1&quot;&gt;History lesson &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Computer_terminal&quot;&gt;Terminals&lt;/a&gt; used to be the whole computer. The &lt;em&gt;only thing it did&lt;/em&gt; was to be a terminal.&lt;/p&gt;
&lt;p&gt;These days computers are a lot more powerful, and &#39;the terminal&#39; is just an app. Technically we call it a &lt;a href=&quot;https://en.wikipedia.org/wiki/Terminal_emulator&quot;&gt;terminal emulator&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;there-are-other-terminal-apps&quot; tabindex=&quot;-1&quot;&gt;There are other terminal apps &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Apple&#39;s Terminal is like a Ford Escort. It&#39;s pretty basic, it doesn&#39;t have many extras, but it comes with the job and doesn&#39;t cost you anything to drive.&lt;/p&gt;
&lt;p&gt;If you want more features -- a better stereo, nicer wheels -- you can go shopping and get yourself a nicer model. There&#39;s &lt;a href=&quot;https://iterm2.com&quot;&gt;iTerm 2&lt;/a&gt;, &lt;a href=&quot;https://www.warp.dev&quot;&gt;Warp&lt;/a&gt;, and a bunch of others.&lt;/p&gt;
&lt;p&gt;You can even get them &lt;a href=&quot;https://panic.com/prompt/&quot;&gt;for your iPad&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But when you&#39;re just learning, stick with the simple car. I still use Terminal; it does everything that I need.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;launching-terminal&quot; tabindex=&quot;-1&quot;&gt;Launching Terminal &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Let&#39;s get your seat and mirrors adjusted. Launch Terminal, which is in your Mac&#39;s&lt;br&gt;
&lt;code&gt;/Applications/Utilities&lt;/code&gt; folder.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;By the way, that notation with the slashes -- it means something &lt;em&gt;very&lt;/em&gt; specific, which you&#39;ll soon understand. :-)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You&#39;ll be greeted by a fairly austere window.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://commandline.johnnydecimal.com/img/04.01-terminal-basic-682x483.png&quot; alt=&quot;A screenshot of the basic Terminal window with it&#39;s default configuration. Small black text on a white window.&quot; width=&quot;682&quot; height=&quot;483&quot;&gt;&lt;/p&gt;
&lt;p&gt;I like to feel more like an old-school nerd when I&#39;m at the CLI, so I set my default terminal to have green text on a black background. You can do that in Terminal&#39;s &lt;strong&gt;Settings&lt;/strong&gt;: on the &lt;strong&gt;Profiles&lt;/strong&gt; tab, select &lt;strong&gt;Homebrew&lt;/strong&gt;,&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot; id=&quot;fnref1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt; and click &lt;strong&gt;Default&lt;/strong&gt; at the bottom of the list.&lt;/p&gt;
&lt;p&gt;I also bump up my font size, which you can do on the right under &lt;strong&gt;Font&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Now hit &lt;code&gt;Command-N&lt;/code&gt; to get a new window.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://commandline.johnnydecimal.com/img/04.02-terminal-homebrew-1002x650.png&quot; alt=&quot;Terminal, now green-on-black and with a larger font.&quot; width=&quot;1002&quot; height=&quot;650&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;font-size: 4rem; margin: 0; text-align: center;&quot;&gt;😎&lt;/p&gt;
&lt;h2 id=&quot;tip-duplicate-the-default-profiles&quot; tabindex=&quot;-1&quot;&gt;Tip: duplicate the default profiles &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can modify these profiles to your heart&#39;s content. If you select one of the defaults and click the three-dots-in-a-circle icon at the bottom of the list, you can &lt;strong&gt;Duplicate Profile&lt;/strong&gt;. Now if you mess it up you can just delete it and start again.&lt;/p&gt;
&lt;h2 id=&quot;we-haven-t-started-the-car-yet&quot; tabindex=&quot;-1&quot;&gt;We haven&#39;t started the car yet &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It&#39;s important to note that what you&#39;re messing about with here is &lt;em&gt;the Terminal application&#39;s settings&lt;/em&gt;. There&#39;s no harm you can do here, other than making it look ugly.&lt;/p&gt;
&lt;p&gt;We haven&#39;t put the key in the ignition yet. Let&#39;s do that and make sure it starts.&lt;/p&gt;
&lt;h2 id=&quot;start-the-engine&quot; tabindex=&quot;-1&quot;&gt;Start the engine &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It can help to see some text in the otherwise-empty window. So let&#39;s type your first command, which I&#39;m not going to explain. It&#39;s just a command that will fill up your window with text.&lt;/p&gt;
&lt;p&gt;Crucially, it&#39;s totally harmless.&lt;/p&gt;
&lt;p&gt;Type &lt;code&gt;printenv&lt;/code&gt; and hit &lt;strong&gt;return&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://commandline.johnnydecimal.com/img/04.03-terminal-printenv-1017x650.png&quot; alt=&quot;Terminal, showing the result of the `printenv` command. Which is mostly a bunch of incomprehensible junk.&quot; width=&quot;1017&quot; height=&quot;650&quot;&gt;&lt;/p&gt;
&lt;h1 id=&quot;shut-it-down&quot; tabindex=&quot;-1&quot;&gt;Shut it down &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;To close this window, you have a few options.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Type &lt;code&gt;logout&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;exit&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;Control-D&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Close the window using the red button at the top right.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;They all do the same thing. I prefer &lt;code&gt;logout&lt;/code&gt; because it feels more nerdy. &lt;code&gt;Control-D&lt;/code&gt; is also very old-school.&lt;/p&gt;
&lt;p&gt;Closing the window feels like the &lt;em&gt;least&lt;/em&gt; correct thing to do.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;homework&quot; tabindex=&quot;-1&quot;&gt;Homework &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;h2 id=&quot;1-have-the-window-close-automatically&quot; tabindex=&quot;-1&quot;&gt;1: Have the window close automatically &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you use one of the first three methods, the window won&#39;t actually close. Instead you&#39;ll be left looking at this text:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;Saving session&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;.completed.

&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;Process completed&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Figure out how to make it so that when you type &lt;code&gt;logout&lt;/code&gt;, the window closes. Have a look around Settings, but use the internet if you&#39;re not sure.&lt;/p&gt;
&lt;h2 id=&quot;2-why-don-t-i-like-using-the-red-button&quot; tabindex=&quot;-1&quot;&gt;2: Why don&#39;t I like using the red button? &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I said that closing the window using the red button felt like the &#39;least correct&#39; thing to do.&lt;/p&gt;
&lt;p&gt;Why?&lt;/p&gt;
&lt;hr class=&quot;footnotes-sep&quot;&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn1&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;Unrelated to the CLI tool that we&#39;ll learn about later. &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/04-let-me-show-you-around-your-new-car/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
	</entry>
	
	<entry>
		<title>Computers are like cars</title>
		<link href="https://commandline.johnnydecimal.com/learn/03-computers-are-like-cars/"/>
		<updated>2024-05-29T13:55:00Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/03-computers-are-like-cars/</id>
		<content type="html">&lt;p&gt;Thanks, Johnny, this is outrageously exciting to my aspiring-geeky heart!&lt;/p&gt;
&lt;p&gt;So I&#39;ve done my assignment re- layers of abstraction. Makes perfect sense.&lt;/p&gt;
&lt;p&gt;Just like my car&#39;s ignition button, I&#39;m aware there&#39;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&#39;t have to think of any of that when I&#39;m buckling up.&lt;/p&gt;
&lt;p&gt;Computers be no different!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>What is the command line?</title>
		<link href="https://commandline.johnnydecimal.com/learn/02-i-want-to-understand-what-the-command-line-is/"/>
		<updated>2024-05-28T02:00:00Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/02-i-want-to-understand-what-the-command-line-is/</id>
		<content type="html">&lt;p&gt;Your computer has many &#39;languages&#39;, or ways of &#39;thinking&#39;, internally.&lt;/p&gt;
&lt;p&gt;The phrase &#39;(it&#39;s all just) &lt;a href=&quot;https://en.wiktionary.org/wiki/ones_and_zeroes&quot;&gt;ones and zeroes&lt;/a&gt;&#39; represents the fact that, at its very lowest level, your computer is literally just passing around information that looks like &lt;code&gt;1010111110101000100111010010110010&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;(It&#39;s made of transistors, and they can only be on &lt;code&gt;1&lt;/code&gt; or off &lt;code&gt;0&lt;/code&gt;.)&lt;/p&gt;
&lt;p&gt;That&#39;s not very friendly for us humans, so over the years we&#39;ve abstracted away from &lt;code&gt;1010111...&lt;/code&gt; by creating &lt;strong&gt;higher-level languages.&lt;/strong&gt; The next-least-complicated language is called &lt;strong&gt;assembly&lt;/strong&gt;.&lt;sup class=&quot;footnote-ref&quot;&gt;&lt;a href=&quot;https://commandline.johnnydecimal.com/learn/02-i-want-to-understand-what-the-command-line-is/&quot; id=&quot;fnref1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;pre class=&quot;language-asm6502&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-asm6502&quot;&gt;&lt;span class=&quot;token op-code keyword&quot;&gt;LDA&lt;/span&gt; &lt;span class=&quot;token hex-number number&quot;&gt;#$01&lt;/span&gt;
&lt;span class=&quot;token op-code keyword&quot;&gt;STA&lt;/span&gt; &lt;span class=&quot;token hex-number number&quot;&gt;$0200&lt;/span&gt;
&lt;span class=&quot;token op-code keyword&quot;&gt;LDA&lt;/span&gt; &lt;span class=&quot;token hex-number number&quot;&gt;#$05&lt;/span&gt;
&lt;span class=&quot;token op-code keyword&quot;&gt;STA&lt;/span&gt; &lt;span class=&quot;token hex-number number&quot;&gt;$0201&lt;/span&gt;
&lt;span class=&quot;token op-code keyword&quot;&gt;LDA&lt;/span&gt; &lt;span class=&quot;token hex-number number&quot;&gt;#$08&lt;/span&gt;
&lt;span class=&quot;token op-code keyword&quot;&gt;STA&lt;/span&gt; &lt;span class=&quot;token hex-number number&quot;&gt;$0202&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Okay, still not what you&#39;d call friendly. Let&#39;s try some &lt;strong&gt;JavaScript:&lt;/strong&gt; a higher-level language than assembly.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; firstname &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Johnny&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; nickname &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Decimal&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; surname &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Noble&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Hi, &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;firstname&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; ‘&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;nickname&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;’ &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;surname&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Better! You don&#39;t have to know JavaScript to at least guess what that&#39;s going to do.&lt;/p&gt;
&lt;p&gt;If we keep going, we can abstract away this idea of languages entirely, and end up with the &lt;strong&gt;graphical user interface,&lt;/strong&gt; or &lt;strong&gt;GUI.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://commandline.johnnydecimal.com/img/02.01-mess-error-image9-398x191.png&quot; alt=&quot;A Windows error dialog that reads &#39;An error occurred while creating an error report&#39;.&quot; width=&quot;398&quot; height=&quot;191&quot;&gt;&lt;/p&gt;
&lt;p&gt;So why would you bother learning a language when you can just go around clicking buttons?&lt;/p&gt;
&lt;h2 id=&quot;control&quot; tabindex=&quot;-1&quot;&gt;Control &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/02-i-want-to-understand-what-the-command-line-is/&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can click a button because some designer in Seattle designed the program to have a button.&lt;/p&gt;
&lt;p&gt;But what if you want more granular control? What if there isn&#39;t a button for the thing you want to do?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Then you crack open the command line.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Because at the end of the day, that button passed a command to a high-level language which translated it and passed it down to a lower-level language which translated it to assembly which your computer translated to ones and zeros which is all it can understand.&lt;/p&gt;
&lt;p&gt;So if you can insert yourself in that chain, if you can start talking some of these higher-level languages, you can get more control. You can do whatever you want.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The command line is how you talk to your computer in a high-level language.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Next, I&#39;ll explain how you do that.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id=&quot;homework&quot; tabindex=&quot;-1&quot;&gt;Homework &lt;a class=&quot;header-anchor&quot; href=&quot;https://commandline.johnnydecimal.com/learn/02-i-want-to-understand-what-the-command-line-is/&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Do a bit of reading on &lt;a href=&quot;https://en.wikipedia.org/wiki/Abstraction_layer&quot;&gt;abstraction layers&lt;/a&gt;. But you don&#39;t need to go deep on theory here: as long as you&#39;ve got the idea, we&#39;ll move on.&lt;/p&gt;
&lt;hr class=&quot;footnotes-sep&quot;&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn1&quot; class=&quot;footnote-item&quot;&gt;&lt;p&gt;This is not a scientifically complete list of computer languages. &lt;a href=&quot;https://commandline.johnnydecimal.com/learn/02-i-want-to-understand-what-the-command-line-is/&quot; class=&quot;footnote-backref&quot;&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
	</entry>
	
	<entry>
		<title>Introduction &amp; goals</title>
		<link href="https://commandline.johnnydecimal.com/learn/01-introduction-and-goals/"/>
		<updated>2024-05-28T01:00:00Z</updated>
		<id>https://commandline.johnnydecimal.com/learn/01-introduction-and-goals/</id>
		<content type="html">&lt;p&gt;On Mastodon, &lt;a href=&quot;https://pkm.social/@ellane&quot;&gt;Ellane&lt;/a&gt; mentioned that she&#39;d like to &#39;learn the command line&#39;. What she told &lt;a href=&quot;https://hachyderm.io/@johnnydecimal&quot;&gt;Johnny&lt;/a&gt; was that she wants to:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;understand what the command line IS&lt;/li&gt;
&lt;li&gt;learn how not to stuff up your machine&lt;/li&gt;
&lt;li&gt;learn what language it speaks&lt;/li&gt;
&lt;li&gt;understand what commands DO, where things go&lt;/li&gt;
&lt;li&gt;know what Homebrew is, why people use it, what it does, and how it does it.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Also she has a &#39;burning ambition to learn plain text accounting (hledger, specifically)&#39;. So that&#39;s where we&#39;re headed.&lt;/p&gt;
&lt;p&gt;And so that&#39;s what we&#39;re going to do here. From zero to hero: I&#39;m going to teach Ellane the command line.&lt;/p&gt;
</content>
	</entry>
</feed>
