The default alias Alert is for the command
notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"
Executing alert
gives an notification with text Alert and an terminal icon.
Executing it with one param like alert !!!!!
gives notification with text Alert !!!!! and !!!!!.
So, what's the difference between simple notify-send
command and this complexed alias which uses notify-send, echo, history, tail and sed?
In which situations is this alias useful or was it just created for pun(Something like using sudo sudo sudo sudo sudo apt-get install
I'm using Ubuntu 12.10
Best Answer
You could use the man pages to get details about what the commands combined here do. Here's a little about the purpose of those commands here:
This would echo terminal or error as per to the execution status - successful or fail respectively of the last command; and the result is as the value to the
-i
switch ofnotify-send
for displaying the icons...to get the last command executed.
and
sed
to parse the text to display it withnotify-send
message.To understand these try the following:
..this would echo terminal.
..this would echo error.
And,
..is very useful to know the exit value of the last command executed.
..nested
echo
as a simple demo for using$()
in a command combo.