简体   繁体   中英

zsh script launches Terminal.app instead of iTerm.app

I am trying to use the zsh rails workspace launcher for OSX terminal.app written by Jim Fisher. I am on OSX 10.6.8. I want it to launch in iTerm but it continues to launch in Terminal. Shell is /bin/zsh

Below is the script that I modified slightly. Any help is always appreciated!

    rails_workspace()

    {
osascript -e 'tell application "iTerm.app"' \
-e 'tell application "System Events" to tell process "iTerm.app" to keystroke "t" using command down' \
-e "do script with command \"cd `pwd`;clear;\" in selected tab of the front window" \
-e "do script with command \"rails server\" in selected tab of the front window" \
-e 'tell application "System Events" to tell process "iTerm.app" to keystroke "t" using command down' \
-e "do script with command \"cd `pwd`;clear;\" in selected tab of the front window" \
-e "do script with command \"rails console\" in selected tab of the front window" \
-e 'tell application "System Events" to tell process "iTerm.app" to keystroke "t" using command down' \
-e "do script with command \"cd `pwd`;clear;\" in selected tab of the front window" \
-e "do script with command \"tail -f log/development.log\" in selected tab of the front window" \
-e 'end tell' &> /dev/null
sleep 2
subl .
open "http://localhost:3000"
    }
    alias rw=rails_workspace

I found that the code above was Applescript launched within zsh. So instead I wrote my own Applescript as an Automator task:

 tell application "Finder"
   set project_list to name of folders of folder ("your/projects/folder" as POSIX file)
 end tell

 (choose from list project_list with prompt "What project do you want?")
   set project to result as text

 tell application "iTerm"
   activate
   terminate the first session of the first terminal

   set myterm to (make new terminal)

   tell myterm
     set mysession to launch session "Default Session"
     tell mysession
        write text "website"
        write text project
     end tell

     set mysession2 to launch session "Default Session"
     tell mysession2
        write text "website"
        write text project
        write text "rails console"
     end tell

     set mysession3 to launch session "Default Session"
     tell mysession3
        write text "website"
        write text project
        write text "tail -f log/development.log"
     end tell
   end tell
 end tell

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM