Browse Source

Automatically update environment variables in tmux sessions

Emmanuel Bouthenot 12 years ago
parent
commit
a72c94a389
1 changed files with 7 additions and 0 deletions
  1. 7 0
      .zsh.d/config.d/prompt.zsh

+ 7 - 0
.zsh.d/config.d/prompt.zsh

@@ -82,6 +82,12 @@ pr_git_prompt() {
     echo -n "${git_prompt}"
 }
 
+pr_update_tmux_env() {
+    if [ -n "$TMUX" ] && command -v git >/dev/null 2>&1 ; then
+        source <(tmux show-environment | sed -r -e '/^-/d' -e 's/^([^=]+)=(.*)$/\1="\2"/')
+    fi
+}
+
 preexec() {
     case "$TERM" in
         xterm*|screen*)
@@ -113,6 +119,7 @@ precmd() {
             fi
         ;;
     esac
+    pr_update_tmux_env
 }
 
 myprompt() {