On 14 Aug 2009, at 11:23, skillzero wrote:
> Is there a way to run a non-filter Unix script that has info about the
> current window? I'd like to be able to run a Unix script with access
> to BB_DOC_PATH, BB_DOC_SELSTART, BB_DOC_SELEND, etc., but I don't want
> to modify the text of the window (as a filter does). For example, I
> want to have a script that does a 'git difftool' (which I've
> configured to use bbdiff) on the current window to show a side-by-side
> diff. Another thing I want is to select some text and do 'git blame'
> on the selected lines and show them in the new window.
You can use AppleScript from within your shell script to query BBEdit
for the information you need.
The key is using the `osascript` command.
As an example (without an error checking) this outputs the path of the
current file:
getDoc='tell application "BBEdit"
set a to file of text document 1
set p to POSIX path of a
end tell';
BB_DOC_PATH=`osascript -e "$getDoc"`;
echo $BB_DOC_PATH;
The backticks capture the output of the osascript call into the
BB_DOC_PATH variable. The -e flag takes an inline script; I think -s
is the one to specify a separate script file, check the man page.
(Given issues with escape sequences, both to the shell and the
applescript component itself, using an external script can be a lot
easier.)
I hope this helps.
Regards,
Carlton
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
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 specific feature request or would like to report a suspected (or
confirmed) problem with the software, please email to "[email protected]"
rather than posting to the group.
-~----------~----~----~----~------~----~------~--~---