AppleScript splitting terminal session doesn't work as expected
I would expect the below applescript to create a grid of 2 rows with 3 columns each, but it doesn't.
tell application "iTerm"
-- the goal is to create a grid of 6 sessions and let them ssh into 6 different servers
-- for convenience we refer to the sessions like we do in a spreadsheet (eg. a2 means the first column of the 2nd row)
local session_a1, session_a2, session_b1, session_b2, session_c1, session_c2
activate
-- create a new window
create window with default profile
set session_a1 to (current session of current window)
tell session_a1
write text "echo session_a1"
split horizontally with same profile
end tell
set session_a2 to (current session of current window)
tell session_a1
write text "echo session_a1"
split vertically with same profile
end tell
set session_b1 to (current session of current window)
tell session_b1
write text "echo session_b1"
split vertically with same profile
end tell
set session_c1 to (current session of current window)
tell session_c1
write text "echo session_c1"
end tell
tell session_a2
write text "echo session_a2"
split vertically with same profile
end tell
set session_b2 to (current session of current window)
tell session_b2
write text "echo session_b2"
split vertically with same profile
end tell
set session_c2 to (current session of current window)
tell session_c2
write text "echo session_c2"
end tell
activate
end tell