Thank you! This seems to be what I'm after, however I'm running into a 
permissions issue, with this being the error message I get: *sh: 
/Users/venkgvi/Desktop/talk/build.sh: Permission denied*

I'm not sure why I'm getting this message, since running build.sh directly 
from the #! menu works fine. Do I need to add permissions somewhere in the 
AppleScript? Also is it possible to include the contents of build.sh 
directly in the AppleScript script? So instead of:

set vScriptPath to vDirectoryPath & "/build.sh"

Can I write the contents of build.sh directly in the script? I was 
wondering if I can skip making an extra shell script file in my project 
folder.

On Friday, July 16, 2021 at 2:49:35 AM UTC-5 jj wrote:

> Hi Venkat,
>
> This applescript might do what you want if I correctly understood your 
> workflow:
>
> ```applescript
> try
> tell application "BBEdit"
> tell first window
> tell first document
> if not (its on disk) then
> error "BBEdit's front document is not saved on disk."
> end if
> set vName to (its name) as string
> set vLanguage to (its source language) as string
> ignoring case
> if not (vName ends with ".tex" or vLanguage is "TeX") then
> error "BBEdit's front document is not a TeX document."
> end if
> end ignoring
> set vFile to its file
> end tell
> end tell
> set vFilePath to POSIX path of vFile
> set vDirectoryPath to do shell script "dirname" & space & the quoted form 
> of vFilePath
> set vScriptPath to vDirectoryPath & "/build.sh"
> do shell script the quoted form of vScriptPath
> end tell
> on error aMessage
> display alert aMessage as critical
> end try
> ```
>
> Name it and copy it to BBEdit's Scripts folder and in the menu Window > 
> Palettes > Scripts palette you can assign it a keyboard shortcut.
>
> HTH
>
> Jean Jourdain
>
> On Friday, July 16, 2021 at 1:44:53 AM UTC+2 Venkat wrote:
>
>> Hello, I'm relatively new to scripting, and need some help writing up a 
>> script that may need extension in the future. I write and compile LaTeX 
>> documents in BBEdit, and my workflow is  to create a build.sh (in the same 
>> folder) file with the following code that's enough to compile the latex 
>> code in the folder:
>>
>> #!/bin/sh
>> latexmk -xelatex -verbose -pv
>>
>> I was wondering if it was possible to create a script (stored in scripts 
>> folder) that is called every time I hit the keys Cmd+R together, *when 
>> the frontmost open text file is a .tex file*. In the future, I hope to 
>> extend this script for other filetypes. Anyone have any tips or a template 
>> script I can work with? 
>>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/d7637b4d-8da6-4d1e-a485-6004d1b7fb30n%40googlegroups.com.

Reply via email to