OSX bash minimize window

China☆狼群 提交于 2020-01-06 09:04:47

问题


In the Mac and using the bash shell, I want to execute a file that contains a single command (to start Jupyter Lab) and immediately minimize the terminal window.

Is there a way to do this WITHOUT installing third party software?


回答1:


Yes, just use osascript and Applescript:

osascript -e 'tell application "Terminal" to set visible of front window to false'



回答2:


You can create a file that with the command extension, for example jupiter-lab.command.

You add execution rights on it (chmod +x jupiter-lab.command). You edit the file and insert commands like in a bash script.

For example to open App Store, you could insert :

open "/Application/App Store.app"

The first time you double click on it, you will get a popup that tells you that the command has ended quickly. Just check the Suppress this message permanently not to see it anymore.

Note : the terminal will not be minimised but will be closed.




回答3:


Building on Paul R's answer, which in my testing appears to make the window fully hidden and unrecoverable, you can use the following to minimise the window to the dock if access is required again later:

 osascript -e 'tell application "Terminal" to set miniaturized of every window to true'


来源:https://stackoverflow.com/questions/52020528/osx-bash-minimize-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!