Whenever I type 'exit' or I logout, the terminal window stays open and I have to close it manually. Can I change this behavior?
2 Answers
Go to Terminal -> Preferences, then on the right hand side select "Shell", then select "Close if the shell exited cleanly" from the dropdown labeled "When the shell exits".
This will close the shell if it exited without a problem (such as when you typed "exit"), but if the process returns an error it will stick around so that you can see what it was.
-
-
1Any ideas on how to make this work in El Capitán? This has changed, and I can't find that "When the shell exits" combo anymore– jmmSep 20, 2016 at 18:51
-
2@jmm for El Capitan: Preferences, Profiles, Shell, Set the "When the shell exits" dropdown as you wish. Sep 22, 2016 at 17:24
Additionally, you can execute the following command (or add it to the end of your .sh shell script) in order to kill the Terminal application:
kill `ps -A | grep -w Terminal.app | grep -v grep | awk '{print $1}'`
-
This will kill all Terminal windows, not just the one running the application. So it is only useful to those who don't use Terminal windows for any other purpose but the proposed automation. Jan 4, 2017 at 18:44