AppleScript example request: BBEdit roundtrip - Shell script via AppleScript

48 views
Skip to first unread message

Iain Houston

unread,
Jan 20, 2020, 12:01:41 PM1/20/20
to BBEdit Talk
I have a shell script I use for quickly creating a skeleton Jekyll blog post with all the required front matter; required file name etc. 
I would like to invoke this from the BBEdit AppleScript menu and have BBEdit return with the newly-created Markdown Text File as the frontmost document in BBEdit. 

The script requires some input arguments (see GitHub Gist) which I assume I can collect from an AppleScript dialogue in an AppleScript wrapping my Python script.

I feel sure that this is a fairly common roundtrip pattern: BBEdit -> AppleScript -> Shell script -> AppleScript -> BBEdit.

I'd be very grateful for a pointer to a similar AppleScript that I can look at to see how to best implement this.

Thanks!

John Delacour

unread,
Jan 20, 2020, 6:07:20 PM1/20/20
to bbe...@googlegroups.com
On Mon, 20 Jan 2020 at 17:01, 'Iain Houston' via BBEdit Talk
<bbe...@googlegroups.com> wrote:

> I feel sure that this is a fairly common roundtrip pattern: BBEdit -> AppleScript -> Shell script -> AppleScript -> BBEdit.

Here's an example. You can also send arguments to an existing shell
script rather than have the script inline:

try
set _q to display dialog "What is your name" default answer ""
set _a to text returned of _q
end try

set _perloutput to do shell script "
perl <<'END'
my $name = qq~" & _a & "~;
print qq~Your name is $name~;
END"
display dialog _perloutput

--JD

Iain Houston

unread,
Jan 20, 2020, 9:44:13 PM1/20/20
to BBEdit Talk
Thank you John.

That remarkably simple example contained just what I needed.

IH
Reply all
Reply to author
Forward
0 new messages