I wanted a single command to launch my development environment: LunarVim in a large pane on the left, two Claude Code sessions stacked on the right, and three Fish shells across the bottom.
┌──────────────┬─────────┐
│ │ claude │
│ LunarVim ├─────────┤
│ (66x66) │ claude │
├──────┬───────┼─────────┤
│ fish │ fish │ fish │
└──────┴───────┴─────────┘
iTerm can save window arrangements natively—arrange your panes, hit
Cmd+Shift+S to save, and Cmd+Shift+R to restore. Simple.
But these arrangements live inside ~/Library/Preferences/com.googlecode.iterm2.plist,
a monolithic binary file with all iTerm settings mixed together. Not something you can
version cleanly in git. And arrangements only save geometry, not the commands each pane
should run. I needed a script that could be versioned and parameterized with the project
path.
AppleScript with System Events
AppleScript reads like English sentences. The tell keyword targets an
application or object, and everything inside the block sends commands to it.
tell application "iTerm" means “talk to iTerm”, and tell current session narrows the
focus to the active terminal pane.
tell application "iTerm"
-- 1. Start with current pane (becomes LunarVim)
tell current session of current window
-- 2. Split vertically → creates right column
set claude1 to (split vertically with default profile)
-- 3. Split right column horizontally → two Claude panes
tell claude1
set claude2 to (split horizontally with default profile)
end tell
-- 4. Back to LunarVim, split horizontally → bottom row
set fish1 to (split horizontally with default profile)
-- 5. Split bottom row twice → three shell panes
tell fish1
set fish2 to (split vertically with default profile)
tell fish2
set fish3 to (split vertically with default profile)
end tell
end tell
end tell
end tellBut AppleScript splits are always 50/50. To get LunarVim to 66% width, the script uses
System Events to simulate resize keyboard shortcuts (Ctrl+Cmd+Arrow):
tell application "System Events"
repeat 13 times
key code 123 using {control down, command down} -- Left arrow
delay 0.01
end repeat
end tellThirteen repeats gets the editor pane to roughly 66% width.
System Events requires Accessibility permission—add iTerm in
System Settings > Privacy & Security > Accessibility once.
Bonus: Auto-Open NvimTree
While setting this up, I also configured LunarVim to auto-open NvimTree on startup:
vim.api.nvim_create_autocmd("VimEnter", {
callback = function()
require("nvim-tree.api").tree.open()
end,
})No more typing Space + E every time.