2014-11-06 19:34:26 +01:00
|
|
|
# bgnotify zsh plugin
|
|
|
|
|
2023-11-23 20:00:34 +01:00
|
|
|
cross-platform background notifications for long running commands! Supports OSX and Linux.
|
2014-11-06 19:34:26 +01:00
|
|
|
|
|
|
|
Standalone homepage: [t413/zsh-background-notify](https://github.com/t413/zsh-background-notify)
|
|
|
|
|
2023-11-23 20:00:34 +01:00
|
|
|
---
|
2014-11-06 19:34:26 +01:00
|
|
|
|
2023-11-23 20:00:34 +01:00
|
|
|
## How to use
|
2014-11-06 19:34:26 +01:00
|
|
|
|
|
|
|
Just add bgnotify to your plugins list in your `.zshrc`
|
|
|
|
|
2018-01-23 04:14:32 +01:00
|
|
|
- On OS X you'll need [terminal-notifier](https://github.com/alloy/terminal-notifier)
|
2014-11-06 19:34:26 +01:00
|
|
|
* `brew install terminal-notifier` (or `gem install terminal-notifier`)
|
2023-11-23 20:00:34 +01:00
|
|
|
- On Linux, make sure you have `notify-send` or `kdialog` installed. If you're using Ubuntu you should already be all set!
|
|
|
|
- On Windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package
|
2014-11-06 19:34:26 +01:00
|
|
|
|
|
|
|
|
2014-11-08 23:20:37 +01:00
|
|
|
## Screenshots
|
|
|
|
|
|
|
|
**Linux**
|
|
|
|
|
|
|
|
![screenshot from 2014-11-07 15 58 36](https://cloud.githubusercontent.com/assets/326829/4962187/256b465c-66da-11e4-927d-cc2fc105e31f.png)
|
|
|
|
|
|
|
|
**OS X**
|
|
|
|
|
|
|
|
![screenshot 2014-11-08 14 15 12](https://cloud.githubusercontent.com/assets/326829/4965780/19fa3eac-6795-11e4-8ed6-0355711123a9.png)
|
|
|
|
|
|
|
|
**Windows**
|
|
|
|
|
|
|
|
![screenshot from 2014-11-07 15 55 00](https://cloud.githubusercontent.com/assets/326829/4962159/a2625ca0-66d9-11e4-9e91-c5834913190e.png)
|
|
|
|
|
|
|
|
|
2014-11-06 19:34:26 +01:00
|
|
|
## Configuration
|
|
|
|
|
|
|
|
One can configure a few things:
|
|
|
|
|
2023-12-01 17:09:48 +01:00
|
|
|
- `bgnotify_bell` enabled or disables the terminal bell (default true)
|
2014-11-06 19:34:26 +01:00
|
|
|
- `bgnotify_threshold` sets the notification threshold time (default 6 seconds)
|
2023-11-23 20:00:34 +01:00
|
|
|
- `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon.
|
2014-11-06 19:34:26 +01:00
|
|
|
|
|
|
|
Use these by adding a function definition before the your call to source. Example:
|
|
|
|
|
2023-11-23 20:00:34 +01:00
|
|
|
```sh
|
2023-12-01 17:09:48 +01:00
|
|
|
bgnotify_bell=false ## disable terminal bell
|
2014-11-06 19:34:26 +01:00
|
|
|
bgnotify_threshold=4 ## set your own notification threshold
|
|
|
|
|
|
|
|
function bgnotify_formatted {
|
|
|
|
## $1=exit_status, $2=command, $3=elapsed_time
|
2023-11-23 20:00:34 +01:00
|
|
|
|
|
|
|
# Humanly readable elapsed time
|
|
|
|
local elapsed="$(( $3 % 60 ))s"
|
|
|
|
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
|
|
|
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
|
|
|
|
|
|
|
|
[ $1 -eq 0 ] && title="Holy Smokes Batman" || title="Holy Graf Zeppelin"
|
|
|
|
[ $1 -eq 0 ] && icon="$HOME/icons/success.png" || icon="$HOME/icons/fail.png"
|
|
|
|
bgnotify "$title - took ${elapsed}" "$2" "$icon"
|
2014-11-06 19:34:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
plugins=(git bgnotify) ## add to plugins list
|
|
|
|
source $ZSH/oh-my-zsh.sh ## existing source call
|
2023-11-23 20:00:34 +01:00
|
|
|
```
|