Skip to content

tmux passthrough of large data sequence #1502

@wookayin

Description

@wookayin

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:

no 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.

with tmux

For a file of 262144 bytes, the data seems to be truncated in the middle.

image

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?

What else did I try?

I tried to split the sequence into multiple chunks (e.g. use ... \033\ + \033Ptmux; ...), but no success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions