Welcome to the lab.

Fish (shell) fun: event handlers

[Tweet : nvALT]

In my last post on the Fish shell, I brazenly stated that “because of the way that Fish handles the prompt function, there’s no easy way to hook it without modifying the original theme files.” That was 100% incorrect, as I figured out the next day.

Fish has the ability to specify that any function act as an event handler. You can attach to the event fish_prompt to have the function run right before the prompt displays. So my revised function in my init file is:

function __should_na --on-event fish_prompt
  set -l cmd (history --max=1|awk '{print $1;}')
  set -l cds cd z j popd g
  if contains $cmd $cds
    test -s (basename $PWD)".taskpaper" && ~/scripts/fish/na

Now I no longer need to edit the theme files directly at all, which is much more how I’d prefer things to be. As an alternative to fish_prompt, you can also attach to variables changing, which means you can use PWD to run the function any time the working directory changes. That would look like:

function __should_na --on-variable PWD

Also, any function can use the emit command to add its own hook. The example from the docs is nice and succinct:

function event_test --on-event test_event
    echo event test: $argv

emit test_event something

This is one area where the Fish documentation seems lacking: there’s no list of available hooks nor (that I can find) any way to retrieve a list of emitted events in the shell. It’s been trial and error for me thus far. Hopefully someone will correct me if I’m wrong here. Update, someone (evanrelf) did correct me in the comments: you can find a list of all named events using function -h.

Ok, so that’s an extended correction to my last post, but it’s a cool enough aspect of Fish that it seemed worth covering on its own.

Branching out from Bash: Fishing expedition

[Tweet : nvALT]

Given that Apple has already switched the default shell in Catalina from Bash to Zsh, I’ve been thinking I really need to expand from Bash. Don’t get me wrong, I love Bash and I’ve spent years molding it to my liking. The amount of time I’ve put into it and the ease with which that investment allows me to use it has always made switching to anything else seem, well, like a waste of time. But now I feel stuck. To that end, I’ve been stretching out and trying to shake off my fear of getting to know other shells.

I decided to spend some time getting comfortable with Zsh and Fish (the Friendly Interactive SHell). I started with Fish, building a configuration on weekends. Three weekends now and I’m comfortable enough to use it as my regular shell during the week.

Fish features advanced autosuggestion and expansions, does cool syntax highlighting, offers a “sane” scripting toolset, has an array of existing plugins and themes, and even sports a browser-based configuration tool that’s pretty awesome. So here are some random notes from my travels. This is a journal, not a tutorial, containing my impressions and a few tips.

The Shortcuts Field Guide Giveaway

[Tweet : nvALT]

As is always the case with David Sparks’ Field Guides, the iOS 13 edition of The Shortcuts Field Guide got a great response when I mentioned it here. And once again David has kindly provided a few extra codes for BrettTerpstra.com readers. And yes, if you win a code but already purchased the Guide, you can gift it to someone you think deserves it!

There are five magic codes available that will give the winner free access to the MacSparky Shortcuts Field Guide, iOS 13 edition videos. Enter a name and email address below to be eligible to win one (1) coupon ($29US value) in a random drawing on Friday, October 11th, at 12:00 CST.

Sorry, this giveaway has ended.

Web Excursions for September 30, 2019

[Tweet : nvALT]

Brett holding map

Web excursions brought to you in partnership with CleanMyMac X, all the tools to speed up your Mac, in one app.

A tool similar to calend.ly or WhenWorks, but built for Messages. Nail down a meeting time by offering available slots and letting the correspondent just pick one.
Learn vim For the Last Time: A Tutorial and Primer
I always feel like I’m going back to the beginning to get a better grasp on Vim. This was a great tutorial.
Simple Opt Out
Deep links to opt-out of data sharing by 60+ companies.
Markdown Tables for iOS
In the vein of TableFlip, Markdown Tables is an iOS app for the creation and editing of Markdown-formatted tables for use in combination with your favorite Markdown editor. From the creator of Trunk Notes, the now-defunct iOS wiki app that I still have a soft spot for.
Untitled Goose Game
Yeah, I know, everybody’s already talking about this game (to the extent that I had to try it), but it’s worth the buzz. Cathartic.

CleanMyMac X

nvUltra news, September

[Tweet : nvALT]

Ok, another month, another nvUltra update. As I’d warily predicted, my initial hopes for an August release slipped, and I’m currently making more conservative predictions. I’m not going to put an ETA on it this time, but before you grow concerned, let me tell you where things are at and why I’m being cautious.

We’ve added another 500 testers from the initial signup list at this point, plus a slew of additional edge-case testers, and we have our hands full keeping up with feedback and forum posts from the current pool of users. Fletcher works in a hospital ER, and I have my own side-pursuits (not a Doctor) to pay the bills while we develop this, so it’s 2 part-time guys working with 1000+ users and a very active beta feedback forum. There’s a lot of excitement, though, and it makes it a lot of fun to continue interacting with everyone.

Bunch 1.2: no more redundant Bunches

[Tweet : nvALT]

First off, I promise an nvUltra update this week. You deserve it. In the meantime…

I woke up at three this morning. As you may have come to expect, I’ve added stuff to Bunch, my batch app launcher and current too-awake-to-sleep-too-tired-to-do-real-work project. I think this new feature will save a few users (and myself) some time: I’m calling it “snippets,” which is an uncreative way of saying you can now use templated actions with variables in a Bunch.

Tower presents Tech Animals, great merch, great charity

[Tweet : nvALT]

Tower, the makers of the eponymous Git client, have a history of providing design-oriented products in addition to their elegant app. You may recall the Developer Manifesto poster I ran a giveaway for last year. Their latest product line is a fantastic followup.

Tech Animals is a reimagining of all of the animals that become logos for our favorite tech projects, from the Linux Penguin and the Firefox to the Swift bird and the Perl camel, you’re sure to find beautifully illustrated versions of your favorite project’s mascot. All available as posters, coffee mugs, and t-shirts.

Here’s the cool part, though: 100% of profits are going to Hacker School, a project that inspires children to get started with programming while also offering refugees an IT education. Visit the shop and get some great design for a worthy cause.

The MacSparky Shortcuts Field Guide

[Tweet : nvALT]

If you get into the kind of automation I offer on this blog, or maybe wish you did if it weren’t for all the coding, then Shortcuts on iOS is either on your radar or should be. And David Sparks has just the thing.

Released today, the latest MacSparky Field Guide is Shortcuts, the iOS 13 edition. Apple has dedicated more resources to automation on iOS than they have for a long time on macOS, and Shortcuts offers a way to harness the power without having to write a single line of code.

The course includes 6 hours+ of video training and 107 separate videos. Learn to build simple apps, automate your meetings, do things like have your iPad enter “focus mode” when you connect to coffeehouse wifi or send an automated message when you’re running late with an accurate ETA.

The MacSparky Shortcuts Field Guide costs $29 US, but for a limited time you can use the code LAUNCHSHORTCUTS to bring the price down to $24. Check it out!