The Terminal – For Noobs (Like Me), Part Two
The Why and What
In part one, I tried to establish the basic concepts of terminal emulator, shell, prompt, and CLI. In this part, I want to go into why people use the terminal – and in the next part, how to make it more noob-friendly.
“But why do people use this archaic thing?”
As mentioned in part one, I’m absolutely not one of those who live in the terminal. But if I were to guess (and this applies to my basic usage as well), I’d say two things are the most important: It’s fast, and it’s powerful.
One way it can be fast, is that CLI programs are computational efficient, as there’s a lot of stuff (like graphics) they don’t need to render.
Another way is that you can do quite complicated tasks in a single command. For instance, I’ll sometimes run this:
for dir in */; do
(cd "$dir" && mkdir -p .Originals && cp * .Originals/)
done
This will
- run through all folders in a parent,
- add a hidden folder in each, named .Originales,
- and place a copy of each file in that hidden folder.
I use this to create backups of files before editing them (in a specific workflow), and it happens instantly. 👌🏻
CLI tools are both powerful in terms of what they can do, and also in that they’re usually highly customisable.
And the combination of being fast and powerful, if you know what you’re doing, makes it a valuable tool in which to invest.
“But what can you use it for?”
If you’re a programmer, you can become a beast (with plenty of bragging rights) by using the text editor NeoVim, that runs in the terminal.1 But I’m not, so I’ll only say that if you find yourself stuck in something you can’t exit, try hitting q
, ctrl+q
, ctrl+c
, or type :qa
.
And if you use many terminal applications, you’ll might want to use stuff like Tmux, which is a sort of window manager within a terminal.
But as I don’t know what I’m talking about, I want to stick to more basic use cases:
- Random commands
- Package management
- Navigate and search the file system
- Git
- Control other computers/servers
- Set up, and run, background tasks
Random commands
After a while, you’ll collect several little snippets that do useful stuff for you, like the examples with .Originals I mentioned above. There are also tools for converting files, batch renaming, and other little things that might be annoying and repetitive.
You can also control OS settings that might not be available elsewhere (or are impractical). One example here are the ones I use to swap the dock layout depending on whether I’m using an external monitor. Another one is a command to turn off font smoothing (which you should):
defaults -currentHost write -g AppleFontSmoothing -int 0
I like to keep these as snippets in Raycast 🖇️.
Package management
This is just a fancy way of saying “installing, updating, and uninstalling apps”. And Homebrew is a good one for Mac, which I’ve written a guide for.
Navigate and search file system
A nice terminal setup for this can be a great alternative to Finder, and also file search with launchers like Raycast or Spotlight. I’ve given an example at the end of part three.
Git
Git, and version control, is another area where I want to write a For Noobs (Like Me) post someday… Because I only almost understand it! And one of the reasons I find the text editor Nova to be more noob-friendly, is that it has built-in support for Git in a GUI, so I don’t have to use it in the terminal.
However, as long as I don’t have to deal with conflicts, it’s really fast to just do it in the terminal! So I’ve (mostly) graduated to this now.
Control other computers/servers
I’ve written previously about having a M4 Mac Mini as a secondary computer. And the only monitor I have connected to it is our TV – and I don’t really have a mouse and keyboard connected to it either. This means I mostly have to control it with my MacBook.
And while I can share the entire screen and control it like that, it’s also really practical that I can just type ssh erlend@192.168.12.34
into my terminal, and suddenly, it’s like I’m running a local terminal instance on the other Mac.
SSH is a way you can securely interact with something remote. In addition to the above, I use it when I use git, and when I have to access a Digital Ocean 🖇️ droplet that runs a Discourse forum I run. It’s also really nice that 1Password handles the SSH keys flawlessly.
Set up, and run, background tasks
In the post I linked above, I also mentioned that I managed to replace Feedbin as a host for the RSS feeds I read. Currently, everything is hosted on my Mac Mini, with Miniflux – and I had to set everything up using the terminal and CLIs.
But now it’s simply a background task that starts up with the Mac.
There are lots of YouTube videos out there, like “7 essential CLI tools”. And the things mentioned are often cool – but often not relevant for a noob and non-programmer like me. But I’d love to hear about other use cases out there! And especially if you think they can be useful for me and my fellow plebs.
Click here to go to part three, about making your Terminal more noob-friendly.
-
You have to relearn everything about how you manipulate text on a computer… But if you do, you’ll become much faster at it! ↩︎