Send a command to a running tmux session (like screen -X)

environment-variablestmux

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.

Best Answer

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

tmux set-environment DISPLAY $DISPLAY
Related Question