Last Updated: February 25, 2016
·
2.355K
· jacaetevha

iTerm automation with AppleScript and Bash

AppleScript is a nice way to automate some features of iTerm. Combining that with my Bash scripts was a no-brainer in order to get my default iTerm tabs. You can see all of the code at https://github.com/jacaetevha/finna-be-octo-hipster/

Here's a sneak preview:

** ~/Library/Scripts/itermcreatedefault_tabs.scpt **

tell application "iTerm"
  activate
  tell the current terminal
    set theRailsDir to choose folder with prompt "Select your Rails directory"

    repeat 6 times
      activate current session
      launch session "Default Session"
      tell the last session
        write text "cd " & (theRailsDir as string)
      end tell
    end repeat

    tell the last session
      write text "osascript '~/Library/Scripts/iterm_set_rails_tabs.scpt'"
    end tell
  end tell
end tell