BBEdit Scripts

| | Comments (0)
John Gruber has a new version of a script to open lots of files in one window in BBEdit. The only one was harder, because there was nothing in the AppleScript dictionary for it, and the command line program couldn't do it.

I wrote a version in Perl, and the new version is quite a bit shorter:

#!/usr/bin/perl
use Mac::Glue ':all';
my $bbedit = new Mac::Glue 'BBEdit';
$bbedit->obj(file => \@ARGV)->open(opening_in => enum('new_window'));

Although for command-line purposes, I'll use this Perl script, called bbeditm:

#!/usr/bin/perl
system 'bbedit', '--new-window', @ARGV;

I have some other similar scripts for BBEdit. One is for using as my default $EDITOR. You see, normally, bbedit(1) will open your files and return immediately. It has an option to wait, but if you set EDITOR='bbedit -w', some programs won't use it because $EDITOR is not executable. So, make an executable, called bbeditw:

#!/usr/bin/perl
system 'bbedit', '-w', '--resume', '-c', @ARGV;

Something else I do a lot is pipe program output to BBEdit. To make this easier, bbedit(1) provides options to scroll up to the top of the window, instead of starting at the bottom, and another option to make it so I can close the window without telling it to not save, and I wrote bbeditd:

#!/usr/bin/perl
system 'bbedit', '--view-top', '--clean', '-t', 'Program Output', @ARGV;

Much of the time I use this in the form of perldoc -t Mac::Glue | bbeditd or gluedoc -t BBEdit | bbeditd, so I shortened that, too, in bbeditp:

#!/usr/bin/perl -s
our $g;
my $prog = $g ? 'gluedoc' : 'perldoc';
my $doc = shift;
open STDOUT, "|bbedit --view-top --clean -t $doc";
system $prog, '-t', $doc;

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 March 31, 2005 3:13 PM.

Lobbying, NPR, Astroturfing, and Congress was the previous entry in this site.

Assisted Suicide is the next entry in this site.

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