Thank you to everyone who replied!

While not exactly the solution I wanted, the various pointers got me
looking in the right direction and I was able to craft a good solution
that's fairly flexible and works very well for me.  I figured that
people would like to know how in case they were looking for a similar
solution.

It requires a mix of both bash scripting and AppleScript.  First is
the AppleScript:
---
(*  set_term_settings.scpt
 *  Copyright (c) 2010 Steve deRosier
 * Licensed under the terms of the MIT License
 *)
on run argv
        set mySettingName to item 1 of argv
        tell application "Terminal"
                set myWindow to front window
                set myTab to front tab of myWindow
                try
                        set current settings of myTab to settings set 
mySettingName
                        (* just ignore an error and leave at the current 
setting *)
                end try
        end tell
end run
---
Save that as set_term_settings.scpt in ~/scripts

The AppleScript simply tells Terminal to set the current settings to a
settings name passed on the command-line.  The basic use is:
`osascript set_term_settings.scpt "cal-sierra.com"`

Then you need some bash scripting to make it work.  I added the
following to my .bashrc:
---
# Copyright (c) 2010 Steve deRosier
# Licensed under the terms of the MIT License
export TERM_SETTINGS_SCPT="$HOME/scripts/set_term_settings.scpt"

if [ -f "${TERM_SETTINGS_SCPT}" ]
then
    function _ssh {
        if [ ${1} == "-X" ]
        then
            osascript ${TERM_SETTINGS_SCPT} "X-Forward"
        else
            osascript ${TERM_SETTINGS_SCPT} "${!#}"
        fi

        ssh $*

        osascript ${TERM_SETTINGS_SCPT} "Basic"
    }

    alias ssh="_ssh"
    alias sshx="_ssh -X"
else
    alias sshx="ssh -X"
fi

---

Basically, it creates a function _ssh that calls the script to change
the settings set, calls ssh, and then when ssh is all done (you call
exit on the remote computer) it calls the script to change back to the
Basic set.  There's a special clause for -X, because I like to color
any ssh -X sessions red so I remember to close any back-grounded X
programs before I close the terminal.

All you have to do is create a terminal settings set that is named the
same as the machine you're sshing into.

So, for the command:
`ssh cal-sierra.com`
I have a cal-sierra.com settings set.

It makes the assumption that the last thing on the command-line is the
machine you're going into.  And it doesn't do any special parsing to
separate the machine name from other parts.  So if you've got to do
something 'fancy' like:
`ssh [email protected]`
you'll need to name the profile "[email protected]".

So it's not without limitations, but for what I want, it is good
enough for me.  Someone who wants to do better could do some sort of
fancy awk processing of the command arguments to get a better
solution.

If anyone wants to use the above, feel free to do so, consider it
licensed under the MIT license.

- Steve

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.

To unsubscribe from this group, send email to 
bbedit+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to