From 22998c6f4a233bcce9b8f14b9cc01d02c9290b00 Mon Sep 17 00:00:00 2001 From: Toshiki Murayama Date: Wed, 17 Jul 2019 10:30:40 +0900 Subject: [PATCH] Escape backslash in notification message for macOS --- auto-notify.plugin.zsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index 2b9b161..2c01df6 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -18,13 +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 - text="$(echo -e "\"$command\" has completed\n(Total time: $elapsed seconds)")" + text_linux="$(echo -e "\"$command\" has completed\n(Total time: $elapsed seconds)")" + text_darwin="$(echo -e "\\\"$command\\\" has completed\n(Total time: $elapsed seconds)")" platform="$(uname)" if [[ "$platform" == "Linux" ]]; then - notify-send "$text" + notify-send "$text_linux" elif [[ "$platform" == "Darwin" ]]; then - osascript -e "display notification \"$text\" with title \"Command Completed\"" + osascript -e "display notification \"$text_darwin\" with title \"Command Completed\"" else printf "Unknown platform for sending notifications: $platform\n" printf "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/\n"