atanunq / viuer

Rust library for displaying images in the terminal.
MIT License
241 stars 43 forks source link

iTerm2 falls back to half-block printing inside tmux #29

Closed luukvbaal closed 3 years ago

luukvbaal commented 3 years ago

Despite the fact that iTerm's image escape sequences and indeed its imgcat script seems to work inside tmux, viu will fall back to half-block rendering.

TERM_PROGRAM is equal to tmux inside tmux but exporting TERM_PROGRAM=iTerm.app manually doesn't seem to help either; this results in nothing being printed at all.

Is this something that was/can be considered inside viuer?

Edit: quoting the imgcat script:

# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
# <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It
# only accepts ESC backslash for ST. We use TERM instead of TMUX because TERM
# gets passed through ssh.
function print_osc() {
    if [[ $TERM == screen* ]]; then
        printf "\033Ptmux;\033\033]"
    else
        printf "\033]"
    fi
}
luukvbaal commented 3 years ago

Upon further inspection it seems iTerm's image protocol support inside tmux is spotty and doesn't always work. Is this why it wasn't included in viu? Anyhow, closing.

atanunq commented 3 years ago

Thanks for raising the issue & sorry for the delay! I never really wanted to get into the whole tmux + custom protocols mess. I'm afraid it gets too ugly too quickly for me to handle.

luukvbaal commented 3 years ago

Completely understand. Just from my initial testing with imgcat it seemed to work hence why I opened the issue. After integrating the required change into iterm.rs and previewing more images I noticed issues and came across the relevant threads describing said issues. I agree its probably not possible/worth it to handle this edge case indeed.