• Stars
    star
    404
  • Rank 106,897 (Top 3 %)
  • Language
    Shell
  • License
    GNU General Publi...
  • Created over 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⏰ ZSH plugin that automatically sends out a notification when a long running task has completed.

ZSH Auto-Notify

CircleCI Version GPLv3

Simple zsh plugin that automatically sends out a notification when a long running task has completed.

Useful for those commands you don't predict will take long to run or just plain forgot to keep track of. Leave the task running and go do something else - auto-notify will let you know when the task is done! 🎉

Usage

You don't need to do anything. Once it's installed, zsh-auto-notify will let you know if a long running task has completed its work via a notification in your desktop environment.

img/notification-example.png

Requirements

auto-notify officially supports zsh versions 5.1 onwards.

It is possible the plugin might work on even older versions. However they would not have been tested as part of the CI test process.

Supported desktop environments:

  • Linux X/Wayland (Requires notify-send to be installed)
  • MacOSX

Installation

Add one of the following to your .zshrc file depending on your package manager:

ZPlug

zplug "MichaelAquilina/zsh-auto-notify"

Antigen

antigen bundle "MichaelAquilina/zsh-auto-notify"

Zgen

zgen load "MichaelAquilina/zsh-auto-notify"

Fig

Install zsh-auto-notify with Fig in just one click.

Install with Fig

oh-my-zsh

Copy this repository to $ZSH_CUSTOM/custom/plugins, where $ZSH_CUSTOM is the directory with custom plugins of oh-my-zsh (read more):

git clone https://github.com/MichaelAquilina/zsh-auto-notify.git $ZSH_CUSTOM/plugins/auto-notify

Then add this line to your .zshrc. Make sure it is before the line source $ZSH/oh-my-zsh.sh.

plugins=(auto-notify $plugins)

Configuration

Notification Threshold

By default, auto-notify will send notifications for tasks that take longer than 10 seconds. You can configure this value by setting the environment variable AUTO_NOTIFY_THRESHOLD:

# Set threshold to 20seconds
export AUTO_NOTIFY_THRESHOLD=20

Notification Formatting

You can change the formatting of notifications by setting the values for AUTO_NOTIFY_TITLE and AUTO_NOTIFY_BODY. When writing these values, the following variables will be replaced according to the data that auto-notify has detected:

  • %command - the command that the user executed
  • %elapsed - number of seconds that elapsed
  • %exit_code - the exit code of the command that was executed

An example of how these values can be set is shown below:

export AUTO_NOTIFY_TITLE="Hey! %command has just finished"
export AUTO_NOTIFY_BODY="It completed in %elapsed seconds with exit code %exit_code"

Notification Expiration Time

You can set how long a notification sent by auto-notify will remain showing by setting the environment variable AUTO_NOTIFY_EXPIRE_TIME to a custom value in milliseconds. The default value is set to 8 seconds. NOTE: This configuration option currently only works for Linux.

# Set notification expiry to 10 seconds
export AUTO_NOTIFY_EXPIRE_TIME=10000

Ignored Commands

A number of commands do not get notifications for long running times due to their nature (e.g. watch or man). The list of ignored commands is specified in the AUTO_NOTIFY_IGNORE environment variable. This can be modified or completely overwritten based on your use case.

# Add docker to list of ignored commands
AUTO_NOTIFY_IGNORE+=("docker")

Make sure that you append to the array above after your plugin manager has been loaded in your zshrc.

If you wish to completely redefine what is ignored and not ignored, then just set AUTO_NOTIFY_IGNORE to a new array.

# redefine what is ignored by auto-notify
export AUTO_NOTIFY_IGNORE=("docker" "man" "sleep")

Using a Whitelist to ignore commands

If you wish to use a whitelist approach instead of the default blacklist approach used by AUTO_NOTIFY_IGNORE, you can do so by defining the environment variable AUTO_NOTIFY_WHITELIST with the elements you wish to allow auto-notify to track and send notifications for. NOTE: If AUTO_NOTIFY_WHITELIST is defined, then all the values in AUTO_NOTIFY_IGNORE are not used.

export AUTO_NOTIFY_WHITELIST=("apt-get" "docker")

Temporarily Disabling Notifications

You can temporarily disable auto notify by running the command disable_auto_notify.

When you want to re-enable notifications, run the command enable_auto_notify.

Contributing

Pull requests and Feedback are welcome! 🎉

I have tried to cater for as many use cases that I can think of. However, they are naturally tailored to to my own workflow and I could be missing many others.

Because of this if there is a specific use case that does not work as you would expect or if you have any suggestions to how the plugin should behave, feel free to open an issue

Running Tests

Install zunit. Run zunit in the root directory of the repo.

$ zunit
Launching ZUnit
ZUnit: 0.8.2
ZSH:   zsh 5.3.1 (x86_64-suse-linux-gnu)

