Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX Terminal - Change Application Focus

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

My goal is to run a process that compiles files, and then focuses on the browser window once the files have finished compiling.

like image 352
Marius Miliunas Avatar asked Jul 23 '13 15:07

Marius Miliunas


2 Answers

If I understand you correctly, this could be done quite easily with open -a. Opening an already-open application brings it to the forefront. The -a option allows you to specify the application you want, so pick your favorite:

open -a Google\ Chrome
open -a Safari
open -a Firefox
like image 82
Amory Avatar answered Oct 28 '22 20:10

Amory


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

like image 20
terrace Avatar answered Oct 28 '22 21:10

terrace