Welcome to the lab.

Web Excursions for November 12, 2019

[Tweet : nvALT]

Brett holding map

Web excursions brought to you in partnership with Codecademy, the easiest way to learn to code.

renameutils
I’m loving this tiny set of CLIs for renaming files. This links to the project page, but you can install them through Homebrew (brew install renameutils). qmv and qcp open a list of target files in an editor, where you can rename them using whatever editor tools you need, and then save to apply the changes. imv and icp provide readline editing of a filename in place. Super handy.
While you’re at it, check out rename, also on Homebrew, for a pipeline approach, and the vidir command from moreutils for another approach to the qmv trick.
Augmented Text Editing on Mobile: The New iOS 13 Gestures
From the Ulysses blog but not Ulysses-specific, a rundown of new gestures for text editing on iOS 13. Did you know there are 3-finger pinch commands for copy, cut, and paste? I didn’t.
Clicker for Hulu
I’m a user of the Mac app Clicker for Netflix, and was happy to see that DBK Labs now has the same type of player for Hulu. It integrates native macOS features with the service’s players, and include PIP and hacks for things like skipping the stupid mini-player that Hulu brings up when you close a show. Some interesting touch bar support, too.
rhydlewis/search-omnifocus
An Alfred workflow that allows free text searching of OmniFocus tasks and projects. A really nice example of Alfred’s power. Now someone needs to make this for LaunchBar…
How to display the size of an app’s frontmost window
Thanks to Rob Griffiths I now have a mouse gesture that shows me the pixel dimensions of whatever window I have in the foreground. Which is actually something I happened to need…

Codecademy Pro

Fish: further exploration

[Tweet : nvALT]

Over the past few months I’ve been playing with Fish, the Friendly Interactive SHell, and I’ve posted a couple of times on the topic. I think I’m sold on it now, and you’ll probably be seeing a lot more Fish posts than Bash ones (though I’ll try to offer Bash equivalents when possible).

So I’ve officially chsh‘d to /usr/local/bin/fish and am 100% comfortable using it day to day. For the record, I did spend some time with Zsh as well, but it just didn’t tickle the same fancy as Fish has for me.

Here are some of my tips, tricks, and observations since my last post.

Hook 1.3

[Tweet : nvALT]

Hook is a productivity app from CogSci Apps that connects your files, emails, web urls, and other digital breadcrumbs to each other. I’ve mentioned it here and there, but my most detailed writeup was at Lifehacker a little while back.

Hook applies a principle from cognitive productivity: “deep work requires rapidly re-accessing pertinent information without searching.” Hook allows you to stay in flow by keeping all of your related resources a couple of keystrokes away, no matter what you’re working on.

The latest update to Hook (v1.3) brings a streamlined UI, reorganized menu commands (with more keyboard shortcuts), and the ability to navigate links without leaving the Hook window.

You can check Hook out for free. BrettTerpstra.com readers who decide to dive into Hook Pro can use the coupon UH1ME-ttscoff for 20% off the list price (which is currently $19, but will be going up to $24 soon!).

To apply the coupon for a discount purchase of Hook, visit the checkout page. During the checkout process, which is mediated by Paddle.com (the merchant of record), there will be an “Add Coupon” link in small font below “Your total is $…”. Tick the checkbox, and then enter the coupon code.

Howzit: Remember how what you work on works

[Tweet : nvALT]

Back in April I posted a short script for keeping track of the various build systems I use in my projects. You know when you open a directory you haven’t worked on for a while and there’s a Gulp file, a Rakefile, a node_modules folder, and various other cruft that means you’ll have to dig through to recall what commands you were using to build and deploy the project? Or when you know there were specific flags you were using to get the build to work, but you never got around to automating them? It’s for those situations, and other general sanity.

Over the rest of this year I’ve slowly modified and expanded the script as I’ve wanted it to do things differently or better. I’ve been hesitant to post the results because it really feels like something nobody else is going to need and it’s entirely possible that I’ve put too much time into it already. I did stop myself before turning it into a fully packaged gem, so good on me.

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
  end
end

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
end

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.