2016-09-10 19 views
1

完成noob在這裏爲applescript。我想知道如何解決如下所示的applescript以下問題:Applescript「預計行結束,但找到標識符」爲終端應用程序

我上線tell the current terminal以下錯誤:

enter image description here

Expected end of line but identifier found

enter image description here

這裏是代碼希望嘗試的人:

tell application "iTerm" 
    make new terminal 
    tell the current terminal 
     activate current session 
     launch session "Default Session" 
     tell the last session 
      write text "unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH" 
      write text "mkdir -p ~/.boot2docker" 
      write text "if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi" 
      write text "/usr/local/bin/boot2docker init && /usr/local/bin/boot2docker up && $(boot2docker shellinit) && docker version" 
     end tell 
    end tell 
end tell 

參考:https://apple.stackexchange.com/questions/8299/how-do-i-make-an-applescript-file-into-a-mac-app

回答

2

因爲terminal項是老的AppleScript語法。

查看https://www.iterm2.com/documentation-scripting.html獲取新的Applescript語法。

tell application "iTerm" 
    activate 
    set newWindow to (create window with default profile) 
    tell newWindow 
     tell current session 
      write text "unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH" 
      write text "mkdir -p ~/.boot2docker" 
      write text "if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi" 
      write text "/usr/local/bin/boot2docker init && /usr/local/bin/boot2docker up && $(boot2docker shellinit) && docker version" 
     end tell 
    end tell 
end tell