Skip to content

Instantly share code, notes, and snippets.

@synackme
Created January 14, 2014 10:32
Show Gist options
  • Save synackme/8416343 to your computer and use it in GitHub Desktop.
Save synackme/8416343 to your computer and use it in GitHub Desktop.
This is a quick tip if you use an xserver that is running remotly and you want to set the DISPLAY enviroment variable when you login to the machine using ssh. It is actually very simple to do. When you use ssh it will automatically set the SSH_CLIENT enviroment variable to contain the client connection details eg the ip address port number etc..…
if [ ! $DISPLAY ] ; then
    if [ "$SSH_CLIENT" ] ; then
        export DISPLAY=`echo $SSH_CLIENT|cut -f1 -d\ `:0.0
    fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment