Skip to content

Instantly share code, notes, and snippets.

@CtrliPhones
Created July 19, 2023 19:35
Show Gist options
  • Save CtrliPhones/272f523b2729be24800342ace872dde5 to your computer and use it in GitHub Desktop.
Save CtrliPhones/272f523b2729be24800342ace872dde5 to your computer and use it in GitHub Desktop.
CotEditor Preview for HTML
(*
A kinda hacky preview for CotEditor when working with HTML. Requires that you save your file before opening, and only supports using Safari for the preview at this time.
Designed by CtrliPhones in Script Editor
*)
tell application "CotEditor"
set currentFile to file of front document
end tell
if currentFile is missing value then
tell application "CotEditor" to display alert "Save document" message "Please save this file to an accessible directory first." as warning
end if
set fileLocation to (currentFile's POSIX path)
set fullURL to "file://" & fileLocation
tell application "Safari"
open location fullURL
activate
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment