Last active
January 23, 2019 16:48
-
-
Save wjandrea/1d1aa893414bf4e4dbe230cd6b42fac0 to your computer and use it in GitHub Desktop.
Ubuntu "alert" alias as function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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