Close Terminal window from within shell script (Unix)?

前端 未结 6 978
无人共我
无人共我 2020-12-07 16:41

Is there a way to close a Terminal window from within a shell script? I have a .command file that should just get out of the way once it\'s done.

6条回答
  •  半阙折子戏
    2020-12-07 17:12

    This works for me:

    #!/bin/sh
    
    {your script here}
    
    osascript -e 'tell application "Terminal" to close (every window whose name contains ".command")' &
    exit
    

    This will work for closing just your windows opened with a .command file but leave things already running in other terminal windows. I know that I almost always have either sass or grunt watch something so I don't want to quit terminal totally.

提交回复
热议问题