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/eb70a0f0-e4e2-4932-939a-f81d116a1c33n%40googlegroups.com.

Reply via email to