feat(tmux): Add shell environment propagation and refresh function

This commit is contained in:
Tanguy Herbron 2023-09-14 10:00:37 +02:00
parent 5df3a9898c
commit 5b8c7040be
2 changed files with 24 additions and 1 deletions

View File

@ -25,7 +25,7 @@ set-option -g display-panes-colour colour166 #orange
set-window-option -g clock-mode-colour green #green set-window-option -g clock-mode-colour green #green
# disable DISPLAY requirement when opening pane/window # disable DISPLAY requirement when opening pane/window
set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY" set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY DISPLAY I3SOCK"
set -g status-interval 1 set -g status-interval 1
set -g status-justify centre # center align window list set -g status-justify centre # center align window list

23
.zshrc
View File

@ -118,6 +118,29 @@ function wg-reload() {
sudo bash -c 'cd /etc/wireguard && wg syncconf $0 <(wg-quick strip $0)' $1 sudo bash -c 'cd /etc/wireguard && wg syncconf $0 <(wg-quick strip $0)' $1
} }
if [ -n "$TMUX" ]; then
function refresh {
sshauth=$(tmux show-environment | grep "^SSH_AUTH_SOCK")
if [ $sshauth ]; then
export $sshauth
fi
display=$(tmux show-environment | grep "^DISPLAY")
if [ $display ]; then
export $display
fi
i3sock=$(tmux show-environment | grep "^I3SOCK")
if [ $i3sock ]; then
export $i3sock
fi
}
else
function refresh { }
fi
function preexec {
refresh
}
# Finally, start a tmux session # Finally, start a tmux session
[ -x "$(command -v tmux)" ] \ [ -x "$(command -v tmux)" ] \
&& [ -z "${TMUX}" ] \ && [ -z "${TMUX}" ] \