Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

pudge
  (email not shown publicly)
http://pudge.net/
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Thursday March 31, 2005
06:13 PM

BBEdit Scripts

[ #23958 ]

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;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.