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:
12
tmux/renew_env.sh
Executable file
12
tmux/renew_env.sh
Executable 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;
|
||||||
@@ -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"
|
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"
|
||||||
|
|
||||||
# ============================
|
bind '$' run "~/.tmux/renew_env.sh"
|
||||||
# === Hooks ===
|
|
||||||
# ============================
|
|
||||||
|
|
||||||
# Prompt to rename window right after it's created
|
|
||||||
set-hook -g after-new-window 'command-prompt -I "#{window_name}" "rename-window '%%'"'
|
|
||||||
|
|
||||||
|
|
||||||
# ============================
|
# ============================
|
||||||
|
|||||||
Reference in New Issue
Block a user