Simplify Mac OSX quote workaround

This commit is contained in:
Michael Aquilina 2019-07-17 16:17:03 +01:00
parent 1a022b8f68
commit f70c3a654e
No known key found for this signature in database
GPG key ID: 636066730B056BD1

View file

@ -18,14 +18,15 @@ function _auto_notify_message() {
local command="$1" local command="$1"
local elapsed="$2" local elapsed="$2"
# Run using echo -e in order to make sure notify-send picks up new line # Run using echo -e in order to make sure notify-send picks up new line
text_linux="$(echo -e "\"$command\" has completed\n(Total time: $elapsed seconds)")" text="$(echo -e "\"$command\" has completed\n(Total time: $elapsed seconds)")"
text_darwin="$(echo -e "\\\"$command\\\" has completed\n(Total time: $elapsed seconds)")"
platform="$(uname)" platform="$(uname)"
if [[ "$platform" == "Linux" ]]; then if [[ "$platform" == "Linux" ]]; then
notify-send "$text_linux" notify-send "$text"
elif [[ "$platform" == "Darwin" ]]; then elif [[ "$platform" == "Darwin" ]]; then
osascript -e "display notification \"$text_darwin\" with title \"Command Completed\"" # We need to escape quotes since we are passing a script into a command
text="${text//\"/\\\"}"
osascript -e "display notification \"$text\" with title \"Command Completed\""
else else
printf "Unknown platform for sending notifications: $platform\n" printf "Unknown platform for sending notifications: $platform\n"
printf "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/\n" printf "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/\n"