diff --git a/tmux/renew_env.sh b/tmux/renew_env.sh new file mode 100755 index 0000000..0e51818 --- /dev/null +++ b/tmux/renew_env.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -eu + +pane_fmt="#{pane_id} #{pane_in_mode} #{pane_input_off} #{pane_dead} #{pane_current_command}" +tmux list-panes -s -F "$pane_fmt" | awk ' + $2 == 0 && $3 == 0 && $4 == 0 && $5 ~ /(bash|zsh|ksh|fish)/ { print $1 } +' | while read -r pane_id; do + # renew environment variables according to update-environment tmux option + # also clear screen + tmux send-keys -t "$pane_id" 'Enter' 'eval "$(tmux show-env -s)"' 'Enter' 'C-l' +done; \ No newline at end of file diff --git a/tmux/tmux.conf b/tmux/tmux.conf index dff1185..8a3d0cf 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -309,13 +309,20 @@ set -g @prefix_highlight_show_copy_mode 'on' set -g @prefix_highlight_copy_mode_attr "fg=$color_dark,bg=$color_secondary" +# ===================================== +# === Renew environment === +# ===================================== +set -g update-environment \ + "DISPLAY\ + SSH_ASKPASS\ + SSH_AUTH_SOCK\ + SSH_AGENT_PID\ + SSH_CONNECTION\ + SSH_TTY\ + WINDOWID\ + XAUTHORITY" -# ============================ -# === Hooks === -# ============================ - -# Prompt to rename window right after it's created -set-hook -g after-new-window 'command-prompt -I "#{window_name}" "rename-window '%%'"' +bind '$' run "~/.tmux/renew_env.sh" # ============================