Skip to content

Instantly share code, notes, and snippets.

@wjandrea
Last active January 23, 2019 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wjandrea/1d1aa893414bf4e4dbe230cd6b42fac0 to your computer and use it in GitHub Desktop.
Save wjandrea/1d1aa893414bf4e4dbe230cd6b42fac0 to your computer and use it in GitHub Desktop.
Ubuntu "alert" alias as function
#!/bin/bash
# You can source this script to get the "alert" function.
function alert {
# Alert after a long running command.
# Use like so: "sleep 2; alert"
local exit=$? # Must go first!
local img=terminal
local msg="$(fc -nl -1 | sed -e 's/^\s\+//; s/\s*[;&|]\s*alert$//')"
[[ $exit -ne 0 ]] && img=error
notify-send --urgency=low -i "$img" -- "$msg"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment