From eecf71b040e89ed639ebb459d5bbab572855513f Mon Sep 17 00:00:00 2001 From: Michael Aquilina Date: Mon, 15 Jul 2019 10:08:15 +0100 Subject: [PATCH] Add support for MacOSX --- auto-notify.plugin.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index 98c09f3..b36fd8c 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -18,7 +18,14 @@ function _auto_notify_message() { local command="$1" local elapsed="$2" # Run using echo -e in order to make sure notify-send picks up new line - echo -e "\"$command\" has completed\n(Total time: $elapsed seconds)" + text="$(echo -e "\"$command\" has completed\n(Total time: $elapsed seconds)")" + platform="$(uname)" + + if [[ "$platform" = "Linux" ]]; then + notify-send "$text" + elif [[ "$platform" == "Darwin" ]]; then + display notification "$text" with title "Command Completed" + fi } function _is_auto_notify_ignored() { @@ -42,7 +49,7 @@ function _auto_notify_send() { let "elapsed = current - AUTO_COMMAND_START" if [[ -n "$AUTO_COMMAND" && $elapsed -gt $AUTO_NOTIFY_THRESHOLD ]]; then - notify-send "$(_auto_notify_message "$AUTO_COMMAND" "$elapsed")" + _auto_notify_message "$AUTO_COMMAND" "$elapsed" fi }