Purpose
Open a right split in Ghostty and preview a Markdown file with glow.
Prerequisites
- Ghostty 1.3.0 or later must be running on macOS with AppleScript enabled
- glow CLI must be installed for markdown rendering (
brew install glow)
Commands
render-markdown-split
Open a right split in the current Ghostty window and render a markdown file using glow.
Arguments
file(required): Path to the markdown file to render
Workflow
- Resolve the markdown file path to an absolute path
- Verify the file exists and has a
.mdextension - Pass the absolute path as an argument to AppleScript. AppleScript shell-quotes it before sending the command to Ghostty:
ABSOLUTE_FILE_PATH='/absolute/path/to/file.md'
osascript - "$ABSOLUTE_FILE_PATH" <<'APPLESCRIPT'
on run argv
set filePath to item 1 of argv
set commandText to "glow -p " & (quoted form of filePath)
tell application "Ghostty"
set currentTerm to focused terminal of selected tab of front window
set previewTerm to split currentTerm direction right
delay 0.5
input text commandText to previewTerm
send key "enter" to previewTerm
end tell
end run
APPLESCRIPT
Important Notes
- The
delay 0.5is necessary to allow the new split to initialize before sending input - Always use absolute paths for the file to avoid working directory issues in the new split
- Pass the path as an
osascriptargument; do not interpolate it into shell or AppleScript source - The
-pflag enables pager mode in glow for scrollable output - If
glowis not installed, inform the user and suggestbrew install glow
Error Handling
- If the file does not exist, report the error to the user — do not run the AppleScript
- If
osascriptreturns an error aboutfocused terminal, Ghostty may not be the active application — advise the user to focus Ghostty first