TLDR;
(Edit: Tested on 10.14 Mojave)
To restore Terminal to a factory state (tested on Mac OS X 10.12.6 Sierra), backing up bash profile, history file, Terminal preferences and savedstate :
#backing up
backupdir="$HOME/Terminal_Backup_Files"
mkdir -p "$backupdir"
defaults export com.apple.Terminal - > "$backupdir"/Terminal_defaults.xml
cp -rf "$HOME/Library/Saved Application State/com.apple.Terminal.savedState" "$backupdir"/
cp "$HOME/Library/Preferences/"com.apple.Terminal.plist* "$backupdir"/
cp -RLafv "$HOME"/.bash* "$backupdir"/
#restoring to factory state
defaults delete com.apple.Terminal
rm "$HOME/Library/Preferences/"com.apple.Terminal.plist*
rm -rf "$HOME/Library/Saved Application State/com.apple.Terminal.savedState/"
rm "$HOME"/.bash*
killall Terminal
To restore it back to how it was
backupdir="$HOME/Terminal_Backup_Files"
defaults import com.apple.Terminal - < "$backupdir"/Terminal_defaults.xml
cp -rf "$backupdir"/com.apple.Terminal.savedState "$HOME/Library/Saved Application State"/
cp "$backupdir"/com.apple.Terminal.plist* "$HOME/Library/Preferences/"
source "$backupdir"/.bash_profile #in case backup profile & history was over the default 500 lines
cp -RLafv "$backupdir"/.bash* "$HOME"/
killall Terminal
Explanation;
bash
doesn't have preferences, but it does follow directives such as profiles, environment variables, and any other sources and flags upon starting a login session. Some of this is influenced by the Terminal
app itself.
One surefire method that will reset both Terminal and delete the user profile:
- Delete the Terminal.app defaults
- Remove the preference files (and any preference lock files)
- Delete
.bash*
files and folders from the home folder.
- Kill existing instances of Terminal