Split window programmatically with iTerm?
You can easily call this from iTerm2 directly to simulate pressing ⌘D:
osascript -e 'tell application "System Events" to key code 2 using command down'
For this to work you want to start the programs in background, since otherwise you cannot run osascript
:
some-command &
osascript -e '…'
From there on you'll land in a new iTerm2 window, so you need to use the write text
option in AppleScript to run further shell commands. See here for more: How do I set up an AppleScript to open a new iTerm2 tab and change the directory?