Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to generate notifications when certain commands finish execution. I'm trying to use xmessage or notify-send to generate this notification.

Right now, I'm trying it this way:

command; notify-send ...;

But I might have multiple such commands running – I want to distinguish between them. So I'm trying to get the PID and name of the process that finished. The problem is, the two processes (<command> and notify-send) aren't related.

Any hints or pointers on what to look for?

share|improve this question
up vote 2 down vote accepted

Make a notifier script (~/bin/notifyme)...

(eval "$@")
notify-send "$1 finished" "Command returned $?."

...or a function (~/.bashrc):

notifyme() {
    (eval "$@")
    notify-send "$1 finished" "Command returned $?."

This is the easiest way.

share|improve this answer
That seems to get everything done. – Utkarsh Sinha Oct 11 '11 at 22:24
Is there a way to get auto completion to work? like notify partialcommand <tab> etc? – Utkarsh Sinha Oct 11 '11 at 22:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.