1

I normally ssh -X to a remote Linux box, launch GNU screen and run vim in server mode inside screen. After detaching and re-attaching to the screen session, I cannot send files to the vim server anymore. I guess it is because the re-attached screen session lost its connection to the X-window server, which is used by the vim server for communication. Is there anyway to solve this problem?

1 Answer 1

1

This is because your new ssh connection uses new values for the $DISPLAY and/or $XAUTHORITY environment variables, but the screen session would still be using values from the original ssh connection.

You could create a script with the following contents, run that before reattaching to the screen session, then in each shell inside of the screen session run source ~/.Xsetup

#!/bin/sh
exec > $HOME/.Xsetup
echo DISPLAY=$DISPLAY
echo XAUTHORITY=$XAUTHORITY

This would copy the new values into any shells from which you source the generated script file. But the screen session itself would still have the old values, and any new programs started would still get those as well. Those values could be fixed by running the following after sourcing the .Xsetup file.

screen -X setenv DISPLAY $DISPLAY
screen -X setenv XAUTHORITY $XAUTHORITY
1
  • Thank you. But I guess the 'vim' server already running in the 'screen' is still using the old environment variables. How can I tell it to use the new one saved in '~/.Xsetup'?
    – Jing
    Nov 16, 2012 at 22:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .