Wait! I realized a mistake; ssh doesn’t always exit with a 0 status, even though it may be a normal exit. To make it a little clearer, the following worked:
1 2 3 4 5 | # First, check to see if we have the correct terminal! if [ "$( tty )" == 'not a tty' ] ; then /usr/bin/ssh "$@" exit fi |
That’s sweet, thank you! Will test on my machine and update the post. Good work!
]]>A quick improvement I had to implement when dealing with non-terminal windows (i.e., bash scripts):
1 2 3 4 5 6 7 | # First, check to see if we have the correct terminal! [ "$( tty )" == 'not a tty' ] && /usr/bin/ssh "$@" && exit # Generate dimension based on screensize H=$((1440 / 178 * `stty size | cut -d ' ' -f2` )) V=$((900 / 47 * `stty size | cut -d ' ' -f2` )) DIMENSIONS=$H"x"$V # Console dimensions |
This uses the the tty variable to detect whether or not its a terminal session, so it won’t try and grab the screen size from stdin-less sessions. Note, this depends on the tty variable being set which, from my basic testing, works flawlessly on bash-3.2.
Andrew
]]>So I came up with the following; this should net you the approximate resolution by converting the rows/columns to a resolution. I simply used the ratio of the columns/rows to the resolution on my laptop:
1 2 3 4 | # Generate dimension based on screensize H=$((1440/178*`stty size | cut -d ' ' -f2`)) V=$((900/47*`stty size | cut -d ' ' -f1`)) DIMENSIONS=$H"x"$V |
Its not foolproof, but its very dynamic and works great for me! :)
Andrew
]]>I did discover an error when attempting to run in snow leopard (v10.6.1):
1 2 3 | Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers. |
After a quick google search, I ran into a post (http://forums.adobe.com/thread/486208) that suggested prefixing the osascript command with the appropriate supported architecture:
1 | arch -i386 osascript ... |
So if anyone runs into this issue, just change the following line:
1 | osascript -e "tell application "iTerm" |
with this:
1 | arch -i386 osascript -e "tell application "iTerm" |
Thanks a lot for this, that solved problems I had for ages connecting to too many servers….
just a little problem, the background image disapear when I enter full screen (CMD-Enter)
cheers
julien
]]>1 | HOSTNAME=`echo $@ | sed 's/.* \(.*\)$/\1/' | sed "s/.*@//"` |
e.g. on OSX -Y forwards X11 connections easily, but using your sed expressions the command ssh -Y myhost will result in -Y being the image shown in the background.
Also, you still need to be careful that you are on the host that you logged onto originally from OSX. if you chain your ssh’s your background image will be incorrect.
]]>