Auto-save your BBEdit documents on a per-document basis. The script will keep looping every N seconds until the file is closed (or you kill the script manually).
#!/usr/bin/perl # bb_autosave.plx - autosave for BBEdit # save whatever is currently frontmost document when script first executes, # every N seconds
use strict; use warnings;
use Mac::Glue ':all';
my $bbedit = new Mac::Glue 'BBEdit'; my $front_id = $bbedit->prop(id => document => 1, window => 1)->get; my $front = $bbedit->obj(document => obj_form(formUniqueID, typeLongInteger, $front_id));
my $name = $front->prop('name')->get; print "Auto-saving document '$name'.\n";
my $sec = shift || 10;
while ($front->get) { $front->save; sleep $sec; }
print "Document closed.\n"; exit;