Automatically Setting Your X Display To From Whence You Came
I use ssh from cygwin to connect from my laptop to various linux servers. For various no good reasons, I use the eXceed X display software on my laptop rather than cygwin's. I have a batch file set up which permits me to launch a rxvt with a
ssh $USER@$PLACE command in it. This ssh usually does not know about an X server, so it generally tends to not set the X display on the system where I land. This is annoying.
Therefore, today's slightly-clever-bit in my .bash_profile (on the system I ssh
too, not my laptop):
if [ -z "$DISPLAY" ] ; then
MyTTY=`who am i | awk '{print $2." "}'`
export DISPLAY=`w | grep "$MyTTY" | awk '{print $3.":0.0"}'`
fi
echo Display:$DISPLAY