Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Just 'trap' it' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Just 'trap' it
Authored by: apparissus on May 05, '04 11:42:52PM
If you don't want to remember to type "quit" instead of "exit", and you're using bash, just add the following to your .bashrc or other shell startup script:
trap '/usr/bin/osascript -e "tell application \"terminal\" to quit"' 0
What's it do? When the shell receives signal 0 (zero), that is, told to exit, it will execute this command as the last thing it does. This allows your shell, etc, to exit gracefully, and asking Terminal.app to exit via applescript makes sure it does the same. In other words, type 'exit', and your shell exits, then Terminal quits, all cleanly and the way nature intended.

Note:You'll need to add login, bash, and osascript to the exclude list under "Prompt before closing window" or terminal will whine at you before exiting. Or you could just choose "Never".

Something similar is surely possible with tcsh...but I have no idea how.

[ Reply to This | # ]