On 8 Oct 2009, at 03:09, jdx2172 wrote:

> My feature request is to run a line of terminal command when the user
> presses a keyboard shortcut. The application of that is like this...

Basically you can script the BBEdit application using AppleScript, and/ 
or process any text (the selection or the whole document) using either  
AppleScript or a Unix filter.

For example, suppose you want to write a script that, when invoked  
(either from the script menu or with a key combination), finds a  
directory path in square brackets on the current line and inserts a  
listing of that directory, you'd probably write this:

tell application "BBEdit"
        tell front text window
                set n to startDisplayLine of selection
                set result to find "\\[(.*)\\]" searching in line n options 
{search  
mode:grep} with selecting match
                if (found of result) then
                        set directory to grep substitution of "\\1"
                        set listing to do shell script "ls  " & "\"" & 
directory & "\""
                        set selection to listing
                end if
        end tell
end tell

My AppleScript is rusty these days, but you get the idea. Because you  
want to talk to BBEdit, use AppleScript.

However, I personally prefer to just select some text manually (eg  
Command B to balance brackets) and run a Unix filter on that. Only the  
selection is passed to your Unix filter, so I'd probably tie a  
keystroke to that filter. This way you can do most of your string  
processing in your filter, and that could be easier than doing it in  
AppleScript.

:)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
-~----------~----~----~----~------~----~------~--~---

Reply via email to