OSX Terminal - changing application focus

Is there a way to use the command line to change focus to a specific application? If so, do I need a process id or what?

My goal is to start a process that compiles files, and then focuses on the browser window after the file compilation is complete.

+7
terminal focus macos
source share
2 answers

If you understand correctly, this can be done quite easily with open -a . Opening an already open application brings it to the fore. The -a option allows you to specify the desired application, so select your favorite:

 open -a Google\ Chrome open -a Safari open -a Firefox 
+7
source share

Another option: osascript -e 'activate application "Google Chrome"' .

+4
source share

All Articles