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 profile or change some of the options 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 the .colors.csv file available at osx terminal colors from cli (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 functions available at: osx terminal colors from cli and add them to your .bash_profile (or source them, if you prefer)

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

  • set_foreground_color <color-name>
  • set_background_color <color-name>
  • set_theme foreground-color <color-name>
  • set_font <font-name>

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 change colors when connecting to a different host.

Get in touch