Welcome to the lab.

Just a SearchLink fix

I noticed last week as I was working on show notes for Overtired #238 that SearchLink was returning raw search urls instead of the results I expected. I didn’t have time to look at it until this weekend, so I finished the show notes jumping back and forth between my editor and my web browser, like some kind of primitive beast. I think I have it sorted now, though, and I just published version 2.2.17 which should fix the issue. Download below or visit the project page.

If you have no idea what I’m talking about but do any writing for the web, do yourself a favor and check it out. I even made some tutorials for you. Out of all the tools I’ve created, it’s among my most loved. Like top three. Maybe top two. I’ll be honest, it might just be my favorite1.

SearchLink v2.2.17

Generate Markdown links from web searches without leaving your editor.

Published 11/10/14.

Updated 05/15/21. Changelog

DonateMore info…

Nitty Gritty©

If you’re curious: something changed in the way DuckDuckGo’s nginx server responds to header requests, so the location: line wasn’t showing up in a curl request. Which is baffling. It threw a curl: (3) URL using bad/illegal format or missing URL error every time I tried to curl -SsLI (follow redirects and return headers), yet would redirect properly if I left the -I (return just response headers) out. So now SearchLink is doing a full download of the destination page just to get the location headers, but it works.

(Hopefully someday there will be a search engine with an actual API that doesn’t require all of this hacking. Google used to have one but they canned it years ago and made scraping impossible. DuckDuckGo puts up with scraping, for now, but I really do hope they offer an actual search API someday, like they do with Instant Answers.)

Side Note: Pinboard Searches

Since we’re talking SearchLink, I’d like to point out a feature I added a while back but hadn’t used all that much until recently. If you add your Pinboard API key in the config file, you can search your Pinboard bookmarks and insert the URL for the top match with the !pb search type. I’ve been using this more as of late because Hook can now create a private Pinboard bookmark every time you hook a web page (or even just copy a Hook link). So now any time I hook a page that I know will be of interest in the future, it’s readily available to my SearchLink searches, offering a nice, finite set of possibilities that all but guarantees I’ll get the URL I was hoping for.

  1. Don’t tell Marked 2, nvUltra, or Bunch, they all currently think they’re the favorite child. 

Catching up with progress

Well, I finally updated the Jekyll instance that runs this blog. If everything went to plan, this post will be the inauguration of a new era. One that looks a lot like the last era, hopefully.

My Jekyll install had been stuck in about 2012 because a lot of the custom plugins I’d written over the years required very specific versions of various libraries, and it was working, so it got left alone. Then I got an M1 Mac mini, and my very specific requirements became impossible.

Much of the transition to Apple Silicon is easy, thanks to most developer’s readiness1 combined with Rosetta and Universal Binary, but anyone who spends time on the command line will know that things are a little stickier once you get into your shell. After wrestling with Mackup, brew bundle, and dotbot for a weekend, I got things mostly working.

The Homebrew community has done a great job of updating brew formulae for ARM compilation, and I only had trouble with about 3% of my (fairly large) Brewfile when I installed it on the M1. (It does, however, install everything to /opt/homebrew instead of /usr/local/bin, so I had to update a few scripts here and there where I’d hardcoded paths. But easy enough.)

However, Node and Ruby are a little bit stickier. If you want the latest versions of either, no problem, the edge builds are fine on ARM. But if you need, say, Node 10 and Ruby 2.6.5 for something (like this blog), you’re in trouble. You can kind of work around the Node issue by launching Terminal (or iTerm) using Rosetta (Get Info -> Open Using Rosetta) and using the arch command to fake an Intel machine, but no such luck with Ruby. Big Sur on the M1 ships with Ruby 2.6.3. If you want to use another version, you can install 3.0.1. That’s it. That’s all that will actually build.

So I’ve been updating everything to use newer versions of the various tools. The last thing that was keeping me from letting go of my Intel MacBook Pro was this blog. (Well, that and Izotope plugins for Logic Pro X. I really miss the RX plugins — which crash Logic on the M1 — and hope they get their act together soon.) I spent the weekend rewriting Jekyll plugins, giving up a few that I didn’t really need anymore, and revamping some templates and scripts as needed to work with Jekyll 4.

I have a 2012 Mac mini that actually handles the final build/deploy of this site (I needed an always-on machine to handle post scheduling hackery). It takes that machine about 30 minutes to render this blog with about 2100 posts dating back to 2010. I had gotten used to it. Now, with Jekyll 4 on an M1 Mac mini, it builds in 3-4 minutes. And that’s with all the crazy plugins I wrote to create tag indexes, search tools, related posts, and myriad other shenanigans. Running without plugins, it builds in about 30 seconds. Not bad!

I haven’t had time to pore over the site thoroughly and see if anything broke that I didn’t account for. Everything I consider vital seems to be working. If you’re looking around and something seems amiss, please let me know!

I’ll post again soon with some news about the new job I started last week at Oracle, some cool new stuff in the Bunch beta, and some updates to other projects that I’ve squeezed in despite the whole corporate day job thing.

  1. And then there’s me, who didn’t realize Marked 2 had reverted back to Intel-only after some library changes. Update forthcoming. 

Web Excursions for April 28, 2021

Web excursions brought to you in partnership with MindMeister, the best collaborative mind mapping software out there.

