Over the last few years I’ve released a number of command line utilities for macOS. I’ve always included online help within them, triggered with the --help
switch, but I recently wondered how I might provide Unix Manual pages too. It would allow users to call up help with the CLI command man
as well as a command switch. Belts and braces, perhaps, but I’m a completist and, more to the point, didn’t know how it was done and wanted to learn.
Category Archives: How To (Mac)
How to do DNS over HTTPS with macOS
My last post detailed how you set up DNS over HTTPS (DoH) for a client Raspberry Pi. I mentioned that I tried this out first on a Mac, and so I’ve been asked to show how running DoH on macOS works. Here goes.
Continue readingTackle async signal safety in Swift
How do you safely interrupt a command-line program written in Swift? This question was posed to me this week by a reader who got in touch to point out that boilerplate code included in my How to write macOS command line tools in Swift post might not be totally safe: it could leave a program and system in an undefined state, which is never a good thing. So I took a closer look.

Crop picture files with confidence and pixel-precise offsets, using sips and imageprep
I recently had a rather large number of screenshots to process: specifically to crop them down to a small area about a third of screen width in and two-thirds of its height down. I could have done this manually, but it’s easy enough to make mis-crops when you’re cropping a couple of images by eye, let alone a 100 or so. The solution? Get your Mac to do it for you. Here’s how.
Continue readingHow to fix ‘xcodebuild’ macOS Terminal slowdowns
For a while, running commands and scripts in macOS’ Terminal has felt slower than it should, especially when opening Terminal for the first time. Clearly my .zshrc
file was being run, but there was a very noticeable pause between the completion of the script and before the prompt appeared. The gap was much less on my M1 Mac than my Intel machine, but still noticeable. Got the same problem? Here’s how to fix it.
Take advantage of Xcode’s hidden diagnostics to debug multi-threaded application code
PreviewMarkdown’s Thumbnailer component, an App Extension which generates Finder icon thumbnail previews of Markdown documents, recently started showing some odd behaviour. Tracking down the cause provided some interesting insights into writing macOS software for a multi-threaded environment.

How to use zmv — Z Shell’s super-smart file renamer
I’d like to introduce you — if you’re not already acquainted — to the Z Shell’s incredibly handy function zmv. If you ever need to change at the command line the names of a batch of files consistently, it’s the tool you’ll want to turn to first. It’s not well known, and having been given the nod by a colleague, I thought I’d explore and pass on some notes about taking advantage of it.

How to share preferences between macOS/iOS apps
A couple of macOS releases or so ago, Apple introduced app extensions: self-contained modules that are bundled within apps to deliver functionality to the wider operating system. But how do apps and their extensions share information between themselves, in particular users’ preferences?
Continue readingHow to migrate to native Homebrew on an M1 Mac
Let the great Homebrew migration begin. Yes, Homebrew now has native support for Apple’s ARM64-based M1 chip. The latest version, 3.0.0, released 5 February, will run nicely on your Apple Silicon Mac. There’s a catch, of course. Well, several catches: first, not all of the tools you can install using Homebrew are M1 native yet and, second, Homebrew doesn’t offer explicit migration instructions, that I could find at least.
Continue readingHow to debug a Raspberry Pi Pico with a Mac, SWD and… another Pico
When you’ve used Serial Wire Debug (SWD) to help you correct the C or C++ code running on your Raspberry Pi Pico, you’ll never want to go back to USB and the UF2 file system again. I don’t — no more messing about unplugging and re-plugging cables for me.
Continue reading