Apple - Open an app in fullscreen via Terminal

Here it is:

/usr/bin/osascript -e 'tell application "Safari"' -e "activate" -e 'tell application "System Events"' -e 'keystroke "f" using {control down, command down}' -e "end tell" -e "end tell"

Here it is in a clearer form (but you can't run it this way):

/usr/bin/osascript -e "tell application \"Safari\"" 
-e "activate"
-e "tell application \"System Events\""
-e "keystroke \"f\" using {control down, command down}"
-e "end tell"
-e "end tell"

And this is it as formatted AppleScript:

tell application "Safari"
    activate
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
end tell

It works by first opening a Safari window if one is not currently open. Then it simulates the Control ⌃-Command ⌘-F keystroke which tells the Safari window to become full screen.

If you want to make the window the max-size it can be without becoming full screen (i.e. taking up all the space below the menu bar at the top):

tell application "Finder"
    set desktopSize to bounds of window of desktop
end tell

tell application "Safari"
    activate
    set bounds of window 1 to desktopSize
end tell

Which would become this in Terminal:

/usr/bin/osascript -e "tell application \"Finder\"" -e "set desktopSize to bounds of window of desktop" -e "end tell" -e "tell application \"Safari\"" -e "activate" -e "set bounds of window 1 to desktopSize" -e "end tell"

For Chrome, do this:

tell application "Google Chrome"
    activate
    make new window
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
end tell

So it would be this in Terminal:

/usr/bin/osascript -e "tell application \"Google Chrome\"" -e "activate" -e "make new window" -e "tell application \"System Events\"" -e "keystroke \"f\" using {control down, command down}" -e "end tell" -e "end tell"

Hope this helps!


This won't work with applications that don't use native full screen windows, but should work with some that don't use the standard shortcut for entering full screen. A few applications have different process names and application names.

set a to "Notes"
set bid to id of application a
tell application a
    reopen -- open a new default window if there are no windows
    activate -- make frontmost
end tell
tell application "System Events" to tell (process 1 where bundle identifier is bid)
    click (button 1 of window 1 where subrole is "AXFullScreenButton")
end tell