Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Possibly Easier?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Possibly Easier?
Authored by: sharumpe on Aug 25, '04 12:07:19PM

How about a short perl (or shell, if that's your preferred poison) script to just use the 'defaults' command to change the background color every time you login (ie. open a terminal window)?

This is non-functional, but something like this:

#!/usr/bin/perl

# Colors to choose from, in R G B
@colors = ( "124 248 182", "219 183 28", "55 27 138" );

# Randomly select one
$nextIndex = int( rand( scalar( @colors ) ) );

# Set the new background color via the 'defaults' command
exec( "defaults", 
      "write",
      "com.apple.terminal",
      "BackgroundColor",
      $colors( $idx ) );

I didn't poke around in the tags for Terminal, but something like that should be possible...

Call this script from your .profile or .login file, and every time you open a terminal, the script will select a random color from the list for the next new window.

Mr. Sharumpe



[ Reply to This | # ]
Possibly Easier?
Authored by: otomo on Aug 26, '04 02:21:02AM
Close, but the value you change is a string of float numbers, I just figured out where the foreground and background were.

Randomness gets you some nasty combinations though.

Anyone know how to start the Terminal from the command line and get a new window and not another instance of Terminal.app?

Then I could just throw this in the dock and run it. As is it is a minor novelty. SAVE YOUR CURRENT SETTINGS!!!

chmod 700 or u+x depending on your permission paranoia.

#!/usr/bin/perl
#
# format appears to be as follows background_rgb[0-2] foreground_rgb[12-14]
# so just grab the old values, plop them into an array
# write over the area for fg and bg and call defaults
@colors = split ' ', `defaults read com.apple.terminal TextColors`;

#cheap, set the fg(text) then the bg colors randomly
(@colors[0], @colors[1], @colors[2]) = (rand(1), rand(1), rand(1));
(@colors[12], @colors[13], @colors[14]) = (rand(1), rand(1), rand(1));

$colorstring = undef;

foreach $x (@colors) {
        $tmp = sprintf "%1.3f", $x;
        $colorstring = $colorstring ? "$colorstring $tmp" : $tmp;
}
system("defaults", "write", "com.apple.terminal", "TextColors", $colorstring);


[ Reply to This | # ]