summaryrefslogtreecommitdiffstats
path: root/.zshrc
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2019-10-30 02:04:02 +0100
committerTharre <tharre3@gmail.com>2019-10-30 02:04:02 +0100
commit936d41a0af416c516c6051cf5e5c7dca68ebcb14 (patch)
tree98f0334758553aa069d6d183347d87b274e30550 /.zshrc
parenta8af042aa9c5573c89717daca110590ac6dacf1b (diff)
downloaddotfiles-936d41a0af416c516c6051cf5e5c7dca68ebcb14.tar.gz
dotfiles-936d41a0af416c516c6051cf5e5c7dca68ebcb14.tar.xz
dotfiles-936d41a0af416c516c6051cf5e5c7dca68ebcb14.zip
tmux: auto refresh environment on attach
Automatically refresh the following environment variables in all zsh sessions inside tmux when we attach: SSH_CONNECTION SSH_CLIENT SSH_TTY SSH_AUTH_SOCK DISPLAY
Diffstat (limited to '.zshrc')
-rw-r--r--.zshrc16
1 files changed, 15 insertions, 1 deletions
diff --git a/.zshrc b/.zshrc
index f6beb89..d5730f6 100644
--- a/.zshrc
+++ b/.zshrc
@@ -112,6 +112,16 @@ function title {
esac
}
+function refresh_tmux {
+ if [ -n "$TMUX" ]; then
+ eval $(tmux showenv -s SSH_CONNECTION)
+ eval $(tmux showenv -s SSH_CLIENT)
+ eval $(tmux showenv -s SSH_TTY)
+ eval $(tmux showenv -s SSH_AUTH_SOCK)
+ eval $(tmux showenv -s DISPLAY)
+ fi
+}
+
function set_title_precmd {
title "%15<..<%~%<<" $ZSH_THEME_TERM_TITLE_IDLE
}
@@ -126,8 +136,12 @@ function set_title_preexec {
title '$CMD' '%100>...>$LINE%<<'
}
+function refresh_preexec {
+ refresh_tmux
+}
+
precmd_functions+=(set_title_precmd)
-preexec_functions+=(set_title_preexec)
+preexec_functions+=(set_title_preexec refresh_preexec)
# zshenv may not be attached to a tty, so we set this here instead
export GPG_TTY="$(tty)"