Add tmux alt+arrow bindings if missing

This commit is contained in:
David Heinemeier Hansson
2026-02-28 17:01:11 +01:00
parent aa3ea5b04a
commit 7934b0d51b
3 changed files with 29 additions and 4 deletions
+1 -4
View File
@@ -3,7 +3,4 @@
# Overwrite the user tmux config with the Omarchy default and reload tmux.
omarchy-refresh-config tmux/tmux.conf
if pgrep -x tmux; then
tmux source-file ~/.config/tmux/tmux.conf
fi
omarchy-restart-tmux
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
# Restart tmux if running with the latest configuration
if pgrep -x tmux; then
tmux source-file ~/.config/tmux/tmux.conf
fi
+21
View File
@@ -0,0 +1,21 @@
echo "Add Alt+Arrow keybindings for tmux window and session navigation"
TMUX_CONF=~/.config/tmux/tmux.conf
if [[ -f $TMUX_CONF ]]; then
# Add M-Left/M-Right after M-9 if not present
if ! grep -q "bind -n M-Left select-window" "$TMUX_CONF"; then
sed -i '/bind -n M-9 select-window -t 9/a\
bind -n M-Left select-window -t -1\
bind -n M-Right select-window -t +1' "$TMUX_CONF"
fi
# Add M-Up/M-Down after "bind N switch-client -n" if not present
if ! grep -q "bind -n M-Up switch-client" "$TMUX_CONF"; then
sed -i '/^bind N switch-client -n$/a\
bind -n M-Up switch-client -p\
bind -n M-Down switch-client -n' "$TMUX_CONF"
fi
omarchy-restart-tmux
fi