Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tmux plugin refresh tmux global environments automatically. #5282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

delphij
Copy link
Contributor

@delphij delphij commented Aug 4, 2016

This is handy for tmux users who work in interactive mode. By default, tmux would pass through e.g. X11, SSH agent, etc. via global environment.

@robbyrussell robbyrussell added Area: plugin Issue or PR related to a plugin Status: testers needed Pull Requests that are waiting for testers to merge labels Aug 15, 2016
@delphij
Copy link
Contributor Author

delphij commented Aug 17, 2016

Hi, @robbyrussell are you looking for someone to do the testing, or would like some instructions?

To test:

  • Enable the 'tmux' plugin in ~/.zshrc

ssh -A to the system, then run 'tmux'.

env | grep SSH_AUTH_SOCK

Detach the session (Ctrl+B, D), logout, then repeat ssh -A, tmux

Hit enter (which makes sure that zsh have a new prompt)

env | grep SSH_AUTH_SOCK

The result should be different. ssh'ing to other hosts would be relayed to user's workstation for SSH agent authentication.

@xals
Copy link

xals commented Mar 15, 2017

Hello @delphij,
You may use the preexec hook instead of precmd so you would not have to press enter just before running a command. Anyway, I don't know how it behaves on variable substitution, to be tested, I think.

@delphij
Copy link
Contributor Author

delphij commented Mar 19, 2017

Good point! I have updated my tree and it worked.

@khsing
Copy link

khsing commented Mar 19, 2017

I have tested this feature, truly helped me while I am connected throughtmux, very good one.

ps. second tmux is attach to the pervious session, not new one.

➜  ~ env | grep SSH_AUTH # first ssh connection and tmux new session 
SSH_AUTH_SOCK=/tmp/ssh-dxCaf0fmj8/agent.22865
➜  ~ env | grep SSH_AUTH  # second ssh connection and tmux attach back
SSH_AUTH_SOCK=/tmp/ssh-xtau3V7aPt/agent.23157
➜  ~ 

Thank you very much.

@MikeDacre
Copy link

Personally, I think this PR should be merged, the functionality is super helpful and can be easily toggled on/off by the user.

@xals I think you were asking about how changing variables that are also set in the tmux update-environment command, it is true that with this plugin those commands would be automatically overridden, and any variables set from them (e.g. i=$DISPLAY) will not be updated by the preexec hook.

@delphij I would suggest also adding tmux ls >/dev/null 2>/dev/null to your test on line 106, because otherwise if someone SSHs into another machine from within tmux, and that machine has this plugin installed, it will run anyway as both variables will be set, so then the user will get tmux errors on every prompt/command. I would suggest changing the test to:

[[ -n "$TMUX"  && "$ZSH_TMUX_AUTOREFRESH" == "true" ]] && tmux ls >/dev/null 2>/dev/null

@delphij
Copy link
Contributor Author

delphij commented Jan 7, 2019

I've rebased my changes over the latest version of the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: plugin Issue or PR related to a plugin Status: testers needed Pull Requests that are waiting for testers to merge
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

None yet

6 participants