A Hook CLI for Terminal goodness

I’ve created a command line utility called hook that brings a lot of Hooks power to the terminal. You can find it at https://github.com/ttscoff/hookapp where you’ll also find installation instructions. Spoiler, it’s a ruby gem and you can install it by simply running gem install hookapp (you may need sudo gem install hookapp depending on your setup).

The main command is hook and it’s built to use subcommands, a la git. All commands are detailed under hook help, and you can get details on a specific command using hook help COMMAND.

There’s some brief documentation on the GitHub page as well.

You can let me know how it goes here or in the Issues section of the GitHub repo.

12 Likes

Fantastic! CLI was one of my early internal feature request for Hook as SLC product ( Simple Lovable Complete product, as opposed to MVP.). How fitting that it should be Brett Terpstra himself who delivers the goods!

One of us here at CogSci Apps has tried your CLI and happily reports success! She notes , it return an error message when the url is invalid

error: no implicit conversion of false into String

I am looking forward to trying it too.

I will reply to the hook://email URL topic

A bit more feedback from a developer here:

I only tested files, web urls and emails.

I just did some test with other types of urls:

The following commands not working:
hook clip
“bear://x-callback-url/open-note?id=C24C1EEB-F5FF-4B06-B033-BB2A19BFA2EB-877-0000016BBABE4FFC”
hook clip nvalt://find//?NV=FGNrz%2BwTQlSmGLofWgauqQ%3D%3D

for the above types of urls, hook select , hook list also not working

more investigation from our side tomorrow.

I just pushed v0.0.3 to both the gem server and to GitHub. Should fix usage with all urls. I think it should fix the “conversion of false to string” issue as well, though I probably should have tested that further before this release. Next one!

-Brett

1 Like

0.0.4 pushed, does actually fix that string conversion error now :).

2 Likes

The latest version of the gem with Hook 2.0 compatibility (2.0.3) is live now. Use gem install hookapp (or gem update hookapp if already installed). Note that, depending on your Ruby setup, you may need to use sudo gem....

Full documentation is available on GitHub.

1 Like

Does this mean I’m going to want to learn Ruby after all? I’m only half joking; If learning Ruby buys me more Hook functionality I would do it.

You don’t have to learn any Ruby to use the CLI, it works like any other command line tool. If you’re comfortable in Terminal, that’s all you need!

  • Brett
2 Likes

Right. I meant more generally…

… Is Ruby the language to make Hook dance and sing? (If I feel the need.)

No, AppleScript is. I simply used Ruby to call osascript, which is the macOS AppleScript runner.

  • Brett
2 Likes

Just wanted to thank you for this. I’ve been recently toying with Task Warrior and wanted the ability to call hooks with taskopen. This did the trick beautifully.

2 Likes

Thanks for making this! It works really well with Hazel and 2Do’s URL scheme. I made a rule in Hazel to watch a folder of text files for the string @todo and then create a 2Do task once one appears. This is the embedded script in Hazel that I managed to get working after some trial and error.

hook clip $1
HOOKLINK=$(pbpaste)
LONG_FILENAME="$1"

SHORT_NAME=$(basename "$LONG_FILENAME")
open "twodo://x-callback-url/add?task=$SHORT_NAME&type=0&forlist=Inbox&tags=hooked&action=url:$HOOKLINK"
2 Likes