In X11 days, I had a script that would randomly pick a pastel background color and then open a fresh xterm. This was easy to do because I could just pass an argument for (as I recall) -background.
Does Terminal.app have such an interface? I would prefer to do this via a bash script but I can cope with AppleScript if needed.
I tend to use tabs within one Terminal window which may complicate things as well.
I'm currently on Mojave.
Best Answer
You can indeed use AppleScript to change the Terminal background color.
For example:
You can execute it from the command line with:
You can then change more attributes:
To execute this kind of longer script from the Terminal, you can save it into a separate file
~/.terminal_change_color.scpt
then, call it from the terminal:You can then add it to your
~/.bash_profile
so that it executes for every new Terminal window you open:Below is a longer script to choose a random background color. As @nohillside noticed, you also need to adjust the text color to make it readable (white text on dark background, and black text on light backgound). The script handles that.
Alternatively, you can create like 30 themes into your Terminal Preferences > Profiles, and select one randomly:
Credits to: