Hi Friends,
Wondering whether anyone else has dealt with this: I want to generate a
BBEdit worksheet programmatically AND populate it with some initial info
for its use.
BBEdit has its CLI tool `bbedit`, which can create a worksheet from the
command line:
`bbedit —-worksheet my_worksheet`
This will create and open a new (blank) BBEdit worksheet named
‘my_worksheet’.
The BBEdit docs say that the bbedit command has an option `—-append`,
and that it may be used with `—-worksheet` but I don’t get how to
use it.
Going further, I’m generating the worksheets programmatically using
Perl:
## Perl script ##
#!perl
my $project = ‘abc’;
my $base_dir = ‘/Users/me/tests’;
my $worksheet_filename = ‘ws_test_01’;
# How do I get this into the new worksheet?
my $initial_content = <<CON;
A=‘project=$project’
B=‘base_dir=$base_dir’
perl
my_project_analyzer.pl “$A” “$G”
#-#-#
CON
chdir $base_dir;
system( ‘bbedit’, ‘—worksheet’, ‘—wait’,
‘—resume’, $worksheet_filename);
## end Perl script ##
This opens a blank worksheet, and returns me to the Terminal after I
close the worksheet.
My goal is to have it open the worksheet with the following at the top:
A=‘project=abc’
B=‘base_dir=/Users/me/tests’
perl
my_project_analyzer.pl “$A” “$G”
#-#-#
I have a command that selects everything down to the ‘#-#-#’ line,
so when I press Enter, it executes the perl script with the arguments
provided. The output appears below the ‘#-#-#’ line. The project
name, worksheet filename, base_dir, and some other potential args
dynamically come out of the executing Perl script that create the
worksheet. So my problem isn’t solved with stationery.
How do I apply the `-—append` option to put the initial content into
the worksheet??
I’ve tried variations on pipes etc, and this might be a limitation of
Perl’s `system` function.
If I run the above and then (in my Perl app) open the worksheet and
print the above, the file is no longer an executable worksheet. This
makes sense to me because under the hood, BBEdit worksheets are XML
docs, so arbitrarily opening and printing to them messes up the XML
structure.
The best I’ve been able to muster is to have the Perl script output
that initial content to the Terminal, which I can then copy-paste into
the new blank worksheet. LTA.
Anyone know how to deal with this?
Thanks,
- Bruce
_bruce__van_allen__santa_cruz__ca