Random Color Terminal

11/2/2006

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/
    Terminal/RandomColorTerminal.scpt

    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/
    Terminal/RandomColorTerminal.scpt'

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

  • http://www.red-sweater.com/blog/ Daniel Jalkut

    Hey – glad you like the script! Minor correction, you’ll have to put an “Applications” directory in there in the Scripts folder path, to make it show up correctly in the script menu only under Terminal.

  • http://snier.com Tyler

    Yes – good call. I got it in the right place on my computer, but typed it wrong in the post. That’s what happens when you try to type in paths from memory :)

    In any case, the path is now correct.