Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show window using command line in Mac

I usually work with several WebStorm projects opened (sometimes 5 or 6) and it gets really annoying that I have to keep searching through all the Desktops to find the right one. To make it worse, my Mac sometimes changes the order of the desktops, so I really can't know where the project is and have to search through all of them.

Does anyone know if there's a command line that I can run to show a specific window? e.g. I have a terminal window opened with 3 tabs, Projects 1, 2 and 3, and I want to go on Project 2 terminal tab and type something to show me the desktop where the WebStorm window of Project 2 is showing. Is this possible at all?

I know that I can run $ wstorm . to open the Project, but if I run it with the project already opened then nothing happens.

Thanks!

like image 350
Thiago Loddi Avatar asked Feb 18 '26 11:02

Thiago Loddi


1 Answers

The osascript command can be used if the window names contain text that can be used to identify them. Using as example TextEdit, having two windows open, one for file "file1.txt" and the other for "file2.txt", then the following command will show the window for "file2.txt"

osascript -e $'activate application "TextEdit"\ntell application "TextEdit" to set index of window 1 where name contains "file2" to 1'
like image 173
mauvilsa Avatar answered Feb 21 '26 10:02

mauvilsa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!