term-img
term-img copied to clipboard
Support tmux
It requires some wrapper escape codes to please it.
https://raw.githubusercontent.com/gnachman/iTerm2/master/tests/imgcat
Specifically:
# 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.
function print_osc() {
if [[ $TERM == screen* ]] ; then
printf "\033Ptmux;\033\033]"
else
printf "\033]"
fi
}
# More of the tmux workaround described above.
function print_st() {
if [[ $TERM == screen* ]] ; then
printf "\a\033\\"
else
printf "\a"
fi
}
I will get to this eventually, but I don't use tmux, so not a priority. A pull request would be welcomed :)
Yay. I was just about to write this issue for terminal-image-cli but I'm glad I dug a little deeper first and found this.
Here's a related fix from a different project: https://github.com/dylanaraps/neofetch/commit/a575c01b5cba723418cf8733a640751e98bca5a9
I practically use tmux as a tiling WM so I'm happy to PR this in the near future.
I practically use tmux as a tiling WM so I'm happy to PR this in the near future.
A PR would be lovely 👌
I've attempted to implement a couple of different versions of the tmux image fix but all have failed. The imgcat test script that was supplied by the iTerm team isn't functional either. After failed attempts and digging further, I found this: https://gitlab.com/gnachman/iterm2/issues/3898. It appears that at least for the time being, this may not be a possibility, is out of the scope of this repo, and much more to do with tmux's relationship with iTerm.
The strange thing is that if I spin up a new login shell from within my tmux session, I can get the pixelated version of the image to display.

Will this same support ("special escape code sequences") also make this work in rxvt
/rxvt-unicode
?
Ranger supports image display in rxvt
, both natively and via w3m
/w3mimagedisplay
:
https://github.com/ranger/ranger/wiki/Image-Previews#with-urxvt
https://github.com/ranger/ranger/wiki/Image-Previews#with-w3mimgdisplay
Native rxvt
methods mess with any set terminal background (sets to a solid black color on display, and resets to the solid color Urxvt*background: ...
, losing any pixmap background), where as w3m
method retains the background.