2

I've been setting an alias that running Apple Script on Terminal. As below:

alias playda="osascript -e 'tell application "QuickTime Player"
    activate
    set thisFile to open POSIX file "path.m4a"
    play thisFile
end tell'"

And Zsh always reports an error:

.zshrc:19: number expected

I think it relates to the quotes. Could anyone show me how to handle this, please?

Thank you very much!

0

2 Answers 2

1

Use escape characters (\) :

alias playda="osascript -e 'tell application \"QuickTime Player\"'"

I'm not on a Mac so I'm not sure about the single-quotes, but escaping the double-quotes is the key to the solution.

0

In shell scripts, a function is almost always easier to work with than an alias:

playda() {
  osascript -e 'tell application "QuickTime Player"
    activate
    set thisFile to open POSIX file "path.m4a"
    play thisFile
    end tell'
}

Not the answer you're looking for? Browse other questions tagged .