: # my_ssh - ssh wrapper; sets bg color for Terminal.app # # Written by Rich Morin , 2003.07.10 # upgraded by Vicki Brown # # use: # my_ssh # # e.g. # my_ssh green catnip.corp # # See http://www.dreness.com/tips.html#bgcolor for details # # The terminal.app applescript dictionary says that the background color # value is a text string, such as "black", "gray", etc... but that just won't # do, since most of the 8 or 9 colors that can be described that way are # fairly useless as background colors. # Even though it's possible to manually specify the background color using # the color picker "Terminal menu --> Window Settings...", I had a hard time # figuring out how to programmatically articulate non-standard colors. # Turns out that an easy way to figure out how applescript and # terminal.app describe the colors is to simply ask it: # tell application "Terminal" to set x to the background color # of the front window # The result window will be populated with a three or four item list # (depending on whether or not there's any alpha transparency) which can be # used to describe colors back to terminal.app via applescript. For example: # tell application "Terminal" to set the background color # of the front window to {32767, 29478, 27360} # At this point, we're able to gather the numerical representation of the # colors we want by simply using the color picker to choose a color, then # using applescript to get the values of that color. case $1 in beige) color='{-1, -1, -6000}' # pale yellow/beige host=$2 ;; blue) color='{-13427, -1, -713}' # light blue host=$2 ;; pink) color='{-1, -8164, -8938}' # pink host=$2 ;; grey-green) color='{-5973, -4450, -10174}' # grey-green host=$2 ;; green) color='{-5981, -1, -1676}' # pale green host=$2 ;; green2) color='{-7894, -1, -4546}' # spring green host=$2 ;; purple) color='{-8493, -5361, -1}' # bluish purple host=$2 ;; lavender) color='{-3642, -7283, -1}' # lavender (rosy purple) host=$2 ;; yellow) color='{-1930, -1, -17016}' # a fairly unattractive yellow host=$2 ;; salmon) color='{-1, -11620, -21993}' # a salmony orange host=$2 ;; magenta) color='{-1, -17766, -7988}' # a rosy magenta/pink host=$2 ;; *) color='{-5973, -4450, -10174}' # grey-green host=$1 ;; esac hostname=`expr $host : '^.*@\(.*\)$'` if [ $?XTERM_COMPAT ]; then settitle $hostname fi osascript << EOT set thecolor to $color repeat with i in thecolor if i < 0 then set contents of i to 65536 + i end repeat tell application "Terminal" set the background color of the front window to $color end tell EOT ssh -X $host osascript << EOT tell application "Terminal" set the background color of the front window to "white" end tell EOT if [ $?XTERM_COMPAT ]; then settitle $HOST $FRAME fi