I need to open some terminal sessions via iTerm 2 and execute commands on each terminal (e.g. rails s ; rails c)
How to do it via automator or alfred?
You could do it with an Alfred Worflow (you need the Powerpack).
First create a
Blank Workflow and fill the data:
Use the plus symbol in the right cornet to add
Trigger → Hotkey action. Define your prefered hotkey and save it.
Actions → Run script. Use
/usr/bin/osascript as language. Paste the following script and save it. Change
ls -l to whatever command you want to execute.
tell application "iTerm" activate set the clipboard to "ls -l" delay 0.5 tell application "System Events" keystroke "v" using command down keystroke return end tell end tell
Connect the two actions and you will be ready.
Type your hotkey and it will open iTerm and execute your command.