From e9d275298d8219115bc241c563a7bafd04240568 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 25 May 2026 10:30:16 +0200 Subject: [PATCH] Give kitty alt+shift+enter power for tmux vertical splits --- config/kitty/kitty.conf | 2 ++ config/tmux/tmux.conf | 1 + migrations/1779696759.sh | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 migrations/1779696759.sh diff --git a/config/kitty/kitty.conf b/config/kitty/kitty.conf index 7d550d78..af2da6dc 100644 --- a/config/kitty/kitty.conf +++ b/config/kitty/kitty.conf @@ -13,6 +13,8 @@ confirm_os_window_close 0 # Keybindings map ctrl+insert copy_to_clipboard map shift+insert paste_from_clipboard +# Kitty legacy encoding sends Alt+Shift+Enter the same as Alt+Enter; send CSI-u so tmux can match M-S-Enter. +map alt+shift+enter send_text all \e[13;4u # Allow remote access allow_remote_control yes diff --git a/config/tmux/tmux.conf b/config/tmux/tmux.conf index 53990431..f24361d7 100644 --- a/config/tmux/tmux.conf +++ b/config/tmux/tmux.conf @@ -77,6 +77,7 @@ setw -g aggressive-resize on set -g detach-on-destroy off set -g extended-keys on set -g extended-keys-format csi-u +set -g terminal-features[3] "xterm-kitty:extkeys" set -sg escape-time 10 # Status bar diff --git a/migrations/1779696759.sh b/migrations/1779696759.sh new file mode 100644 index 00000000..f7303e60 --- /dev/null +++ b/migrations/1779696759.sh @@ -0,0 +1,22 @@ +echo "Make Alt+Shift+Enter distinguishable for Kitty and tmux" + +kitty_config="$HOME/.config/kitty/kitty.conf" +tmux_config="$HOME/.config/tmux/tmux.conf" + +if [[ -f $kitty_config ]] && ! grep -Eq '^map[[:space:]]+alt\+shift\+enter[[:space:]]' "$kitty_config"; then + if grep -qxF 'map shift+insert paste_from_clipboard' "$kitty_config"; then + sed -i '/^map shift+insert paste_from_clipboard$/a # Kitty legacy encoding sends Alt+Shift+Enter the same as Alt+Enter; send CSI-u so tmux can match M-S-Enter.\nmap alt+shift+enter send_text all \\e[13;4u' "$kitty_config" + else + printf '\n# Kitty legacy encoding sends Alt+Shift+Enter the same as Alt+Enter; send CSI-u so tmux can match M-S-Enter.\nmap alt+shift+enter send_text all \\e[13;4u\n' >>"$kitty_config" + fi +fi + +if [[ -f $tmux_config ]] && grep -qxF "set -as terminal-features ',xterm-kitty:extkeys'" "$tmux_config"; then + sed -i 's/^set -as terminal-features '"'"',xterm-kitty:extkeys'"'"'$/set -g terminal-features[3] "xterm-kitty:extkeys"/' "$tmux_config" +elif [[ -f $tmux_config ]] && ! grep -q 'xterm-kitty:extkeys' "$tmux_config" && ! grep -Eq '^(set|set-option)[[:space:]].*terminal-features' "$tmux_config"; then + if grep -qxF 'set -g extended-keys-format csi-u' "$tmux_config"; then + sed -i '/^set -g extended-keys-format csi-u$/a set -g terminal-features[3] "xterm-kitty:extkeys"' "$tmux_config" + else + printf '\nset -g terminal-features[3] "xterm-kitty:extkeys"\n' >>"$tmux_config" + fi +fi