How to stop terminal from re-opening old windows at launch?

Solution 1:

One way which won't interfere with any other apps is to clear the contents of the Saved Application State and set the folder to immutable.

Paste this into the Terminal

terminalSAS="$HOME/Library/Saved Application State/com.apple.Terminal.savedState"
[[ -d "$terminalSAS" ]] &&
rm -rf "$terminalSAS" &&
mkdir -p "$terminalSAS" &&
chflags -R uchg "$terminalSAS"

And to revert:

terminalSAS="$HOME/Library/Saved Application State/com.apple.Terminal.savedState"
chflags -R nouchg "$terminalSAS"

Breakdown


#this sets a variable for the folder of Terminal's Window data
terminalSAS="$HOME/Library/Saved Application State/com.apple.Terminal.savedState"

#check that the folder exists
[[ -d "$terminalSAS" ]] &&

#deletes the folder to clear saved window data
rm -rf "$terminalSAS" &&

#re-create blank folder
mkdir -p "$terminalSAS" &&

#set the folder to immutable (like the lock checkbox in Finder -> Get Info)
chflags -R uchg "$terminalSAS"