Macos – How to hide an application from the terminal

macosterminal

It's trivial to open applications from the terminal in OS X: open -a Twitter.app.

Is there some special terminal command that will hide an open application (essentially the equivalent of typing +H from inside the application)?

Best Answer

Something like this is a pretty rough start.

osascript -e 'tell application "Finder"' -e 'set visible of process "Twitter" to false' -e 'end tell'

Here is a slightly better example

on run argv

    set programName to item 1 of argv

    tell application "Finder"
        set visible of process programName to false
    end tell

end run

Which you run with osascript ~/hider.scpt Twitter as an example assuming it's in your home dir with the name hider.scpt and you want to hide Twitter.app (you don't use the word '.app').