Jump to content

trigger iterm command via bash script


Recommended Posts

Total newb here: I just created a workflow that starts my dev environment. It launches parallels, codekit and sublime text via the following script:

 

open ~/Documents/Parallels/ubuntu\ 12.04.01\ LTS.pvm;
sleep 10;
open /Applications/CodeKit.app;
sleep 15;
open /Applications/Sublime\ Text\ 2.app;

This is wonderful not to have to do this every day.  I even have a shutdown sequence as well.  This is why I decided to purchase a super-license for alfred, this shit is life changing.

 

So, I want to add one more step to this process.  I thought I could chain an action after the script, but it looks like that doesn't work out well.   :(  I would like to trigger a command in my current iTerm window to ssh into the new setup, but I'm kinda stuck at this point.  Any suggestions?

Link to comment

You can send commands to iTerm via applescript (and you can call applescript from bash via the osascript command), so you can do something like

osascript -e 'tell application "iTerm"
  tell current session of first terminal to write text "echo 'hello'"
  activate
end tell'
Naturally, change "echo 'hello'" to your ssh command.

 

You also can, instead of using Run Script, in Alfred, set up a Terminal Command action, and put all your commands there, in succession. The terminal you set under Preferences → Features → Terminal / Shell will be the one that opens.

Edited by Vítor
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...