Skip to content

Instantly share code, notes, and snippets.

@paulsmith
Created July 15, 2025 15:41
Show Gist options
  • Save paulsmith/e24438daca4e6907f342f4abd25f2309 to your computer and use it in GitHub Desktop.
Save paulsmith/e24438daca4e6907f342f4abd25f2309 to your computer and use it in GitHub Desktop.
Ghostty terminal emulator AppleScript for creating custom split layout
-- ABOUTME: AppleScript to set up Ghostty terminal with custom split layout
-- ABOUTME: Creates left column full height, right column with two vertical splits
on makeNewWindow()
if application "Ghostty" is running then
tell application "System Events"
set visible of application process "Ghostty" to true
delay 0.1
end tell
end if
tell application "Ghostty" to activate
tell application "System Events"
set preWindowCount to count of windows of application process "Ghostty"
keystroke "n" using command down
set tryUntil to (current date) + 5
repeat while preWindowCount is equal to (count of windows of application process "Ghostty")
delay 0.1
if tryUntil is less than (current date) then
error "Failed to create new window"
end if
end repeat
delay 0.2
end tell
end makeNewWindow
on runCommand(theCommand)
tell application "System Events"
keystroke (theCommand as text)
keystroke return
end tell
end runCommand
on setupSplits()
tell application "System Events"
-- Create split to the right (this creates left and right columns)
keystroke "d" using command down
delay 0.3
-- Now we're in the right split, split it vertically
keystroke "d" using {command down, shift down}
delay 0.3
-- Navigate to the left split (need to go back twice)
keystroke "[" using command down
delay 0.2
keystroke "[" using command down
delay 0.2
-- Run Claude Code in left split
tell me to runCommand("claude --dangerously-skip-permissions")
delay 0.5
-- Navigate to right top split
keystroke "]" using command down
delay 0.2
-- Run nvim in right top split
tell me to runCommand("nvim")
delay 0.5
-- Navigate to right bottom split
keystroke "]" using command down
delay 0.2
-- This split stays as bash shell, so nothing to type
end tell
end setupSplits
-- Main execution
tell me to makeNewWindow()
tell me to setupSplits()
#!/bin/bash
# ABOUTME: Bash script to run the Ghostty split layout AppleScript
# ABOUTME: Executes the AppleScript that creates custom terminal layout
osascript ghostty_splits.applescript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment