Stupid Mac::Glue Tricks: BBEdit Auto-Save

| | Comments (0)
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;

use.perl.org

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on April 3, 2006 6:09 PM.

Kurt Loder, You Are Old was the previous entry in this site.

Global Warming Evidence is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.