At work, I have a desktop with a monitor and a few running tmux sessions. At home, I frequently ssh into that desktop and enter my running tmux sessions. When I ssh from home, I do not want to use X11, so I do not use the -X
flag. When I go back to work (after ssh'ing from home) and use those tmux sessions on desktop, I can no longer do anything that would spawn a GUI. I can't open files in evince. When I try use matplotlib, I get a : cannot connect to X server
message.
After ssh'ing and opening an existing tmux session from home, how do I later reattach the ability to open up GUI stuff on the desktop?
The ssh'ing from home seems to make the tmux session forget that it can spawn GUI stuff.
EDIT:
Best Answer
I had the same issue. I normally use
tmux
as part of a multi-monitor X11 desktop environment, and sometimes ssh in from a chromebook, which doesn't support X11 or set$DISPLAY
. The answer by @chrisdembia works, but requires changingDISPLAY
in each new window for the rest of the tmux session, which is a pain.A permanent solution is to remove
DISPLAY
from the tmuxupdate-environment
variable in the tmux settings. You can see your current value with this command:To remove it, I added this line to my
~/.tmux.conf
file, including everything butDISPLAY
:This is further explained at Reset the shell DISPLAY variable in a tmux session over ssh, which explains why
DISPLAY
is there by default, for a different common use case.