All posts by admin

Popping up a notification on completion of a shell command

It often happens that you execute a shell command which takes too long to execute and you waste your time checking the terminal from time to time to check if the command has been completed.

I was thinking it would be better if I can be notified by a pop-up message that the command has been executed.  Searching on the web, about creating a pop-up message using shell commands, i came across xmessage command. Then, i wrote a script in which i pass the command to be executed as a single argument by enclosing it in double quotes. By executing this script, my command starts executing and when it is completed, i get a pop-up message in center of screen notifying it's completion.

Here's the script:
# !/bin/sh
USAGE="USAGE: `basename $0`  shell_command"

if [ $# -eq 0 ]
echo $USAGE >&2
exit 1

# parse command line arguments
if  [ $# -eq 1 ]

xmessage -center command `echo $1` has been executed

I named this script as So, an example usage of this script to unzip a large file would be :

$ ./ "tar xvzf filename.tar.gz"

Since bash completion doesn't work under quotes, it would be a better idea to type the actual command first using bash completion, then copy it and pass as an argument to Maybe there exists better way of achieving the desired effect. If you know one, please leave behind a comment.