Last active
October 24, 2016 23:05
-
-
Save towo/b5643ba96f987df54acc54470e6be460 to your computer and use it in GitHub Desktop.
Updating shells in tmux for new X sessions, specifically GNOME shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY DBUS_SESSION_BUS_ADDRESS' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precmd() { | |
if [ -n "${TMUX}" ]; then | |
local _tmux_env; | |
_tmux_env=$(tmux show-environment); | |
if [ "${_tmux_env}" != "${_expected_tmux_env}" ]; then | |
eval $(echo "${_tmux_env}" | sed -e '/^-/!{ s/=/="/; s/$/"/; s/^/export /; }' -e 's/^-/unset /' -e 's/$/;/'); | |
_expected_tmux_env="${_tmux_env}"; | |
fi; | |
fi; | |
} | |
# vim: filetype=zsh : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just drop this function into your zsh infrastructure and get it loaded in your shells and ensure your tmux also updates
DBUS_SESSION_ADDRESS
.This will automatically source all things you set in
update-environment
- especiallyDBUS_SESSION_BUS_ADDRESS
- to update to your current runtime environment. So if you have to shoot your X session in the head and get a new one, just push enter in your shell to still be able to talk to your new ssh agent started with the D-Bus session.