feat(bgnotify): add option to disable terminal bell (#12077)
Diff
1diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md
2index 6bbe3b3025d30005ebd2b881131813afd754090b..33d529f1588b3be73a7e89ae98fd696c615a8e69 100644
3--- a/plugins/bgnotify/README.md
4+++ b/plugins/bgnotify/README.md
5@@ -35,12 +35,14 @@ Just add bgnotify to your plugins list in your `.zshrc`
6 7 One can configure a few things:
8 9+- `bgnotify_bell` enabled or disables the terminal bell (default true)
10 - `bgnotify_threshold` sets the notification threshold time (default 6 seconds)
11 - `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon.
1213 Use these by adding a function definition before the your call to source. Example:
1415 ```sh
16+bgnotify_bell=false ## disable terminal bell
17 bgnotify_threshold=4 ## set your own notification threshold
1819 function bgnotify_formatted {
20diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh
21index 4499d816cd4545864724fbb951191196ba21ed62..3c0766191479e7b8dea9b8a2e257fc2949ff86fc 100644
22--- a/plugins/bgnotify/bgnotify.plugin.zsh
23+++ b/plugins/bgnotify/bgnotify.plugin.zsh
24@@ -27,7 +27,7 @@ function bgnotify_end {
25 # check if Terminal app is not active
26 [[ $(bgnotify_appid) != "$bgnotify_termid" ]] || return
2728- printf '\a' # beep sound
29+ [[ $bgnotify_bell = true ]] && printf '\a' # beep sound
30 bgnotify_formatted "$exit_status" "$bgnotify_lastcmd" "$elapsed"
31 } always {
32 bgnotify_timestamp=0
33@@ -136,6 +136,9 @@ function bgnotify {
3435 ## Defaults
3637+# enable terminal bell on notify by default
38+bgnotify_bell=${bgnotify_bell:-true}
39+
40 # notify if command took longer than 5s by default
41 bgnotify_threshold=${bgnotify_threshold:-5}
42