This is a very developer-centric excursions post. I spent too long looking at git utilities this week, so you get a bunch of links to cool git stuff I found. If you are, somehow, a developer who doesn’t care about git, be sure to check out the last link anyway.

dandavision/delta
I’ve been using diff-so-fancy with git for a long time, but recently discovered delta. It does way more, with in-line diffs, side-by-side view, and themed output. It even makes copying text out of a diff easier by removing the +/- by default.
Git Town
A set of git utilities that works on top of your favorite workflow (e.g. git-flow) and provides high-level (but simpler) commands for creating and shipping feature branches. I especially like git town sync for updating your working feature branch with all changes from the develop branch and updating remotes in one command.
sobolevn/git-secret: A bash-tool to store your private data inside a git repository.
A git command that allows you to store secret information (credentials, etc.) as encrypted files in a repo. Automates ignoring the original and adding an encrypted copy. Allow others access based on public PGP keys.
MichaelMure/git-bug
Distributed, offline-first bug tracker embedded in git, with bridges for major bug tracking apps (GitHub, Gitlab, Jira, Launchpad). Stores tickets as git objects that can move with a repo without affecting history. It even has a GUI for terminal and a web view.
Mac Dev Survey 2021 Results | Tower Blog
The new Mac Dev Survey results are out. Turns out I’m in some smaller segments these days (I still use Sublime and everyone else uses VS Code). Fun results to look at, though (at least for devs).

Check out MindMeister and start brainstorming, collaborating, and boosting productivity.

Peek brings text selection back to Quick Look (+Giveaway)

There used to be a defaults write trick that would allow you to select text in Quick Look previews, but Apple curtailed it back in 2015. Since then, dragging your cursor on any Quick Look plugin just moves the window. No selection possible, and thus no copy paste from the preview.

Enter Peek, an $8 macOS extension that brings back text selection in Quick Look, at least for source code and Markdown files (which it also syntax highlights and renders, respectively). Both of the latter features do have free alternatives, so the primary draw here is text selection. That, and having your syntax highlighting and Markdown rendering all in one plugin.

In addition to working in Finder, Peek includes support for HoudahSpot, Path Finder and Forklift.

While I have some guesses, I don’t know exactly how Peek is working this magic. All I know is that I’ve really missed text selection in Quick Look, and Peek has solved it. (I’ll also mention that I had some weirdness on my machine that ultimately had nothing to do with Peek, but the developer spent a good week helping me track down the problem. ★★★★★ Great support.)

I have 10 copies of Peek to give away to BrettTerpstra.com readers. Sign up below to enter the drawing. Winners receive a Mac App Store promo code for Peek, value $8 US. Ten winners will be picked at random on Friday, April 30th at 12PM Central.

Entering a giveaway does not subscribe you to any newsletters. If you’d like to get occasional announcements, special offers, and whatever else I come up with, please sign up for the BrettTerpstra.com mailing list separately.

Sorry, this giveaway has ended.

If you can’t wait to get your text selection back, check out Peek today.

Hacking around with Marked’s Streaming Preview

In the last Marked newsletter I wrote a bit about Marked’s Streaming Preview, a feature of Marked that flew under the radar for a few years before starting to gain some traction.

It’s a special window (Preview->Streaming Preview) that watches a private clipboard for updates, updating the preview every time the clipboard contents change. All an app needs to do to interface with it is write Markdown content to the named clipboard, which is easily done from any Swift/Objective-C instance. Normally Marked watches files on the disk for changes, but this special window allows apps to update the preview in Marked without ever writing to disk, and with closer-to-live update speeds. Apps like Drafts, Bear, and The Archive have all implemented it with great results. (I even added some special processing for Bear users, so a majority of the Polar syntax translates to your live Marked 2 preview.)

Because the only trick to using the Streaming Preview is to write to a clipboard, it’s possible to do it in your own scripts as well. You just need to write to a pasteboard named “mkStreamingPreview” and Marked will do the rest.

As an example, Bruno Conte created a Keyboard Maestro macro that will take any currently-selected text and update the Marked preview. Marked has a “Preview Clipboard” command, of course, but that requires copying the text, switching to Marked, and hitting ⇧⌘V — and it opens a new window every time. This macro means you can just select text and hit a keyboard shortcut to live-update the preview window from any application.

Here’s the Keyboard Maestro macro: Copy and Stream to Marked. In order to use it, you’ll need Python’s PyObjC module installed, so if needed, open Terminal and run: pip install PyObjC.

The crux of the macro is in the Python script:

def stream_to_marked(data):
	from AppKit import NSPasteboard
	pb = NSPasteboard.pasteboardWithName_("mkStreamingPreview")
	pb.clearContents()
	pb.setString_forType_(data.decode('utf-8'), 'public.utf8-plain-text')

You can incorporate this kind of script in whatever tools you like. The macro also makes use of Marked 2’s url handler for opening the Streaming Preview externally: just call open x-marked://stream/.

See the docs for more implementation details (including settings a base URL for relative paths). If you come up with cool new ways to use this, I’d love to hear about it. And if you’d like to see Marked’s Streaming Preview integrated into your favorite app, just put the developers in touch with me!

Want to get Marked tips (and special discounts) in your inbox? Sign up for the mailing list!

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.