ericsoco ericsoco - 10 months ago 92
Bash Question

Close Terminal window from within shell script (Unix)?

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.


(converted to an answer from my comment as suggested)

Using exit 0 will cleanly terminate the script, but whether Terminal window stays open is user-configurable in Terminal's preferences. The default is to alway stay open, but I prefer the setting "Close if shell exited cleanly". It can be changed in Settings -> Shell -> When the shell exists. With that setting the script will close the window automatically if the exit result is 0 (which is the default if nothing went wrong).