Skip to content

When attaching to tmux session, update $DISPLAY for each tmux pane in that session.

License

Notifications You must be signed in to change notification settings

lljbash/tmux-update-display

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tmux update $DISPLAY

Inspired by https://gist.github.com/mikeboiko/b6e50210b4fb351b036f1103ea3c18a9.

The problem:

When you ssh -X into a machine and attach to an existing tmux session, the session contains the old $DISPLAY env variable.

In order the x-server/client to work properly, you have to update $DISPLAY after connection.

For example, the old $DISPLAY=:0 and you need to change to DISPLAY=localhost:10.0 for the ssh session to perform x-forwarding properly.

The solution:

When attaching to tmux session, update $DISPLAY for each tmux pane in that session This is performed by using tmux send-keys to the shell.

This script handles updating $DISPLAY within vim also.

Recommendation

Install zsh-renew-tmux-env for zsh users to update $DISPLAY silently.

Installation

Installation with Tmux Plugin Manager (recommended)

Add plugin to the list of TPM plugins in .tmux.conf:

set -g @plugin 'lljbash/tmux-update-display'

Hit prefix + I to fetch the plugin and source it.

Manual Installation

Clone the repo:

$ git clone https://github.com/lljbash/tmux-update-display ~/clone/path

Add this line to the bottom of .tmux.conf:

run-shell ~/clone/path/update-display.tmux

Reload TMUX environment:

# type this in terminal
$ tmux source-file ~/.tmux.conf

About

When attaching to tmux session, update $DISPLAY for each tmux pane in that session.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages