From 84401fd39cbfc0bc3bc1ba5d34b731131cfd924d Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Wed, 13 May 2026 13:43:12 +0100 Subject: feat(zsh): add reload-env for stale zellij panes Re-exports WAYLAND_DISPLAY, SWAYSOCK, DBUS, SSH_AUTH_SOCK etc. from the currently running sway process, so a zellij pane whose server was started in a different session (SSH-attached, logout/login, etc.) regains working GUI/clipboard/systemctl --user. --- dot_config/zsh/dot_zshrc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'dot_config') diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index 7bb6010..d4a9715 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -260,6 +260,28 @@ za() { esac } +# Re-import session env from the running sway process. Useful inside a +# stale zellij pane whose server was started in a different session +# (e.g. attached over SSH, then reattached locally, or vice versa). +reload-env() { + local pid + pid=$(pgrep -u "$UID" -x sway | head -1) || { + echo "reload-env: no sway process found for $USER" >&2 + return 1 + } + local kv + while IFS= read -r -d '' kv; do + case $kv in + WAYLAND_DISPLAY=*|SWAYSOCK=*|DISPLAY=*|\ + DBUS_SESSION_BUS_ADDRESS=*|XDG_RUNTIME_DIR=*|\ + XDG_CURRENT_DESKTOP=*|XDG_SESSION_TYPE=*|\ + SSH_AUTH_SOCK=*) + export "$kv" + ;; + esac + done < "/proc/$pid/environ" +} + # Just alias j='just' -- cgit v1.3.1