Merge pull request #6 from mrymtsk/mac-notification-fix
Escape backslash in notification message for macOS
This commit is contained in:
commit
d6d00f5cc7
1 changed files with 4 additions and 3 deletions
|
@ -18,13 +18,14 @@ 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="$(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)"
|
platform="$(uname)"
|
||||||
|
|
||||||
if [[ "$platform" == "Linux" ]]; then
|
if [[ "$platform" == "Linux" ]]; then
|
||||||
notify-send "$text"
|
notify-send "$text_linux"
|
||||||
elif [[ "$platform" == "Darwin" ]]; then
|
elif [[ "$platform" == "Darwin" ]]; then
|
||||||
osascript -e "display notification \"$text\" with title \"Command Completed\""
|
osascript -e "display notification \"$text_darwin\" 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"
|
||||||
|
|
Loading…
Add table
Reference in a new issue