✔ version exported
✔ hook functions are loaded by default
✔ enable/disable auto-notify
✔ auto-notify-send does not send notification for short task
✔ auto-notify-send does not send notification for ignored commands

NOTE: It is required that you use a minimum zunit version of 0.8.2

More Repositories

1

zsh-you-should-use

📎 ZSH plugin that reminds you to use existing aliases for commands you just typed
Shell
1,458
star
2

zsh-autoswitch-virtualenv

🐍 ZSH plugin to automatically switch python virtualenvs (including pipenv and poetry) as you move between directories
Shell
422
star
3

python-tools

🔧 Atom plugin which uses jedi to provide numerous tools useful for developing python code in atom.
Python
99
star
4

flake8-spellcheck

❄️ Spellcheck variables, classnames, comments, docstrings etc
Python
71
star
5

S4

🔄 Fast and cheap synchronisation of files using Amazon S3
Python
71
star
6

synapse-project

Powerful fuzzy search launcher for a multitude of tasks
Vala
49
star
7

improved-workspace-indicator

gnome-shell extension that provides a workspace indicator similar to i3/sway
JavaScript
41
star
8

lifx-cmd

💡 Command line tool for controlling LifX bulbs
Python
39
star
9

ubuntu-ansible

Set up a Ubuntu machine from scratch
Python
37
star
10

hashedindex

Python package providing an Inverted Index implementation using dictionaries
Python
34
star
11

wdisplays

GUI display configurator for wlroots compositors
C
28
star
12

zsh-history-filter

🔍 Zsh plugin to filter out some commands from being added to you history
Shell
28
star
13

tro

Trello command line utility written in Rust
Rust
27
star
14

Some-2D-RPG

Tinkering with Game Development
C#
27
star
15

Fuzzy-Logic-Controller

A simulator for a boiler with a fuzzy logic controller to control the pressure.
C#
15
star
16

zsh-emojis

Variables for numerous ascii emojis!
Shell
14
star
17

git-commands

Various helpful git commands for your git workflow
Shell
11
star
18

flake8-graphql

Flake8 plugin to lint your GraphQL query strings in Python
Python
11
star
19

tumbleweed-ansible

Setup an OpenSUSE Tumbleweed Machine from scratch
Shell
10
star
20

Web-Scraping-Scripts

A Random set of Scripts that can be used on various machines
Python
8
star
21

Reddit-Recommender-Bot

Indentifying Interesting Documents for Reddit using Recommender Techniques
Python
7
star
22

Windows-Pixel-Ruler

A simple tool to measure the pixel length of items on the screen.
C#
6
star
23

SDL2-Pong

Development of Pong with SDL2
C++
5
star
24

SpamFilter

Classification of emails using machine learning and natural language processing techniques in Java
TeX
5
star
25

Whatsappium

Firefox and Chrome extension that allows you to use Keyboard shortcuts for Whatsapp Web
JavaScript
4
star
26

apm-ansible

Manage your Atom packages using ansible
Python
3
star
27

todolist

Simple todolist manager to keep track of my daily life from the command line
Python
3
star
28

gsettings-ansible

Control gsettings using ansible!
Python
3
star
29

me-thinks-it-is-like-a-weasel

Simple Genetic Algorithm inspired by Richard Dawkin's "The Blind Watchmaker"
Python
2
star
30

Snakes

Multiplayer Snakes for UNIX based terminals developed using C and Ncurses.
C
2
star
31

fedora-ansible

Setup a fedora machine using ansible from scratch
Shell
2
star
32

smart-light-ui

Gtk UI for interacting with Smart Light bulbs
Python
2
star
33

Document-Classification

Classification of SGML documents using Natural Language Processing and Machine Learning techniques
C#
1
star
34

swayconfig

Sway Configuration files
Shell
1
star
35

atom-better-window-title

Improve Atom's window title
JavaScript
1
star
36

atom-pgp

🔑 Atom plugin to open and save PGP encrypted files
CoffeeScript
1
star
37

Notebook

Python notebook with various commands
Python
1
star
38

restructured-preview

Atom package to preview restructured text files
Python
1
star
39

Reddit-Data

Archive for post data from several subreddits to be used for a Recommender Agent
Python
1
star
40

pytextparser

Python
1
star
41

adventofcode2018

My solutions to advent of code 2018 in Rust
Rust
1
star
42

NeuralNetwork

A Neural Network library in C#
C#
1
star
43

Resume

Personal Resume
1
star
44

zshrc

Personal zshrc configuration file
Shell
1
star
45

adventofcode2020

Solutions for https://adventofcode.com/2020/
Rust
1
star
46

i3config

i3 configuration files
Python
1
star
47

adventofcode2021

Rust
1
star