Using howzit as a task runner

I’ve become fairly dependent on howzit for running my builds and deploys (and other tasks). By setting up a buildnotes.md file for each project, containing @run(task) lines for each section, I can always run howzit -r build to build or deploy, no matter what task runner/build system I set up for it. npm, yarn, gulp, grunt, rake, make, it doesn’t matter. I can get the right build command every time without a second thought.

As a shortcut, I have a function called bld that runs howzit -r with a default argument of “build” but accepting alternate arguments. In Bash that’s as easy as howzit -r ${1:build}, but in Fish I have to use my fallback function:

# Fish functions for howzit shortcuts

function fallback --description 'allow a fallback value for variable'
  if test (count $argv) = 1
    echo $argv
  else
    echo $argv[1..-2]
  end
end

function bld -d "Run howzit build system"
  howzit -r (fallback $argv build)
end

Shell Completion

In the latest version of howzit (published today), I added some new options for getting completion-compatible lists of sections. The -L switch does the same as -l (list all sections), but without color, header, or list markers. The -R and -T switches list all sections containing @run (or @copy, @open, etc.) directives that could be run with howzit -r. The -R version makes the list verbose, showing exactly what each section will run, and -T gives you just a “task list”, perfect for completion. The repository now includes some Fish tab-completion commands using these options. I haven’t set them up for other shells yet, but all the ingredients are there now.

Supplemental: Let’s Get Weird With That

Recently I got one of those fancy MacBook Pros with the Touch Bar. (Obviously I got it about a month before Apple announced the 16” with the better keyboard, as would be my persistent luck.) Nonetheless, I’ve been trying — really trying — to make that Touch Bar useful on the machine I have. BetterTouchTool is a hoot with it, but I think I finally found a use that’s truly a time-saver. At least a little.

It started when I found the “touchrunner” package for Fish that checks for a package.json file when you switch into a directory, setting the function keys in the Touch Bar to any npm tasks listed there. Great if you do everything with npm (or yarn), but with howzit I could make that universal. So I did.

I’m just showing it off here. I’m happy to share the plugin (a hack of touchrunner) upon request, but given that it requires the very specific combination of iTerm, Fish, a Touch Bar Mac, and the use of howzit, it seems like a pretty narrow slice of audience to deal with packaging it for general use. Just a neat trick for now.

Brett Terpstra

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff on Twitter, GitHub, and Mastodon. Keep up with this blog by subscribing in your favorite news reader.

This content is supported by readers like you.