[OS X TeX] Pdf Sync from BBEdit to TeXShop

tkiffe tom at kiffe.com
Sun Jun 27 18:17:06 EDT 2021


Below is a simple Apple Script for syncing from BBEdit to TeXShop. Copy the script and paste it into Script Editor. Compile the script and use File->Export to save it in ~/Library/Application Support/BBEdit/Scripts as a script. It will appear as an item in BBEdit’s Script"s menu. Launch BBEdit and open any tex file. Launch TeXShop and open the corresponding pdf file. It must be displayed in the front window of TeXShop. In BBEdit select some text in the tex file and then select this script under BBEdit’s Script menu. The selected text will be highlighted in the pdf file.  

Special thanks to Michael Sharpe for help in the TeXShop portion of this script and to Richard Koch for making syncing possible in TeXShop with an external editor.

Begin script —————


on run
	tell application "BBEdit"
		try
			set afile to (file of text window 1) as text
			set line_number to startLine of selection of text window 1
		on error
			display dialog "I can't find a file for the front window." buttons {"OK"} default button "OK"
			return
		end try
	end tell
	
	set texFile to POSIX path of afile
	tell application "TeXShop"
		set frontdoc to (document of window 1)
		tell frontdoc
			try
				sync_preview_line theLine line_number
				sync_preview_index theIndex 1
				sync_preview_name theName texFile
			on error
				display dialog "Oops!"
			end try
		end tell
	end tell
end run


—————End script

Tom



More information about the MacOSX-TeX mailing list