I connect to my Mac many USB devices that communicate over a serial (UART) bus to send debug information to the host or to receive data and code. You know, Raspberry Pi Picos, Adafruit Feathers, FTDI cables — that kind of thing. Often I have more than one connected. Is there an easy way to see what’s connected without listing /dev every time and to remember connected devices’ paths?
It’s June once more, and time for Apple’s Worldwide Developers’ Conference (WWDC). This is a chance to learn about new functionality and, yes, discover initiatives announced at previous WWDCs that you completely missed the first time around. A case in point: Apple’s revamp of how apps are notarised at the command line, which was revealed at WWDC 21 but I only encountered this week.
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.
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.
I work on quite a few git repositories at once, and I don’t always commit changes in one before making changes to another. Or if I do, I don’t always push the changes up straight away. That might not be best practice in software development, but hey, it’s what I do. The issue for me is remembering what state each repo is in. Here’s the script I use to tell me.
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.
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.
imageprep, my command line tool for batch-processing picture files, had a big update a week or so back — and now it has another one. With the second update imminent, I didn’t announce the first, 6.1.0, which I released to coincide with my post on writing command line utilities in Swift. That done, it’s time to shout about imageprep 6.2.0.
I’ve spent a lot of time of late working on several macOS command line tools written in Swift. So I’ve gathered together the key points I’ve learned while creating and updating pdfmaker and imageprep: some best practices and ways to deliver many of the features common to programs the run at the command line.