iTerm2 offers a way to notify you when a long-running command has finished (#tilPost)

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…

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.

While reading the excellent labnotes newsletter, I learned that iTerm2 offers a nice way to tell you when a command has finished. It doesn’t require changing or chaining the command you want to run.

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.

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 . ?



Reply to Stefan


Print Share Comment Cite Upload Translate
APA
Stefan Judis | Sciencx (2024-03-28T08:24:50+00:00) » iTerm2 offers a way to notify you when a long-running command has finished (#tilPost). Retrieved from https://www.scien.cx/2020/12/20/iterm2-offers-a-way-to-notify-you-when-a-long-running-command-has-finished-tilpost/.
MLA
" » iTerm2 offers a way to notify you when a long-running command has finished (#tilPost)." Stefan Judis | Sciencx - Sunday December 20, 2020, https://www.scien.cx/2020/12/20/iterm2-offers-a-way-to-notify-you-when-a-long-running-command-has-finished-tilpost/
HARVARD
Stefan Judis | Sciencx Sunday December 20, 2020 » iTerm2 offers a way to notify you when a long-running command has finished (#tilPost)., viewed 2024-03-28T08:24:50+00:00,<https://www.scien.cx/2020/12/20/iterm2-offers-a-way-to-notify-you-when-a-long-running-command-has-finished-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » iTerm2 offers a way to notify you when a long-running command has finished (#tilPost). [Internet]. [Accessed 2024-03-28T08:24:50+00:00]. Available from: https://www.scien.cx/2020/12/20/iterm2-offers-a-way-to-notify-you-when-a-long-running-command-has-finished-tilpost/
CHICAGO
" » iTerm2 offers a way to notify you when a long-running command has finished (#tilPost)." Stefan Judis | Sciencx - Accessed 2024-03-28T08:24:50+00:00. https://www.scien.cx/2020/12/20/iterm2-offers-a-way-to-notify-you-when-a-long-running-command-has-finished-tilpost/
IEEE
" » iTerm2 offers a way to notify you when a long-running command has finished (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2020/12/20/iterm2-offers-a-way-to-notify-you-when-a-long-running-command-has-finished-tilpost/. [Accessed: 2024-03-28T08:24:50+00:00]
rf:citation
» iTerm2 offers a way to notify you when a long-running command has finished (#tilPost) | Stefan Judis | Sciencx | https://www.scien.cx/2020/12/20/iterm2-offers-a-way-to-notify-you-when-a-long-running-command-has-finished-tilpost/ | 2024-03-28T08:24:50+00:00
https://github.com/addpipe/simple-recorderjs-demo