Macos – Mac Terminal Continuously Running a Command

macmacosterminal

I'm trying to run the following command continuously:

osascript -e 'tell application "System Events" to set visible of every application process to false'

Is there some sort of command with the following methodology?

repeat "enter command here"

If not, how could I do this?

Best Answer

With a simple while loop, sleeping in between:

while true; do osascript -e 'tell application "System Events" to set visible of every application process to false'; sleep 1; done

If you have Homebrew, install watch (brew install watch), and then call:

watch -n1 osascript -e 'tell application "System Events" to set visible of every application process to false'

… to run it every second.

Related Question