Skip to content

Instantly share code, notes, and snippets.

@vitalybe
Created February 25, 2016 09:48
Show Gist options
  • Save vitalybe/d19087e383135557ea1a to your computer and use it in GitHub Desktop.
Save vitalybe/d19087e383135557ea1a to your computer and use it in GitHub Desktop.
tell application "iTerm"
-- Create a new terminal window or tab.
set myterm to (make new terminal)
tell myterm
-- Create a new session.
set mysession to (make new session at the end of sessions)
-- Create primary divider (rows or columns).
tell application "System Events" to keystroke "D" using {command down}
tell application "System Events" to keystroke "D" using {command down}
tell application "System Events" to keystroke "D" using {command down}
-- Sleep for a bit while we catch up.
do shell script "sleep 1"
-- Create panes within each primary divider.
tell application "System Events" to keystroke "]" using {command down}
tell application "System Events" to keystroke "d" using {command down}
tell application "System Events" to keystroke "]" using {command down}
tell application "System Events" to keystroke "]" using {command down}
tell application "System Events" to keystroke "d" using {command down}
tell application "System Events" to keystroke "]" using {command down}
-- Terminate first or last session, which are unused.
terminate the first session
-- Sleep for a bit while we catch up.
do shell script "sleep 1"
-- Create all commands for a given pane (item).
tell item 1 of sessions to set name to "here"
tell item 1 of sessions to write text "cd /Users/vitaly/git/termrc && echo \"Hello, here.\""
tell item 2 of sessions to set name to "there"
tell item 2 of sessions to write text "cd /Users/vitaly/git/termrc && echo \"Hello, there.\""
tell item 3 of sessions to set name to "world"
tell item 3 of sessions to write text "cd /Users/vitaly/git/termrc && echo \"Hello, world.\""
tell item 4 of sessions to set name to "me"
tell item 4 of sessions to write text "cd /Users/vitaly/git/termrc && echo \"Hello, me.\""
tell item 5 of sessions to set name to "you"
tell item 5 of sessions to write text "cd /Users/vitaly/git/termrc && echo \"Hello, you.\""
end tell
-- Reposition window.
-- set the bounds of the first window to {10, 10, 600, 600}
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment