Prevent Terminal from overwriting preferences on exit

by CosmoM   Last Updated June 13, 2019 08:12 AM

When a user loads my C++ program, I want Terminal to look a certain way. I solved this by wrapping my program in an AppleScript .app which overwrites ~/Library/Preferences/ (making a backup first) before opening the program. With a subsequent killall cfprefsd, this works (if Terminal wasn't open to begin with!), but I don't want to mess up the user's own Terminal preferences. So, after calling my program I overwrite ...Terminal.plist again with the backup of the original settings.

The problem is that when my program is done and Terminal closes, its preferences are automatically overwritten with that of the current window, meaning the user is stuck with the look I set for my program. I tried to counter this by having the AppleScript wait until Terminal was closed and then overwriting the plist with the backup once more, which works, but if my app were to be closed before Terminal then this fails of course. And the whole process seems pretty hacky to begin with.

Can I prevent Terminal from overwriting its preferences when it closes? Or even better, can I have my code run in a terminal that looks the way I want without messing with the user's settings? Preferably I wouldn't use Terminal at all to run my code (so it also doesn't fail when Terminal was already open), but I think the only alternative is writing my own...

Related Questions

Updated June 05, 2017 21:12 PM

Updated September 05, 2017 10:12 AM

Updated July 21, 2018 21:12 PM

Updated April 22, 2015 04:05 AM