Undistract-me: gets a notification when a long-running Terminal command is completed

Source: Internet
Author: User
Tags arch linux

Undistract-me: gets a notification when a long-running Terminal command is completed

Some time ago, we published How To Get notifications when terminal activities are completed. Today, I found a similar tool called "undistract-me", which can notify you when a long-running Terminal command is completed. Imagine this scenario. You run a command that takes some time to complete. At the same time, you can view your Facebook and participate in it. After a while, you remember that you executed a command a few minutes ago. You go back to the terminal and notice that the command is complete. However, you do not know when the command will be completed. Have you ever encountered this situation? I bet most of you have encountered this situation many times. This is what undistract-me can help. You do not need to check the terminal frequently to check whether the command is complete. After a long running command is completed, undistract-me will notify you. It can run on Arch Linux, Debian, Ubuntu, and other Ubuntu derivative versions.

 

Install Undistract-me

Undistract-me can be used in the default repository of Debian and its derivative versions (such as Ubuntu. All you need to do is run the following command to install it.

  1. sudoapt-get install undistract-me

Arch Linux users can use any help program to install it from AUR.

Use Pacaur:

  1. pacaur -S undistract-me-git

Use Packer:

  1. packer -S undistract-me-git

Use Yaourt:

  1. yaourt -S undistract-me-git

Then, run the following command to add "undistract-me" to Bash.

  1. echo'source /etc/profile.d/undistract-me.sh'>>~/.bashrc

Alternatively, you can run this command to add it to your Bash:

  1. echo"source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install">>.bashrc

If you are using Zsh shell, run the following command:

  1. echo"source /usr/share/undistract-me/long-running.bash\nnotify_when_long_running_commands_finish_install">>.zshrc

Finally, let the change take effect.

For Bash:

  1. source ~/.bashrc

For Zsh:

  1. source ~/.zshrc

 

Configure Undistract-me

By default, Undistract-me treats any command that exceeds 10 seconds as a long-running command. You can edit/usr/share/undistract-me/long-running.bashTo change the interval.

  1. sudonano/usr/share/undistract-me/long-running.bash

FindLONG_RUNNING_COMMAND_TIMEOUTVariable and default value (10Seconds.

Save and close the file. Do not forget to make the change take effect:

  1. source ~/.bashrc

In addition, you can disable notifications for specific commands. For this reason, findLONG_RUNNING_IGNORE_LISTVariables are separated by spaces as follows.

By default, notifications are displayed only when the active window is not the window for running commands. That is to say, it will notify you only when the command runs in the background terminal window. If the command is run in the terminal of the activity window, no notification is received. If you want to send notifications both visible in the terminal window and in the background, you canIGNORE_WINDOW_CHECKSet1To skip the window check.

Another cool feature of Undistract-me is that you can set audio and visual notifications when the command is complete. By default, only one visible notification is sent. You can add a variable on the command line.UDM_PLAY_SOUNDSet to a non-zero integer to change this behavior. However, your Ubuntu system should install the pulseaudio-utils and sound-theme-freedesktop programs to enable this function.

Remember, you need to run the following command to update the changes.

For Bash:

  1. source ~/.bashrc

For Zsh:

  1. source ~/.zshrc

It is time to verify whether this is true or not.

 

Get notifications when long-running Terminal commands are completed

Now, run any command that takes more than 10 seconds or that you have defined in the Undistract-me script.

On the Arch Linux desktop, run the following command:

  1. sudo pacman -Sy

This command took 32 seconds to complete. After the preceding command is complete, I receive the following notifications.

Remember, the Undistract-me script will notify you only when the given command takes more than 10 seconds to complete. If the command is completed within 10 seconds, you will not receive a notification. Of course, you can change the Interval Settings as described in the "configuration" section above.

I found this tool very useful. When I get lost in other tasks, it helps me back to the right thing. I hope this tool will also help you.

There are more tools. Be patient!

Cheers!

Resource:

  • Undistract-me GitHub Repository

Via: https://www.ostechnix.com/undistract-get-notification-long-running-terminal-commands-complete/

Author: sk Translator: geekpi Proofreader: wxy

This article was originally compiled by LCTT and launched with the honor of Linux in China

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.