Mac OS X: setting background color of terminal in a shell script
I find it quite convenient to “cluster” terminal windows by their background colours.
In Mac OS X almost every application can be scripted with
AppleScript. The following small shell
script allows calls like setbgcolor 0xff 0 0 0x80 to get a red window with 50% transparency.
#!/bin/bash
a=$4
if [ -z "$a" ]; then
a=0xff
fi
r=$[$1<<8]
g=$[$2<<8]
b=$[$3<<8]
a=$[$a<<8]
osascript -e "tell application \"Terminal\"
tell window frontmost
set background color to {$r, $g, $b, $a}
end tell
end tell
"
I also noted that, if the transparency is less than 0xa, you can click through the window.
Last modified 27.05.2004 11:21