From 42260925a0b301f8d57515166d6eaa946ae65320 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sun, 7 Apr 2024 22:59:13 +0100 Subject: [PATCH] Fix tmux-dcs-passthrough & notify utilities These two have been sitting in a broken state for quite a while but I findally RTFM and realised that the escape characters in the escape sequence need to be doubled up in order for tmux to properly pass through the escape sequence. --- utilities/utilities.plugin.zsh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/utilities/utilities.plugin.zsh b/utilities/utilities.plugin.zsh index 3a13aaf..357b65d 100644 --- a/utilities/utilities.plugin.zsh +++ b/utilities/utilities.plugin.zsh @@ -26,16 +26,21 @@ fi # Passthrough an escape sequences tmux doesn't know about. tmux-dcs-passthrough() { + local escape_sequence=$1 if [ -n "$TMUX" ]; then - printf "\x1bPtmux;\x1b$1\x1b\\" + # Replace single \x1b or \033 with two, this is required for tmux to + # properly pass-through the escape sequence. + escape_sequence=${escape_sequence//\\x1b/\\x1b\\x1b} + escape_sequence=${escape_sequence//\\033/\\x1b\\x1b} + printf '\x1bPtmux;\x1b'"$escape_sequence"'\x1b\\' else - printf "$1" + printf "$escape_sequence" fi } -# OSC 9 - Post a notification - supported by iTerm2, maybe others? +# OSC 9 - Post a notification - supported by iTerm2, kitty, maybe others? notify() { - tmux-dcs-passthrough "\x1b]9;$*\x7" + tmux-dcs-passthrough '\x1b]9;'"$*"'\x7' } # Detect the type and extract an archive file.