How can I import a .terminal file using the command line?

I'm writing a (Bash) script to automate setting up my Mac environment and would like to do this, except using the command line only. I'd also like to make that theme the default.

I have a .terminal file exported and all ready to go, I just can't figure out how to do this programmatically. Is there a documentation for this somewhere that I'm missing?

... or would these be easier using AppleScript? Never done that before though.


Use the open command, followed by the preference change:

open ~/MyTerminalSettings.terminal
defaults write com.apple.terminal "Default Window Settings" "MyTerminalSettings"

The open command will further open a new Terminal window, but the script will continue running in the original window, and you can close the new window when convenient.