Welcome to the lab.

Fixing the Big Sur proxy icon delay globally

I had previously bemoaned the fact that the proxy icon is now hidden behind a hover delay in Big Sur. In that post, I mentioned that you could remove that delay in Finder using the command defaults write com.apple.Finder NSToolbarTitleViewRolloverDelay -float 0. But that only affects Finder, and you have to repeat it with various bundle identifiers for each app making use of the Big Sur toolbar layout.

I have since realized you can set this globally for all apps in one fell swoop:

defaults write -g NSToolbarTitleViewRolloverDelay -float 0

As far as I can tell, that seems to have done the trick. Just thought I’d update with the new info. I’ve updated the older post as well.

Rewind: Quick reminders in Terminal

I was browsing my gists recently and found one I’d totally forgotten about, which is somewhat ironic given its purpose: scheduling short-term reminders with alarms from the Terminal. I posted it about it back in 2016, but eventually it fell into disuse, as a lot of my just-playing-with-an-idea scripts tend to.

This one was actually pretty cool, though, and I’ve started using it again. You just run something like dontforget to get ready for dinner in 30m in Terminal, and in 30 minutes, you get a reminder in the form of a “ding” and your computer saying “Time to get ready for dinner.” It has LaunchBar integration for large display text.

I don’t know why I ever decided that Bash scripting was the efficient way to write this one. It definitely isn’t. But I stuck with it and updated it a little bit.

You can now use “at 3pm” or “at 10:30am” type strings to set a specific time. The meridian (am or pm) is required. This only works within 24 hours of the current time.

I also added an AppleScript display dialog if you don’t have the LaunchBar integration enabled. Oh, and for some reason I thought it deserved smarter display of the time, so instead of “in 128 minutes,” it says “in 2 hours 8 minutes”.

Contrary to what I wrote in my original post on this, it will actually work fine if you quit the Terminal session you launched it in (assuming you didn’t force it to run in the foreground, but why would you do that, really?).

This little script really isn’t meant to be used for much beyond a quick reminder within a few hours. I use it when I tell my girlfriend I just need to take care of a quick coding problem I thought of in the evening after I’m supposed to be done for the day. “I’ll be back in 20 minutes, I promise.” When I sit down I run dontforget to get back to your beautiful girlfriend in 20m and my Mac will make sure I’m not a liar.

You can find the updated script in the gist. Feel free to leave comments there if you think of additions or fixes it needs! By the way, I’m using Fish as my shell these days, but this works fine as long as it has the bash shebang on the script.

Scripting with sudo on Mac

I was writing up an “advanced scripting” example for the Bunch documentation and realized this tip is useful enough generally to be worth cribbing for a post.

The gist is this: when you need to script a tool that requires administrator privileges, you want to make the process as automated as possible without creating glaring security problems (like including a password in plain text).

An example of why you’d want to do this would be the tmutil command line utility, which allows you to perform Time Machine tasks from the command line. But the enable and disable commands require sudo to work, so pausing Time Machine from a script isn’t as easy as just running tmutil disable. You’d either have do some terribly insecure things to /etc/sudoers, or store your Mac’s most valuable password in plain text in a script. Neither option is good.

Fortunately, macOS has tools built in to make this work. We’ll use a combination of macOS’s Keychain Access and the security command to make running superuser tasks both convenient and secure.

Side note: 1Password has a command line tool that can do something very similar to this, but it requires signing in on the command line. The method below allows you to have a script run in the background, only popping up a password dialog when needed.

A GitHub Stars widget for WordPress

Backstory: my co-host on Overtired, Christina Warren, has a constantly growing collection of repositories she’s starred on GitHub. As a developer advocate for a Big Tech company, she always keeps her finger on the pulse of the new and cool developer stuff, and her stars serve as a curated list of “projects to watch.” It came up on an episode a while ago, and I decided we should have a way to display the latest ones.

The Overtired site uses WordPress, so even though I’m not doing a lot of WordPress development these days, I figured I’d dust off my PHP skills and whip up a plugin for this. It’s pretty barebones, but it does the job, and you can plug in any username to get their latest stars as a widget.

You can see it in action on overtiredpod.com, all the way down in the footer. I actually have never tried it as a sidebar widget, but it’s really simple markup and I’m just assuming it will work.

As with a lot of my little side projects, this one has a finite audience. A convergence of GitHub users who think their stars are worth sharing and happen to be running a WordPress blog. If that describes you, I have just the thing.

Check out the project page for more details. I doubt this will ever see many updates, but it’s tested with WP 5.7 and should be good for the foreseeable future.

WordPress GitHub Stars Widget v1.0.0

A WordPress widget to display your GitHub stars

Published 04/02/21.

Updated 04/02/21. Changelog

DonateMore info…

(I would add this to the WordPress plugin directory for fun, but you still have to set everything up in Subversion and I don’t even have svn installed these days, let alone remember how to use it. If it were a bigger project, I might consider it, but it’s just not worth it.)

