Add enable/disable functionality
This commit is contained in:
parent
73b47b1383
commit
bd83266ccf
3 changed files with 30 additions and 3 deletions
|
@ -9,6 +9,7 @@ has completed.
|
||||||
* Usage_
|
* Usage_
|
||||||
* Requirements_
|
* Requirements_
|
||||||
* Installation_
|
* Installation_
|
||||||
|
* `Temporarily Disabling Notifications`
|
||||||
* Contributing_
|
* Contributing_
|
||||||
* `Running Tests`_
|
* `Running Tests`_
|
||||||
|
|
||||||
|
@ -66,6 +67,13 @@ Then add this line to your ``.zshrc``. Make sure it is **before** the line ``sou
|
||||||
|
|
||||||
plugins=(auto-notify $plugins)
|
plugins=(auto-notify $plugins)
|
||||||
|
|
||||||
|
Temporarily Disabling Notifications
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
You can temporarily disable auto notify by running the command ``disable_auto_notify``.
|
||||||
|
|
||||||
|
When you want to re-enable notifications, run the command ``enable_auto_notify``.
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,15 @@ function _auto_notify_track() {
|
||||||
AUTO_COMMAND_START="$(date +"%s")"
|
AUTO_COMMAND_START="$(date +"%s")"
|
||||||
}
|
}
|
||||||
|
|
||||||
autoload -U add-zsh-hook
|
function disable_auto_notify() {
|
||||||
|
add-zsh-hook -D preexec _auto_notify_track
|
||||||
|
add-zsh-hook -D precmd _auto_notify_send
|
||||||
|
}
|
||||||
|
|
||||||
|
function enable_auto_notify() {
|
||||||
add-zsh-hook preexec _auto_notify_track
|
add-zsh-hook preexec _auto_notify_track
|
||||||
add-zsh-hook precmd _auto_notify_send
|
add-zsh-hook precmd _auto_notify_send
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
enable_auto_notify
|
||||||
|
|
|
@ -26,6 +26,16 @@
|
||||||
assert '_auto_notify_send' in $precmd_functions
|
assert '_auto_notify_send' in $precmd_functions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test 'enable/disable auto-notify' {
|
||||||
|
disable_auto_notify
|
||||||
|
assert '_auto_notify_track' not_in $preexec_functions
|
||||||
|
assert '_auto_notify_send' not_in $precmd_functions
|
||||||
|
|
||||||
|
enable_auto_notify
|
||||||
|
assert '_auto_notify_track' in $preexec_functions
|
||||||
|
assert '_auto_notify_send' in $precmd_functions
|
||||||
|
}
|
||||||
|
|
||||||
@test 'auto-notify-send does not send notification for short task' {
|
@test 'auto-notify-send does not send notification for short task' {
|
||||||
AUTO_COMMAND="foo bar -r"
|
AUTO_COMMAND="foo bar -r"
|
||||||
AUTO_COMMAND_START=11099
|
AUTO_COMMAND_START=11099
|
||||||
|
|
Loading…
Add table
Reference in a new issue