Change OSX Terminal Settings from Command Line


Changing fonts and colors should be easy, also with terminals. Alas, neither iTerm2 nor OSX Terminal seem to have an easy way of doing this: you need to define a new profile or change some presets of the current profile. This is often an overkill.

Various solutions exists on the Internet, typically based on AppleScript. Starting from these works, I have put together a few functions that allow to change colors and fonts using Emacs’ color names. For a solution based on JavaScript and working on Yosemite, look at the comments below or visit Fotsies Technology Blog.


  1. Grab colors.csv (a GitHub gist) and save it in your home. The file contains all colors known to Emacs (with M-x list-colors-display) with the corresponding representation used by AppleScript.
  2. Grab the set_colors.bash (another GitHub gist) and add its content to your .bash_profile (or source the file, if you prefer)

You are done! You can now change colors from your terminal using the following commands:

For instance:

$ set_foreground_color wheat
$ set_background_color gray10
$ set_font "Oxygen Mono" 12

Now that you can change colors using a bash function, some opportunities arise. For instance, you can use the command line to change the terminal colors when connecting to a different host.