diff options
| author | 2026-05-13 13:43:12 +0100 | |
|---|---|---|
| committer | 2026-05-13 13:43:12 +0100 | |
| commit | 84401fd39cbfc0bc3bc1ba5d34b731131cfd924d (patch) | |
| tree | 4438d510c8353ad567df75b074198505508b9a11 /dot_config/zsh/dot_zshrc | |
| parent | 22dbd67b564fcef4b06eab0b62f8551f2ad6ef65 (diff) | |
| download | dotfiles-84401fd39cbfc0bc3bc1ba5d34b731131cfd924d.tar.gz dotfiles-84401fd39cbfc0bc3bc1ba5d34b731131cfd924d.tar.bz2 dotfiles-84401fd39cbfc0bc3bc1ba5d34b731131cfd924d.zip | |
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.
Diffstat (limited to 'dot_config/zsh/dot_zshrc')
| -rw-r--r-- | dot_config/zsh/dot_zshrc | 22 |
1 files changed, 22 insertions, 0 deletions
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' |
