Comments on: How to show SSH host name on the iTerm’s background https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/ In my blog I'll try to describe about interesting technologies, my discovery in IT and some useful things about programming. Wed, 23 Jun 2010 18:48:13 +0000 hourly 1 https://wordpress.org/?v=6.6.1 By: Andrew McFague https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-283424 Tue, 06 Oct 2009 17:24:19 +0000 http://kpumuk.info/?p=612#comment-283424 In reply to Dmytro Shteflyuk.

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
]]>
By: Dmytro Shteflyuk https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-283420 Tue, 06 Oct 2009 13:48:24 +0000 http://kpumuk.info/?p=612#comment-283420 In reply to Andrew McFague.

That’s sweet, thank you! Will test on my machine and update the post. Good work!

]]>
By: Andrew McFague https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-283419 Tue, 06 Oct 2009 13:45:13 +0000 http://kpumuk.info/?p=612#comment-283419 In reply to Andrew McFague.

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

]]>
By: Andrew McFague https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-283337 Thu, 01 Oct 2009 13:23:21 +0000 http://kpumuk.info/?p=612#comment-283337 I loved this, but the problem is, I use a fullscreen monitor specifically for SSH at work, but I only have my regular laptop screen at home. So, of course, the background would be extremely distorted.

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

]]>
By: Doug Vasquez https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-283024 Thu, 17 Sep 2009 16:11:42 +0000 http://kpumuk.info/?p=612#comment-283024 Great tip, thanks for sharing!

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"
]]>
By: jujudellago https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-282001 Thu, 02 Jul 2009 13:34:05 +0000 http://kpumuk.info/?p=612#comment-282001 Hi,

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

]]>
By: j2 https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-281091 Wed, 06 May 2009 19:48:36 +0000 http://kpumuk.info/?p=612#comment-281091 This will work better with arguments passed to ssh:

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.

]]>
By: dgs https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-281025 Sat, 02 May 2009 03:05:32 +0000 http://kpumuk.info/?p=612#comment-281025 Very cool, that would be so useful in large data centers!!!

]]>
By: e0ne https://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/comment-page-1/#comment-281017 Fri, 01 May 2009 09:42:20 +0000 http://kpumuk.info/?p=612#comment-281017 It’s interesting feature. But I think it’s not very useful.

]]>