iTerm2 offers a way to notify you when a long-running command has finished
- Published at
- Updated at
- Reading time
We all know the problem; sometimes, you have to run a terminal command, and it takes ages. In the meantime, you start browsing YouTube or Twitter and completely forget about the thing you wanted to do. Thirty minutes later, you find out that your command finished 25min ago.
To work around this problem, I usually have snippets for common commands ready that notify me when they are finished. The
say command is a popular choice to let your computer speak to you.
<command> && say "done"
For long-running commands that I use daily, this approach works very well, but some commands take more time unexpectedly.
To let iTerm notify you, you must have iTerm's shell integration installed. The shell integration comes with many advanced functionalities to make your CLI life more manageable, and it includes marks. After installing the shell integration, go into program controls, navigate to
Edit -> Marks and Annotations -> Alerts and enable
Alert on next mark.
You might ask, "Okay, cool! But what's a mark, Stefan?". According to the iTerm docs, marks are history entries.
Marks are saved locations in history. They make it easy to navigate to previous shell prompts or other locations of interest.
Whenever a new entry is written to the shell history, iTerm registers a new mark. And for these marks, you can turn on notifications. 🎉 After enabling notifications you see an eye displayed in the right corner.
One handy thing about this feature is that you can enable it via a shortcut (
cmd + alt + a), too. With this functionality at hand, you can kick-off a long-running
npm install, hit the key combination, and start browsing Twitter without wasting too much time, because you'll get notified when your command has finished. Awesome!
If you want to learn more about all the iTerm features I use (the status bar, ZSH theme, etc.), check out my post Settings to emojify and prettify your terminal . 🙈
- "HTML End Tag Labels" – a useful VSCode extension to navigate HTML
- Online RSS readers send follower counts in their user agent string
- github1s – open any GitHub repository in VS Code in your browser
- Tips and tricks to navigate your project files in VS Code
- slowfil.es – a service for slow assets with high priority