diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index ebde281..d2d9a2e 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -35,8 +35,14 @@ function _auto_notify_message() { function _is_auto_notify_ignored() { local command="$1" + # split the command if its been piped one or more times + local command_list=("${(@s/|/)command}") + local target_command="${command_list[-1]}" + # Remove leading whitespace + target_command="$(echo "$target_command" | sed -e 's/^ *//')}" + for ignore in $AUTO_NOTIFY_IGNORE; do - if [[ "$command" == "$ignore"* ]]; then + if [[ "$target_command" == "$ignore"* ]]; then print "yes" return fi diff --git a/tests/test_auto_notify.zunit b/tests/test_auto_notify.zunit index d0c3891..bd99aff 100644 --- a/tests/test_auto_notify.zunit +++ b/tests/test_auto_notify.zunit @@ -66,6 +66,16 @@ done } +@test 'auto-notify-send does not send notification for ignored piped commands' { + AUTO_COMMAND="echo hello world | less -r" + AUTO_COMMAND_FULL="echo hello world | less -r" + AUTO_COMMAND_START=11000 + run _auto_notify_send + + assert $state equals 0 + assert "$output" is_empty +} + @test 'auto-notify-send does not send notification for ignored commands with arguments' { for command in $AUTO_NOTIFY_IGNORE; do AUTO_COMMAND="somealias bar -r"