0

我正在尝试使用由 Jim Fisher 编写的 OSX terminal.app 的 zsh rails 工作区启动器。我在 OSX 10.6.8 上。我希望它在 iTerm 中启动,但它继续在终端中启动。外壳是 /bin/zsh

下面是我稍微修改的脚本。任何帮助都将受到赞赏!

    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
4

1 回答 1

0

我发现上面的代码是在 zsh 中启动的 Applescript。因此,我将自己的 Applescript 编写为 Automator 任务:

 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
于 2013-10-09T16:18:36.367 回答