2

I've recently discovered notify-send, which opens up a notification window, so I can do things like:

compile && notify-send "Done!" || notify-send "Failed"

This made me thing that maybe I want to create a variable:

export NS="&& notify-send \"Done!\" || notify-send \"Failed\""

and then I could easily add it to many command lines for which I want notifications:

compile $NS
send-big-file $NS
start-a-heavy-job $NS

etc. But this obviously doesn't work as it is, and I can't seem to be able to come up with the right combination of variable substitutions to make it work... any ideas?

1 Answer 1

6

Write a function that takes the command as an argument (untested):

ns() {
    "$@" && notify-send Done || notify-send Failed
}

ns compile
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.