问题
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