We’re all stuck once in a while waiting for a long command to execute. Most of the times its some sort of a package manager install that gets 100 packages from repositories and installs them on your system.
Even on a blazing fast internet connection, it can take a while to install all the packages. Or maybe you’re compiling a gem from source. You dont necessarily have to sit around staring at the console waiting for the command to complete. And ubuntu can notify you when the command is done executing.
First of all, let’s see how desktop notifications work on ubuntu
The notification server in ubuntu (which is what handles the notification server) can be manually invoked by using the notify-send command
notify-send "message" "description"
This command will show you a notification on ubuntu. This service is used by almost all of the programs on ubuntu (Network Connection, Volume Up/Down)
So the trick is to use the service to send a notification when a command executes. To do this, we need to create a shell script that executes whatever command it is passed and shows a notification whenever the command is finished executing
sudo vi /usr/bin/n
# file location : /usr/bin/n
notify-send "Task Completed"
sudo chmod +x /usr/bin/n
Now you can type “n” before any command and you’ll receive a notification when the command is done executing for example:
n npm install
n rails g model User