Documentation for iTerm2 AppleScript: https://www.iterm2.com/documentation-scripting.html
I have this alias in my ~/.bashrc
:
alias ds='osascript .dev.scpt "$(pwd)"'
I set up a .dev.scpt
script for each of my projects. These scripts set up my preferred panes and tabs in iTerm2, and start the processes for Rails development. The advantage of using "write text" is that you can can press Ctrl+C, "up", "enter" to restart any of the processes (like a normal bash session.)