Bunch provides an AppleScript dictionary that you can use to open, close, and toggle Bunches, process raw text, or access snippets.
tell application "Bunch" to open bunch "Comms" tell application "Bunch" close bunch "Default" toggle bunch "Comms" end tell
You can also process raw Bunch text:
tell application "Bunch" process text "(dnd on)" end tell
\nin the string to add newlines, useful for adding dashed parameters/variables when calling scripts or snippets.
Tip: raw text processing is also useful in scripts where you want to read in the contents of a Bunch, modify them in some way, then execute the result. It won’t mark that Bunch as “open” when it executes, but it’s one way to add dynamic processing.
You can access snippets directly with options to target fragments and pass variables.
run snippet text ¬ fragment text ¬ with variables text
|direct parameter||required||text||snippet path, absolute or relative to configured Bunch folder|
|with variables||optional||text||query string formatted list of key/values|
with variables parameter accepts a string of text formatted like a URL query string, with
key=value pairs separated by ampersands (&). If your value needs to include an actual ampersand, url encode it as
%26 in the query string.
tell application "Bunch" run snippet "useful.snippets" fragment "Spotify" with variables "url=spotify:playlist:4AEt6vXGJYmyOEE8zzgvjQ&autoplay=false" end tell