avatar

Scott Willsey

iOS nerd, old school computer guy

Random Terminal Message of the Day

Dan Moren posted a Terminal Message of the Day tip on Six Colors a few days ago, and I decided I would configure my Mac with a MOTD as well. However, I want a random one from a list every time I open a terminal rather than seeing the same one over and over.

The easiest way to do this is to avoid the /etc/motd file altogether and use a script to read a random line out of a text file and display that when you open a terminal window. There are three parts to this, two of which take all the work: a text file full of messages of the day, a script to randomly grab one, and a means by which to execute it automatically when you open terminal.

Find a place on your Mac you want to store scripts, if you don’t already have one. …

(Read More)

Regular Expressions and Shortcuts, Part 3.5

This post is part of a series on Regular Expressions and their applications in the Shortcuts app.

Regular Expressions and Shortcuts, Part 1

Regular Expressions and Shortcuts, Part 2

Regular Expressions and Shortcuts, Part 3

Before continuing on and looking at how to integrate the regular expression we’ve been talking about so far into a shortcut, I want to incorporate a piece of feedback from Allister Jenks.

I originally came up with this:

^(?:.+\/){1,}(.+)\.json$

Allister points out that there’s a much more logical and concise way of doing it.

He’s right, of course. The following works perfectly and makes more sense.

^(?:.+\/)+(.+)\.json$

Actually, we don’t even need the + after the first group, thanks to greedy matching. By …

(Read More)

Regular Expressions and Shortcuts, Part 3

This post is part of a series on Regular Expressions and their applications in the Shortcuts app.

Regular Expressions and Shortcuts, Part 1

Regular Expressions and Shortcuts, Part 2

Hi, it’s me again, the guy with the terrible regular expression that I keep yammering on and on about:

^(?:.+\/){1,}(.+)\.json$

Last time I explained how (.+\/){1,} works to match file path directories in a file name, like these:

hugo-files/data
hugo-files/
hugo-files/data/links/

I did not explain, however, why the first part of the regular expression contains ?: inside the first set of parenthesis, like this:

(?:.+\/){1,}

In order to understand this, you have to understand the role of the parenthesis in regular expressions.

First, they do what I said last time they do: group things together for the purposes of applying a subsequent modifier to everything in the group. In our case, because …

(Read More)

More things I said recently: