我正在使用applescript打开我的开发环境。
更新 - 此脚本有效。我将textmate打开到脚本的末尾,现在它的工作更加一致。
tell application "Terminal"
activate
do script "cd web_sites/mydomain" in front window
do script "rvm 1.9.2" in front window
do script "rails server" in front window
end tell
tell application "System Events"
if not (exists process "System Events") then
tell application "System Events" to activate
end if
tell process "Terminal" to (keystroke "t" using command down)
end tell
tell application "Terminal"
do script "cd web_sites/mydomain/public/stylesheets" in front window --> tab 2
do script "rvm 1.9.2" in front window --> tab 2
do script "sass --watch stylin.scss:stylin.css" in front window --> tab 2
end tell
tell application "System Events"
tell process "Terminal" to (keystroke "t" using command down)
end tell
tell application "Terminal"
do script "cd web_sites/mydomain" in front window --> tab 3
do script "rvm 1.9.2" in front window --> tab 3
do script "mate ." in front window
delay 4
do shell script "open -a Firefox http://localhost:3000"
end tell
感谢您的帮助。
答案 0 :(得分:1)
我看到三个可能的问题:
tell application "System Events"
行嵌套在寻址tell
的{{1}}块中。您应该创建两个Terminal
块,其中包含tell application "Terminal"
行。
AppleScript无法在一行上执行两项操作。换句话说,改变两次出现...
tell application "System Events"
...到块 ...
tell application "System Events" to tell process "Terminal" to (keystroke "t" using command down) activate
......应该这样做。
tell application "System Events"
activate
tell process "Terminal" to keystroke "t" using {command down}
end tell
。该应用程序有一个默认的五分钟退出延迟(System Events
将在五分钟不活动后自动退出)。如果计算机运行速度很快,则应删除第二个System Events
命令。希望这一切都有意义。 :)