Check commands to ignore after alias expansion

This commit is contained in:
Michael Aquilina 2019-07-14 18:22:46 +01:00
parent fc92fa6951
commit 070eea8265
No known key found for this signature in database
GPG key ID: 636066730B056BD1
2 changed files with 14 additions and 4 deletions

View file

@ -1,8 +1,14 @@
export AUTO_NOTIFY_VERSION="0.1.0"
# Command that the user has executed
AUTO_COMMAND=""
# Full command that the user has executed after alias expansion
AUTO_COMMAND_FULL=""
# Command start time in seconds since epoch
AUTO_COMMAND_START=0
# Threshold for when to automatically show a notification
AUTO_NOTIFY_THRESHOLD=5
# List of commands/programs to ignore sending notifications for
AUTO_NOTIFY_IGNORE=("vim" "nvim" "emacs" "less" "more" "man")
autoload -Uz add-zsh-hook
@ -29,7 +35,7 @@ function _is_auto_notify_ignored() {
function _auto_notify_send() {
local current="$(date +"%s")"
if [[ "$(_is_auto_notify_ignored "$AUTO_COMMAND")" == "yes" ]]; then
if [[ "$(_is_auto_notify_ignored "$AUTO_COMMAND_FULL")" == "yes" ]]; then
return
fi
@ -42,6 +48,7 @@ function _auto_notify_send() {
function _auto_notify_track() {
AUTO_COMMAND="$1"
AUTO_COMMAND_FULL="$2"
AUTO_COMMAND_START="$(date +"%s")"
}