Automatic prefix change to C-a when in ssh or mosh session
This commit is contained in:
15
.config/tmux-prefix-detect.sh
Executable file
15
.config/tmux-prefix-detect.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# Auto-set tmux prefix based on connection type.
|
||||
# Called from tmux hooks: session-created and client-attached.
|
||||
if tmux show-environment SSH_CONNECTION 2>/dev/null | grep -qv '^-' || \
|
||||
tmux show-environment MOSH_SERVER_PID 2>/dev/null | grep -qv '^-'; then
|
||||
tmux set -g prefix C-a
|
||||
tmux bind-key C-a send-prefix
|
||||
tmux unbind-key C-b 2>/dev/null
|
||||
tmux display-message "Prefix: C-a (remote)"
|
||||
else
|
||||
tmux set -g prefix C-b
|
||||
tmux bind-key C-b send-prefix
|
||||
tmux unbind-key C-a 2>/dev/null
|
||||
tmux display-message "Prefix: C-b (local)"
|
||||
fi
|
||||
Reference in New Issue
Block a user