diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2022-01-01 02:26:11 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2022-01-01 02:26:11 -0600 |
commit | 49edbf438ed690c76e6b2af80368c59404cf0167 (patch) | |
tree | 129b3adb2f5f39a1329a426a3b7d51ed2c2290c1 /plugins/zbell | |
parent | 1bc186dabe12b3d01b2257e82f3a104c48b8b3c7 (diff) | |
parent | 78c91ccbf99c77bd4d9cdb74279a40776721f66d (diff) | |
download | zsh-49edbf438ed690c76e6b2af80368c59404cf0167.tar.gz zsh-49edbf438ed690c76e6b2af80368c59404cf0167.tar.bz2 zsh-49edbf438ed690c76e6b2af80368c59404cf0167.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'plugins/zbell')
-rw-r--r-- | plugins/zbell/README.md | 3 | ||||
-rw-r--r-- | plugins/zbell/zbell.plugin.zsh | 17 |
2 files changed, 18 insertions, 2 deletions
diff --git a/plugins/zbell/README.md b/plugins/zbell/README.md index 1c1c13546..eb87699c4 100644 --- a/plugins/zbell/README.md +++ b/plugins/zbell/README.md @@ -24,6 +24,9 @@ These settings need to be set in your zshrc file, before Oh My Zsh is sourced. zbell_ignore=($EDITOR $PAGER) ``` +- `zbell_use_notify_send`: If set to `true`, `notify-send` tool is used -- if + available -- to display a popup on the screen. Default: `true` (enabled). + ## Author Adapted from an original version by [Jean-Philippe Ouellet](https://github.com/jpouellet). diff --git a/plugins/zbell/zbell.plugin.zsh b/plugins/zbell/zbell.plugin.zsh index 6d0416502..8e374029b 100644 --- a/plugins/zbell/zbell.plugin.zsh +++ b/plugins/zbell/zbell.plugin.zsh @@ -29,18 +29,31 @@ autoload -Uz regexp-replace || return # initialize zbell_ignore if not set (( ${+zbell_ignore} )) || zbell_ignore=($EDITOR $PAGER) +# initialize zbell_use_notify_send if not set +(( ${+zbell_use_notify_send} )) || zbell_use_notify_send=true + # initialize it because otherwise we compare a date and an empty string # the first time we see the prompt. it's fine to have lastcmd empty on the # initial run because it evaluates to an empty string, and splitting an # empty string just results in an empty array. zbell_timestamp=$EPOCHSECONDS +# UI notification function +# $1: command +# $2: duration in seconds +zbell_ui_notify() { + [[ $zbell_use_notify_send != "true" ]] && return + + if type notify-send > /dev/null; then + notify-send -i terminal "Command completed in ${2}s:" $1 + fi +} + # default notification function # $1: command # $2: duration in seconds zbell_notify() { - type notify-send > /dev/null && \ - notify-send -i terminal "Command completed in ${2}s:" $1 + zbell_ui_notify "${@}" print -n "\a" } |