13

How can I prevent Terminal from showing me my old output when it starts?

I would like it to always start with a clean window.

5 Answers 5

13

You can change terminal only with this one command to write a new preference for that specific app.

defaults write com.apple.terminal NSQuitAlwaysKeepsWindows -bool false

This is general, so of course, substitute safari or quicktimeplayerX or whatever in the com.apple.terminal portion of the command as needed. This setting switches the default save behavior upon quitting that one app. You'll find many of the other apps that work well with this setting by searching on NSQuitAlwaysKeepsWindows.

Of course, you should issue this defaults command after closing all windows and then quitting the application to ensure the settings are read the next time Terminal starts.

1
  • You can also close all the windows when quitting. Sometimes I like it to be clean. Sometimes I like retaining the old output.
    – bahamat
    Commented Sep 14, 2011 at 2:26
5

Besides setting the preference to always suppress Resume, you can also control this when quitting by pressing the Option modifier key, so that "Quit …" becomes "Quit and Discard Windows". e.g., you can type Option-Command-Q to quit without saving state. You can also press the Shift modifier when an application is opening to prevent it from restoring state for Resume.

There is also a Terminal preference (without UI) for controlling how many lines of the scroll-back to restore, which you can set to zero, although it still restores the display contents:

defaults write com.apple.Terminal RestoreScrollbackLines 0
0

There seems to be one case where disabling NSQuitAlwaysKeepsWindows does not work: When the Terminal is killed by killall Terminal, and probably also when it crashes or when it is forced quit.

I use killall Terminal regularly, but when the resume kicks in, it messes up my bash history. Basically, commands from the session after the resume will not be saved. Normal saving behaviour is only restored after I quit and reopen Terminal.app. It appears, though, that completely disabling any resume features fixes bash history:

chmod a-rwx ~/Library/Saved\ Application\ State/com.apple.Terminal.savedState

Thanks to willWorkForCookies’s answer to How to prevent one app from saving/restoring any Saved State.

-3

You can actually deactivate "save state" on per-app basis, have a look at https://faqintosh.com/risorse/en/sys/swapsaveability/

HTH

1
  • 1
    Welcome to Apple! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – daviesgeek
    Commented Mar 17, 2012 at 16:28
-5

The only way to do this is to completely disable the resume feature in Lion

http://www.macrumors.com/2011/07/20/how-to-disable-lions-resume-feature/

1
  • 7
    This does work, but it's overkill since defaults write com.apple.terminal NSQuitAlwaysKeepsWindows -bool false will quash this behavior on terminal only.
    – bmike
    Commented Sep 13, 2011 at 22:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .