Undistract-me Sends An Alert For Time-Consuming Commands in Linux
In Linux, some commands executed in the terminal such as make, wget, dd may take a while, so usually you’d just let them run in the background, and do some other work, drink tea, go for nap… while they are running, and come to check from time to time if the command has completed. Sometimes I even forget I run a particular command, and realize it has completed a few hours ago… It’s possible to add some command at the end of your command line, but it can be cumbersome, and you may forget to do it. The best would be automatic alerts for commands that take a long time, and undistract-me just takes care of that by sending an alert for commands that take more than 10 seconds (by default).
In Ubuntu 12.04 and 12.10, you can install undistract-me as follows:
sudo add-apt-repository ppa:undistract-me-packagers/daily sudo apt-get update sudo apt-get install undistract-me
Undistract-me is part of Ubuntu 13.04 or greater repository, so you can just use apt-get install directly.
For other Linux based operating systems, you should be able to use it by installing the source (bash scripts), and manually running the commands below:
git clone git://github.com/jml/undistract-me.git . undistract-me/long-running.bash notify_when_long_running_commands_finish_install
One easy way to test it, is to simply run “sleep 11“, and make sure your terminal window is in the background, or the notification won’t show up. The first time I tried, it failed, and found out on webupd8, that “Run command as a login shell” must be enabled in your terminal. In Ubuntu 12.04, go to “Edit->Profile Preferences”, and enable the option.
if the 10 seconds delay is not suitable for you, you can simply edit the script (/usr/share/undistract-me/long-running.bash), and change LONG_RUNNING_COMMAND_TIMEOUT default, or export your preferred value in ~/bashrc.
The script uses “notify-send” to show the message above, and this is fine as long as you are in front of your computer, but if you want to be informed while you are away, you can also use your own command to send an SMS or a tweet to your phone for example. Simply export LONG_RUNNING_COMMAND_CUSTOM and LONG_RUNNING_COMMAND_CUSTOM_TIMEOUT with respectively your chosen command and your chosen “long command” time.