Prevent Terminal from overwriting preferences on exit
I'd look into what can be done with applescript using the scripting dictionary. 

script editor > file > open scripting dictionary

I do not know the details of what you are doing but here are some coloring options.