0

I am unable to use printf command when I am inside tmux.

The command for changing background on the fly is:

printf "\e]20;/home/alexsson/Downloads/alternativ.png;\a"

I can do this directly in urxvt:

enter image description here

Also inside screen:

enter image description here

But this printf command is simply not working in tmux:

enter image description here

Any idea how to make it work in tmux?

PS: There is a similar question here: tmux and control sequence character issue. However, it is difficult to find that question if not using correct searching terms. I think my post will be interesting for a lot more users out there not knowing which searching terms to use but more common (like simply changing background). There is also not much written in the documentation about this.

1

urxvt, tmux and screen are three different terminal emulators, the first one uses X11 as the backend for display/input, while the two others use a host terminal.

tmux and screen are really terminal emulators, they implement a number of features (like bold character attributes, clearing screen...) activated via some escape sequences, but setting the background picture is not among the features they support.

Also remember that a screen/tmux session can be attached to any type of host terminal, even to several at once (with -x), some may support that feature, some may not.

screen will pass along the escape sequences it doesn't recognise, tmux doesn't. Sequences that start with OSC (\e]) end in BEL (\a/^G). When tmux sees a \e], it reads until \a (or the next escape sequence) and if it doesn't recognise that sequence, it just discards it.

However, tmux supports passing arbitrary text through verbatim to the host terminal(s) with the \ePtmux;\e<text>\e\ sequence. So here, you could do:

printf '\ePtmux;\e\e]20;/home/alexsson/Downloads/alternativ.png;\a\e\\'

In any case, note that that's quite a dangerous feature of rxvt. For instance, if you run rxvt as root on Linux and run cat malicious-file with that file containing something like \e]20;/dev/watchdog\a (on systems where a watchdog is available), that will reboot your system after a few seconds.

| improve this answer | |
  • Thanks for a very good explanation. – user1261558 Nov 24 '19 at 23:03
  • Do you know how to set the background in a specific pane? Right now, the background is set across all panes. – user1261558 Nov 25 '19 at 0:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.