AppleScript - How to Open Terminal Fullscreen and Execute Commands

applescriptcommand linefullscreenscriptterminal

I need an applescript, which can do the job below:

  • open the application Terminal with fullscreen
  • run some scripts

Here is what I've tried:

tell application "Terminal"
    tell window 1
        activate
        tell application "System Events"
            keystroke "f" using {control down, command down}    
        end tell
        do script "cd Documents/'cpp project'/test3" in window 1
        do script "./matrix.out" in window 1
    end tell
end tell

But it doesn't work.

Best Answer

You need to be talking to Terminal, not window 1. This script worked fine for me.

tell application "Terminal"
    activate
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
    do script "cd ~/Downloads" in window 1
    do script "brew list" in window 1
end tell