From 6c5586cb085d5cc6fb42b7304428654cc6bf5f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6blom?= Date: Thu, 23 Nov 2023 19:00:34 +0000 Subject: [PATCH] docs(bgnotify): match README with current features (#12057) --- plugins/bgnotify/README.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md index 1d8fac54d..6bbe3b302 100644 --- a/plugins/bgnotify/README.md +++ b/plugins/bgnotify/README.md @@ -1,19 +1,19 @@ # bgnotify zsh plugin -cross-platform background notifications for long running commands! Supports OSX and Ubuntu linux. +cross-platform background notifications for long running commands! Supports OSX and Linux. Standalone homepage: [t413/zsh-background-notify](https://github.com/t413/zsh-background-notify) ----------------------------------- +--- -## How to use! +## How to use Just add bgnotify to your plugins list in your `.zshrc` - On OS X you'll need [terminal-notifier](https://github.com/alloy/terminal-notifier) * `brew install terminal-notifier` (or `gem install terminal-notifier`) -- On ubuntu you're already all set! -- On windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package +- 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 ## Screenshots @@ -36,19 +36,26 @@ Just add bgnotify to your plugins list in your `.zshrc` One can configure a few things: - `bgnotify_threshold` sets the notification threshold time (default 6 seconds) -- `function bgnotify_formatted` lets you change the notification +- `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon. Use these by adding a function definition before the your call to source. Example: -~~~ sh +```sh bgnotify_threshold=4 ## set your own notification threshold function bgnotify_formatted { ## $1=exit_status, $2=command, $3=elapsed_time - [ $1 -eq 0 ] && title="Holy Smokes Batman!" || title="Holy Graf Zeppelin!" - bgnotify "$title -- after $3 s" "$2"; + + # 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" } plugins=(git bgnotify) ## add to plugins list source $ZSH/oh-my-zsh.sh ## existing source call -~~~ +```