Alert provides a cross-platform means of displaying a notification to the user in Julia. It should work on MacOS, Windows 10 (even under WSL2) and many flavors of Linux. This is handy for long-running scripts. You can also use an extension (AlertPushover) to send notifications to your phone or a webapp when working remotely.
There are three ways to use alert:
alert()after a long-running piece of code.
- Put long-running code inside the
alertREPLand any long-running code sent to the REPL will display a notification.
alert() at the end of a long-running script, it would be good to test that it
actually works on your system: some linux distros may not have an appropriate program
installed to display the notification. Loading
Alert should warn you if it can't find an
appropriate executable to send the notification. Just read the error message that is
displayed to see what program you need to install.
Table of Contents:
alert() just add it to some long-running code.
using Alert for i in 1:10_000 long_running_function() end alert("Your julia script is finished!")
@alert macro displays a message if the code passed to it runs for longer
than 2 seconds (or a custom value). This is especially handy when using
ProgressMeter, like so.
@alert @showprogress for i in 1:10_000 long_running_function() end
The REPL hook
In Julia 1.5 or greater, if you want any long-running command at the REPL to send a
notification, you can use
alertREPL. It takes the same arguments as
@alert and will wrap
any code passed to the Julia REPL in a call to
You can add the following to your
startup.jl file to have it work in every Julia
try using Alert alertREPL() catch e @warn e.msg end
- Notification fails to display on Windows: check to make sure you have Notifications turned on in "Notifications & actions" in your OS settings.
If you want to use
alert remotely or in an online IDE, where you can't get local UX
notifications, you can use AlertPushover.