Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm looking to switch from screen to tmux for my terminal multiplexing needs, but there's a feature of screen that I need to replicate in tmux: the -X option, which allows one to run arbitrary screen commands inside an existing screen session. This allows me to modify a running screen session's environment to point to a new X server, since my screen sessions tend to live longer than my X11 logins. For example, I could put something screen -X setenv DISPLAY $DISPLAY in my X11 startup scripts.

Anyway, is there a way in tmux to send arbitrary commands to a running tmux session? Alternatively, a way to update environment variables in a running tmux would be acceptable.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

It's just tmux, optionally with the -t option to select a session (corresponding to -S for Screen).

tmux set-environment DISPLAY $DISPLAY
share|improve this answer

Answering the part of the question about updating the environment: tmux by default inherits certain variables from the client's environment when creating or reattaching a session.

From the manpage:

The update-environment session option may be used to update the session environment from the client when a new session is created or an old reattached.

The default is "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY".

So you don't have to do anything to get the updated DISPLAY setting when reattaching a session.

Note that this only takes effect for new windows or panes you create in the old session, but not existing windows.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.