1
0
mirror of https://github.com/samoshkin/tmux-config.git synced 2026-01-04 00:38:01 +00:00

Configure keybinding and command to renew environment (SSH_AUTH_SOCK, DISPLAY) inside tmux session when attached back to existing session

This commit is contained in:
Alexey Samoshkin
2017-11-24 23:58:55 +02:00
parent 6377634a56
commit 5cc0e65df4
2 changed files with 25 additions and 6 deletions

12
tmux/renew_env.sh Executable file
View File

@@ -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;