02 Nov 2006

Random Color Terminal

I've always wanted something like this. Daniel Jalkut of the Red Sweater Blog has created an AppleScript to randomize the color scheme of the terminal. Just drop it in ~/Library/Scripts/Applications/Terminal and it will show up in the script menu under "Terminal Scripts." Click on it until you find a color scheme that pleases you.

There are two cool hacks that I came up with for this script. Both involve changing ~/.bash_profile (or the startup script for whatever shell that you use). If you don't have a file named .bash_profile in your home directory, then create one. AppleScripts can be invoked from the command line by using the osascript command, and we can use this to our advantage in two ways.

  1. Every time we start up a new terminal, randomize the color. Simply add the line

    osascript ~/Library/Scripts/Applications/

    somewhere in your .bash_profile (all on one line).

  2. Set an alias to the above command so that we can change the color very quickly without needing to navigate to the script menu with the mouse. To do this, add the line

    alias newcol='osascript ~/Library/Scripts/Applications/

    to .bash_profile (all on one line). Now, whenever you type newcol at the command line, you will get a new color scheme.