SearchLink gets a bit more social

I was working on Systematic show notes today and, as always, making good use of SearchLink for quickly adding links to my notes. Then I ran into a LinkedIn handle and decided I needed a faster way to do that. Fast forward an hour.

Yes, I could have opened a browser, searched for the username, and copied the url 120 times in the time it took me to do this, but next time it’s going to be a cinch.

For a while now SearchLink has had the ability to turn @ttscoff into [@ttscoff](https://twitter.com/ttscoff), but not many other services, and that shorthand version only worked with Twitter. So, as of 2.2.16, you can now type i@ttscoff and get [instagram.com/ttscoff](https://www.instagram.com/ttscoff/) or l@BrettTerpstra and get [linkedin.com/in/BrettTerpstra](https://www.linkedin.com/in/BrettTerpstra/).

The services handled are Twitter (t), Facebook (f), Instagram (i) and LinkedIn (l). These work as above in single-line searches, or using the full syntax like [](!@i ttscoff), which is replaced with [instagram.com/ttscoff](https://www.instagram.com/ttscoff/).

The format of the linked text can be defined in your ~/.searchlink configuration file. The configuration option is social_template and uses the placeholders %url%, %user%, and %service%. You can combine these any way you like. As you can see in the examples above, my template is set to use an abbreviated url, e.g. social_template: "%url%". You can easily make them look like “ttscoff on Instagram” or “Instagram/ttscoff” with the placeholders. See the docs for details.

It’s a minor update, but as someone who interviews a lot of people, I’m constantly turning handles into links for show notes. This saves me a bunch of steps, so I’m not ashamed.

SearchLink v2.2.16

Generate Markdown links from web searches without leaving your editor.

Published 11/10/14.

Updated 03/31/21. Changelog

DonateMore info…

P.S. TextBuddy Stuff

An addendum because it’s so simple it doesn’t deserve its own post… I added another TextBuddy script that takes a bunch of methods in an Objective-C implementation file and turns them into declarations to stick in your interface. Basically just turns:

- (NSString *)myMethod:(NSString *)param {
   // BUTTLOAD OF CODE
}

- (NSString *)anotherMethod:(NSString *)param {
   // BUTTLOAD OF CODE
}

into…

- (NSString *)myMethod:(NSString *)param;
- (NSString *)anotherMethod:(NSString *)param;

It’s another one that there used to be an Xcode plugin for and I missed it.

You can find my slowly growing collection of TextBuddy scripts on GitHub.

Mind Maps and Marked 2

I know mind mapping isn’t for everybody, but if it’s for you, I’d like to remind you that Marked 2 works with some of the major Mac mind mapping apps, bringing mind mapping, markdown, and writing together for some amazing workflows.

I’ve written about all of these integrations individually before, but it’s been a while and I’ve had enough people seem shocked to find out about Marked’s mind map capabilities that it seemed like a good idea to put the info out there again. This was originally written as a newsletter for Marked subscribers, but it got longer than any email I’d ever want to receive, so I’m turning it into a blog post for everybody.

If you’d like to stay up to date on Marked 2, please do sign up for the mailing list. It offers tips, tricks, and news, as well as special discounts on my various apps and products.

(If you run popup blockers, the “Marketing Consent” field might not appear. If you get a “Consent not given” error, please reload the page without blockers and check the box. GDPR stuff…)

Prettier comments for flags and switches

A buddy of mine is ramping up his command-line fu lately. He’s a thorough notetaker, and he’s taken to commenting his shell code immaculately. I applaud this. He mentioned that he really liked this particular formatting for describing what each flag/switch in a command does:

I dug it, but my first though was how tedious it would be to type out, even with handy TextExpander snippets. So I made a thing. A silly little thing of limited utility, to be sure. But a thing.

The “Comment Flags” Service will simply scan a line for a grouping of characters following a dash, e.g. the “ltr” in ls -ltr *.md. It will then output a “diagram” for comments like what you see above (minus the actual comments), ready to be filled in.

It will work for multiple groupings (or even multiple single flags). For example, it provides this, ready for all the explaining:

It ignores long flags. They’re more descriptive anyway, but I might add some formatting for those in the future.

Figured I’d share this, just in case it scratches anyone else’s itch.

Comment Flags Service v1.0.0

A Service to make pretty comments for switches/flags in command line examples

Published 03/25/21.

Updated 03/25/21. Changelog

DonateMore info…

By the way, TextBuddy (this week’s gracious sponsor) can run Services now. That means things like this Service, all of the Markdown Service Tools, and even SearchLink can all work in TextBuddy from a single popup palette alongside its own extensive toolset. It’s a secret setting you have to enable from Terminal, but if you’re curious scroll down this page a bit. You know, to the part where Tyler says in 21pt type “Please Don’t Tell Anyone About This…”