Do you know any germans? If you do, you'll know that anything they do with computers is the ultimate in cool. [Robin][robin] lives in Germany, he works on Flock with me. When Robin opens a terminal, it has a randomized foreground and background color. That's l33t.
His magic comes through the use of Linux and the fact that xterm has a million and a half customizable settings; however, I user Mac and iTerm and lack the same set of neat features he has. But I make do.
This is a script that will change the background color of your current iTerm session:
-- colorize.scpt property r_min : 0 property r_max : 10000 property g_min : 0 property g_max : 10000 property b_min : 0 property b_max : 10000set r to random number from r_min to r_max set g to random number from g_min to g_max set b to random number from b_min to b_max
tell application "iTerm" activate set mySess to current session of current terminal tell mySess set background color to {r, g, b} end tell end tell
Now, that's all in good (I suggest you hook it up to a Quicksilver trigger, mine is set to F5, so if you ever don't like the color you can just keep cycling through), the defaults keep the background near-black but different enough that they are distinguishable. I use a colored terminal so I don't mod my foreground color, but you could with a similar technique.
However, you may want this to happen automatically to every terminal, because that is the "most l33t." Here's how you do it (replace the path with the path to where you've saved the script):
!/bin/sh
~/bin/c -- Color cycling command
COLORIZE_SCRIPT=$HOME/path/to/iTerm/colorize.scpt osascript $COLORIZE_SCRIPT
and then add a line to your zshrc -- or bashrc if you're stuck in the past -- to run it when you launch new terminals:
[ -f "$HOME/bin/c" ] && source $HOME/bin/c
I use transparency on my iTerms because transparency is also l33t. But sometimes you don't want that transparency, possibly because you have set your background to a very unl33t color.
This script will toggle the opacity of your current iTerm session between 0% and 10%:
-- opacity.scpt
tell application "iTerm"
activate
set mySess to current session of current terminal
set oldTrans to transparency of mySess
if oldTrans > 0 then
tell mySess
set transparency to 0.0
end tell
else
tell mySess
set transparency to 0.1
end tell
end if
end tell
I have that one set to trigger on Shift-F5.
These scripts are all cool once you're in iTerm already, but what happens when you are sitting in some horrible user interface somewhere in the wastelands of your company's product and you really need a hit of the ol' command-line to cure what ails ya. That's where the next script comes in, I originally got it from somewhere else but it was long enough ago that I don't rightly remember the source.
What it does is open a new iTerm window and changes to the directory you may be looking at in Finder or your Desktop if Finder has no windows open:
tell application "Finder"
try
set t to target of Finder window 1
on error
-- there is no window, use desktop instead
set t to desktop
end try
-- there is no 'is subclass of... :-(
-- you might to to add the 'package' class to the list
if class of t is not in {folder, disk, ¬
class of desktop, class of trash} then ¬
set t to container of t
set thePath to (quoted form of ¬
POSIX path of (t as alias))
end tell
tell application "iTerm"
activate
set w to (make new terminal)
tell w
set number of columns to 100
set number of rows to 30
launch session "Default Session"
tell the last session
write text "cd " & thePath
end tell
end tell
end tell
That one is totally F1. Sometimes I hit it a bunch of times just to see all the pretty colors. Or to make myself look totally l33t to anybody passing by. You know it's true.
Technorati Tags: applescript, code, iterm, osx