On Mon, 17 Aug 2009 09:14:44 +0100, Carlton Gibson wrote: > You can use AppleScript from within your shell script to query BBEdit > for the information you need.
No, you can't. BBEdit does not process apple events while a unix command is running. Trying to do so will result in a timeout error for the osascript command, as BBEdit never replies. If the script is not called from the BBEdit interface, but from a global scripting menu, then BBEdit will respond as expected. However, this means that the script is not in the standard menu structure of BBEdit. > 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.) A heredoc can also be very helpful ( http://en.wikipedia.org/wiki/Heredoc ), but only in cases where osascript can actually be used. Maarten --~--~---------~--~----~------------~-------~--~----~ 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. -~----------~----~----~----~------~----~------~--~---
