From 6c5586cb085d5cc6fb42b7304428654cc6bf5f31 Mon Sep 17 00:00:00 2001 From: Johan Sjöblom Date: Thu, 23 Nov 2023 19:00:34 +0000 Subject: docs(bgnotify): match README with current features (#12057) --- plugins/bgnotify/README.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'plugins/bgnotify/README.md') 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 -~~~ +``` -- cgit v1.2.3-70-g09d2 From 0a9d82780e20e24b6fafc5b2aaefedb0957986c9 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Fri, 1 Dec 2023 17:09:48 +0100 Subject: feat(bgnotify): add option to disable terminal bell (#12077) --- plugins/bgnotify/README.md | 2 ++ plugins/bgnotify/bgnotify.plugin.zsh | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins/bgnotify/README.md') diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md index 6bbe3b302..33d529f15 100644 --- a/plugins/bgnotify/README.md +++ b/plugins/bgnotify/README.md @@ -35,12 +35,14 @@ Just add bgnotify to your plugins list in your `.zshrc` One can configure a few things: +- `bgnotify_bell` enabled or disables the terminal bell (default true) - `bgnotify_threshold` sets the notification threshold time (default 6 seconds) - `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 +bgnotify_bell=false ## disable terminal bell bgnotify_threshold=4 ## set your own notification threshold function bgnotify_formatted { diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index 4499d816c..3c0766191 100644 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -27,7 +27,7 @@ function bgnotify_end { # check if Terminal app is not active [[ $(bgnotify_appid) != "$bgnotify_termid" ]] || return - printf '\a' # beep sound + [[ $bgnotify_bell = true ]] && printf '\a' # beep sound bgnotify_formatted "$exit_status" "$bgnotify_lastcmd" "$elapsed" } always { bgnotify_timestamp=0 @@ -136,6 +136,9 @@ function bgnotify { ## Defaults +# enable terminal bell on notify by default +bgnotify_bell=${bgnotify_bell:-true} + # notify if command took longer than 5s by default bgnotify_threshold=${bgnotify_threshold:-5} -- cgit v1.2.3-70-g09d2