The terminal (and it’s Windows counterparts, the Command Prompt and PowerShell) are terrifying to behold if you have no idea what you’re doing. In When to Start Naming Things, we’ve talked about text labels and design conventions in graphic interfaces. But what do you do when you’re faced with nothing but a blinking text cursor, and nothing else? And why would you want to use such a thing in the first place?
Precision + Speed
Graphic interfaces are great at giving you precision on a slow drip. Given a list of files, you can be very precise in selecting files to delete given that you’ve had the time to:
Hold down the
⌘key and click each file in turn to select them.
⌘+deleteto move them to the trash.
Right-clicking the 🗑 icon and selecting "Empty Trash".
Or you could just type the following in the terminal to remove all
cd target-directory rm *.pdf
Quickly Copy+Paste Stuff
Another really useful thing you can do is this: on macOS, you have a tool called
pbcopy, which allows you to send text to your clipboard. I use this to quickly copy and paste snippets of text for, let’s say, emails. Here’s how it works:
Open your terminal by going to Applications > Utilitites > Terminal, or by using spotlight: press
terminalto find it.
In the terminal, create a new directory by typing the following:
Press enter to run the command.
Go into the
tmpdirectory you’ve just created by running the following command:
revert.txttext file by running the following command:
echo "As per my last email; please revert. Thanks." >> revert.txt
To quickly see the contents of the file, run
Copy the contents of
revert.txtto your clipboard by running:
cat revert.txt | pbcopy
⌘+vto paste the contents of your clipboard. Done!
You can open the current directory in your Finder by running
The thing about these little nifty things you can do with the terminal is that their efficiencies add up. Being able to do this with one text file is nice, but having a whole library of text files you can do this with can potentially save you a lot of time. Plus, once you get used to it, navigating your filesystem using the terminal is a lot quicker, without the same distractions as clicking through the Finder, double-clicking and waiting for a file to open, and then realising its the wrong one and opening the next file (yes, I know QuickLook exists. I’m just trying to make a point).
Download YouTube videos
If you’re willing to really dig into this, you can install and run applications from the terminal directly. And I’d really recommend it, especially if you like YouTube and you’re tired of being endlessly assailed by ads when you try to google "YouTube downloader" (or worse, if you’re using a dubious ad-riddled piece of software to download these things). Enter brew.sh.
brew.sh is a package manager for macOS (there are similar things for Windows, but none come close to anything you can run in a
bash terminal) that allows you to install applications by just running
brew install <application_name>. Go to brewformulas.org  to find a list of applications you can install and run in the terminal.
Now, for the important part — start downloading YouTube videos by doing the following:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install youtube-dl
Go to a YouTube video, and copy its URL from the browser’s address bar.
Go to your terminal and run:
youtube-dl -f mp4 <youtube-video-url>
The terminal is scary as it is powerful. Once you’ve gotten the basics down, you’ll be able to very quickly use more of its features. Plus, once you’re fluent with the macOS terminal, you’re essentially fluent in Linux (though I’m not sure how useful this is to you) because the macOS terminal and the Linux terminal both use the same command shell:
This means lots of skills are transferable: you can read and write files in the same way, and do things like check your computer’s IP address by running
ifconfig (deprecated in more recent versions of Linux).
This also means that you can quickly graduate to using more advanced tools, like the Hugo static-site generator, which this site is built on. But that’s a post for another time.
If you’ve got questions on how this possibly can help you at work or at play, you can email me at email@example.com.