简体   繁体   中英

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? eg 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!

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM