I'm a diehard Karabiner user and anytime I start doing something repetitively I always move it into my Karabiner configuration. Sometimes I'll fall into scenarios where I want to trigger a command, but I also want to know if that command succeeded or failed. Since Karabiner can trigger any command, setting up the command is fairly straightforward, but knowing whether it succeeded or failed became much more difficult. Luckily for me there is a package called terminal-notifier that you can install from homebrew and you can pipe the output of your command to terminal-notifier. And have a seamless way of triggering your keyboard shortcut which runs a command and you can be notified of the results.
Transcript
[00:00] My quick mode layer activates when I press Q, so if I press Q and G it'll run the Goku command and that recompiles my carabiner file. Unfortunately every time I run this it either succeeds or fails silently. To display a notification we can install the terminal notifier from Homebrew and then we're going to pipe the output of whatever the result is from this, including the standard errors, we'll pipe this to the terminal notifier with the default sound. Meaning that if I save this I'll recompile and that time it was silent. Now we'll recompile with Q and D.
[00:34] And this time you can see, done. If there's some sort of syntax error, like I'll delete this quote, hit save, Q and D, we'll see there's an exception, invalid token, or If the command is missing, we'll change it to goke. I'll run it once to recompile. I'll run it again. And this time it says goke is missing because it recompiled and now this is missing.
[00:55] But if we fix this and then we run goku to fix it, now with Q and gee, we're back in business.