Install a newer version of `less`

The version of less which ships in macOS Monterey (12.0) is 487, which was released in March 2017. Since then, it’s gained some features:

  • Line marking. Marking a line allows you to assign a shortcut letter to it to jump back.
  • Search result clearing.
  • Adds a status column, to show marks and indicate lines where search results are found.
  • Mouse support, so e.g. scrolling works in the document using the mouse.

At first it seemed like this may be the general problem of Apple disallowing GPL version 3 software, but less is dual-licensed to a more Apple-favorable one as well. It’s somewhat inexplicable that such a commonly-used command line library sees no updates.

Fortunately, it’s included in Homebrew. And even better, unlike the Apple distribution, they do not disable lesskey support, which allows specifying additional command and keyboard shortcuts for less to use.

Creating iOS simulators in bulk

To work around Xcode’s disinclination for creating new simulators, I wrote a script which deletes all the current simulators and then creates every possible simulator. It’s relatively straightforward because simctl has a decent JSON interface which makes processing the state a lot nicer:

#!/usr/bin/env fish # Just to make it obvious when using the wrong version printf "Using Xcode at %s\n\n" (xcode-select -p) echo "Deleting all simulators..." xcrun simctl shutdown all >/dev/null xcrun simctl delete all >/dev/null printf "...done\n\n" echo "Creating new simulators..." # You could also add 'appletv' to this list for runtime in ios watch set -l runtimes (xcrun simctl list runtimes $runtime available -j | jq -c '.runtimes[]') for runtime in $runtimes set -l runtime_version (echo $runtime | jq -r '.version') set -l runtime_identifier (echo $runtime | jq -r '.identifier') set -l supported_devices (echo $runtime | jq -c '.supportedDeviceTypes[]') for device in $supported_devices set -l device_name (echo $device | jq -r '.name') set -l device_identifier (echo $device | jq -r '.identifier') set -l display_name "$device_name ($runtime_version)" printf \t%s\n $display_name xcrun simctl create $display_name $device_identifier $runtime_identifier >/dev/null end end end printf "...done\n\n"
Code language: Bash (bash)

The only thing missing here is device pairing — connecting a watch and phone together. Since there’s limitations around the number of devices which can be paired together, I find this a bit easier to still do manually.

Making shift-space send page up and other key mappings in iTerm2

A common problem when I am paging through less output is that, while the space key will go down a page, the shift-space shortcut does not go up. The underlying reason is terminals are strings of text and date back decades and many key combinations are archaic sequences.

Shift-space is is one of these cases. While the space key inserts visible text, the shift-space variant doesn’t have a unique character. This requires hoping particular app can handle the sequence CSI 32;2 u (which may look like ^[[32;2u; this is part of a proposal known as CSI u), or changing the key map in the terminal. I went for the latter.

Continue reading “Making shift-space send page up and other key mappings in iTerm2”

Technical debt that lasts forever

I noticed that ls output is sorted case-sensitively on macOS; that is, “abc” is sorted after “Xyz.” It doesn’t appear there are any mechanisms to get ls to do a case-insensitive sort, either. To work around this in a script I was writing, I looked to sort to do this for me, and stumbled upon the always-confusing flag:

-f, --ignore-case: Convert all lowercase characters to their uppercase equivalent before comparison, that is, perform case-independent sorting.

Which brings about the question: what does -f have to do with case-insensitive sorting? The answer to this part of the mystery is more apparent in the coreutils version, which describes it as:

-f, --ignore-case: fold lower case to upper case characters

So the -f short-form flag is for “fold.” Case folding is a mechanism for comparing strings while mapping some characters to others, or in this case mapping lowercase to uppercase using Unicode’s Case Folding table.

The long-form version of this flag was added in 2001, citing as “add support for long options.” The short-form version was added in 1993, likely for compatibility with some pre-existing Unix version. The first version of the POSIX standard in “Commands and Utilities, Issue 4, Version 2” (1994, pg. 647) doesn’t even use the word “fold,” defining it as:

-f: Consider all lower-case characters that have upper-case equivalents, according to the current setting of LC_CTYPE, to be the upper-case equivalent for the purposes of comparison.

Sadly, the oldest version of sort that I can find is from 4.4BSD-lite2, which describes it the same as macOS does now, also without the word “fold” in sight. I’m guessing some older, more ancient documentation for proprietary Unix is floating around somewhere that describes the flags, too.

Amusingly, the option you’d think would be the case-insensitive comparison flag, -i, is instead “ignore all non-printable characters.” This is a great example of picking a precise-but-confusing name for something and getting stuck with it until the end of time.

More quotes

First, from The Dragonbone Chair:

“Ko muhuhok na mik aqa nop, we say in Yiqanuc: ‘When it falls on your head, then you are knowing it is a rock.’”

“‘Mikmok hanno so gijiq,’ we say in Yiqanuc!” Binabik called. “‘If you wish to carry a hungry weasel in your pocket, it is your choice!”

A ponderous one from The Banished of Muirwood:

Your mind is your predicament. It wants to be free of change. Free of pain, free of the obligations of life and death. But change is law and no amount of pretending will alter that reality.

One that made me cry from Artemis:

“What’s up, Dad? You’re slow as snot today.”

“Just being thorough.”

“Are you kidding? I’ve seen you fire up a torch with one hand and set mixture levels with the other at the same time. Why are you—”

Oh. I stopped talking. This wasn’t a normal job. Tomorrow, his daughter’s life would rely on the quality of these welds. It slowly dawned on me that, to him, this was the most critical project he’d ever done. He would accept nothing short of his absolute best. And if that meant taking all day, so be it. I stood back and let him work. After more fastidious double checks, he got started. I assisted and did what I was told. We may have our friction, but when it came to welding he was the master and I was the apprentice. Very few people get a chance to quantify how much their father loves them. But I did. The job should have taken forty-five minutes, but Dad spent three and a half hours on it. My father loves me 366 percent more than he loves anything else. Good to know.

One that makes me ponder from City of Miracles:

What a tremendous sin impatience is, he thinks. It blinds us to the moment before us, and it is only when that moment has passed that we look back and see it was full of treasures.

One that made me laugh from Gardens of the Moon:

“It will be a fine day for a walk, pronounces Kruppe, who is wise in all things.”

Kruppe (of course)

And finally one that reminds me enough of San Francisco that I couldn’t help but stop and think from The City Stained Red:

This city is sick, his father had once told him. It eats people and craps out gold and people pick the filth up off the city streets and shove it in their faces and smear it on their lips.

I created, a quick way to glance at the dynamic type sizes Apple predefines. It’s an evolution of a Gist I created which I’ve been referring to for years, but now with the added benefit of an extremely memorable URL.

Robert Jackson Bennett, author of City of Stairs, wrote author notes for the book:

Every once in a while – mostly due to reader comments – I find myself wondering if the present tense is worth writing in. But the opening sequence to this chapter dispels any such thoughts from my mind.

Seriously, I forgot how fucking creepy Jukov is.