Artboard 16light, inspiration, solution, idea, innovation,ionicons-v5_logosGoogle Sheets iconSwift icon
Published at
Updated at
Reading time
2min
This post is part of my Today I learned series in which I share all my web development learnings.

We all know the problem; sometimes, you 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 discover 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 daily long-running commands, this approach works very well, but some commands take more time unexpectedly.

While reading the excellent labnotes newsletter, I learned that iTerm2 offers telling you when a command has finished. It doesn't require changing or chaining your slow CLI command.

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.

iTerm "notify on new mark" modus showing an eye in the right corner.

The handy thing about this feature is that you can enable it via a shortcut (cmd + alt + a), too. 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!

iTerm session notifying when a command finished

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 . ๐Ÿ™ˆ

Was this TIL post helpful?
Yes? Cool! You might want to check out Web Weekly for more quick learnings. The last edition went out 14 days ago.

Related Topics

Related Articles