The shell tag, available as the global $. Runs the template text with /bin/zsh
in strict mode (set -euo pipefail), with each interpolated value shell-escaped into the
command as a literal word — selected text, file paths, anything: it can never become shell
syntax. Requires the script entitlement, and may only be used during the action phase —
the same gate, failure rules and result as runShellScript.
constresult = await$`date +%A`; popclip.showText(`Today is ${result}`);
The template text is used raw: everything between the backticks goes to the shell
exactly as written, so backslashes survive ($`grep -c '\.txt'` works) and JavaScript
escape sequences are not interpreted. Two consequences: don't put your own quotes around
an interpolation (it arrives already quoted), and write shell variables as $VAR rather
than ${VAR} (which JavaScript would claim).
Interpolated values may be strings, finite numbers, a ShellScriptResult (spliced
as its trimmed stdout, so one command's output feeds the next), or arrays of any of those
(spliced as separate words). Anything else throws.
Calling $ with an options object instead returns a configured tag, which can be kept and
reused:
The shell tag, available as the global $. Runs the template text with
/bin/zshin strict mode (set -euo pipefail), with each interpolated value shell-escaped into the command as a literal word — selected text, file paths, anything: it can never become shell syntax. Requires thescriptentitlement, and may only be used during the action phase — the same gate, failure rules and result as runShellScript.The template text is used raw: everything between the backticks goes to the shell exactly as written, so backslashes survive (
$`grep -c '\.txt'`works) and JavaScript escape sequences are not interpreted. Two consequences: don't put your own quotes around an interpolation (it arrives already quoted), and write shell variables as$VARrather than${VAR}(which JavaScript would claim).Interpolated values may be strings, finite numbers, a ShellScriptResult (spliced as its trimmed stdout, so one command's output feeds the next), or arrays of any of those (spliced as separate words). Anything else throws.
Calling
$with an options object instead returns a configured tag, which can be kept and reused: