Either, make sure build.sh has execution permissions.
  • *in terminal run:*

    sudo chmod ug+x /Users/venkgvi/Desktop/talk/build.sh
    
or 

  • *execute the command directly from the script:*

    ... 
    set vDirectoryPath to do shell script "dirname" & space & the quoted 
form of vFilePath
    set vCommand to "cd" & space & (the quoted form of vDirectoryPath) & 
space & ";"
    set vCommand to vCommand & 
"PATH='/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin'" & 
space 
    set vCommand to vCommand & "latexmk -xelatex -verbose -pv"
    do shell script vCommand

  If you get an error about latexmk not being found, check where latexmk is 
on your setup.
  In terminal run:
    
    which latexmk

  and add the the latexmk directory to the PATH or put the fully qualified 
path to latexmk in the command.

On Friday, July 16, 2021 at 3:31:55 PM UTC+2 Venkat wrote:

> 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/402e7fb9-2609-4341-951b-aa2da0ddd290n%40googlegroups.com.

Reply via email to