Using iTerm2's Alert on Next Mark for Long Running commands
When you kick off a long running process from a terminal window, it’s common to then switch to another application while the process runs (in my case, when I’m deploying a number of resources to Azure using an ARM template). What’s even more common is to then forget about that terminal window because (for example) you’ve started to read the entire XKCD archive.
Recently, I read a tweet by @LawrenceGripper…
Optimization: When running a long running bash script use `longthing && notify-send bash "I'm done"` so you can browse/email but get notified when it's done (tested on ubuntu 18)— Lawrence Gripper (@lawrencegripper) July 2, 2018
Given I spend most of my terminal-time within iTerm2 on my Mac, this tweet made me wondered if there was something I could do within iTerm 2 that would give me a similar experience. It turns out there is!
iTerm2 has a feature called Alert on Next Mark, which is mentione in their online docs for :
Once you have the shell integration installed you can press ⌥⌘A (Opt+Cmd+A) any time you kick off a long running process in your terminal. When you do this, you’ll see an eye image appear top-right of your terminal window:
Now, you can go back to reading the internet while your long running task continues. At the point where it completes, iTerm2 will alert you with a MacOS alert:
This alert isn’t very descriptive, but it’s enough to wake me up from my slumber and get my attention.
One nice aspect of this feature is that you can set up an alert after you’ve run the command. So, if you were expecting something to complete quickly, but it’s taking forever, hit ⌥⌘A, go look at cat gifs, and wait for the alert.