-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
TL;DR) tmux passthrough using \033Ptmux; ... \033\ control sequence doesn't work for a very long sequence.
Environment
- Darwin i386 (macOS)
- tmux 2.7 (also confirmed in the latest HEAD as of 10/14)
- screen-256color (also confirmed in xterm-256color etc.)
Description
iTerm2 supports a file download (or image display) protocol. It works perfectly outside tmux, but not working inside tmux well (provided wrapped by tmux passthrough control sequence).
It works outside tmux:
Inside tmux, only small data sequence works. However, large files are not submitted; seems data transmission is interrupted and packets are not all sent.
For a file of 262144 bytes, the data seems to be truncated in the middle.
Please note that this feature is widely used for imgcat, etc. As a result, we cannot display a large image file inside tmux.
How to reproduce?
To reproduce, consider a test script test-iterm.sh
, which sends a dummy file of specified number of bytes through iTerm2's file download protocol. Note that when running under tmux, the pass-through control sequence \033Ptmux; ... \033\ is applied on OSC and ST.
#!/bin/bash
function print_osc() {
if [[ -n $TMUX ]] ; then
printf "\033Ptmux;\033\033]";
else printf "\033]"; fi
}
function print_st() {
if [[ -n $TMUX ]] ; then
printf "\a\033\\"
else printf "\a"; fi
}
function send_file() {
# sends a dummy file containing $REPEAT '.' characters
REPEAT=${1:-1024}
filename=$(echo -ne "test-$REPEAT.txt" | base64)
echo "Sending a text data of $REPEAT bytes ..."
print_osc
printf "1337;File=name=$filename;size=$REPEAT;inline=0:"
head -c $REPEAT < /dev/zero | tr '\0' '.' | base64
print_st
}
send_file $1
Suspects?
I have no very good idea why it is happening. Any thoughts?
- Seems related to TMUX eats SIXEL DCS header #1388 -- input timer may just flushes data out. Not sure.
- Buffer size limit ('tmux;' passthrough: large sequences #487), which is currently 1M. However, the data being transmitted is less than 1MB (see
test-262144.txt
example), so I doubt of it. - Sequence passthrough #846 -- not relevant.
What else did I try?
I tried to split the sequence into multiple chunks (e.g. use ...
\033\ + \033Ptmux; ...
), but no success.