X11 escaped color codes appearing in tmux shells

237 views Asked by At

In Fedora 39, with i3 + urxvt + tmux, each time I tmux new-session or tmux attach-session, something prints the following characters to the terminal shell, presumably with broken or misinterpreted escape sequence:

user@hostname:~ $ /fe00/fd00^[^[]11;rgb:0100/0200/0300^[^[user@hostname:~ $

The pattern repeats each time I reattach to this session with tmux attach-session (without inputting anything on the terminal):

user@hostname:~ $ /fe00/fd00^[^[]11;rgb:0100/0200/0300^[^[]10;rgb:ff00/fe00/fd00^[^[]11;rgb:0100/0200/0300^[^[]10;rgb:ff00/fe00/fd00^[^[]11;rgb:0100/0200/0300^[^[]10;rgb:ff00/fe00/fd00^[^[]11;rgb:0100/0200/0300^[^C

I first encountered this bug after upgrading to Fedora 39. This seems to be a bug somewhere between tmux and urxvt, which I run in i3. My primary goal is figuring out what workaround I need to use and where I should be filing a bug for this behavior. I can't seem to eliminate the root cause, other than to switch from urxvt to another terminal emulator entirely (which suggests to me that it's a bug in Fedora's rxvt-unicode package, but I would think I'd be able to demonstrate that by changing some rxvt / X11 configuration).

My ~/.Xresources includes (this is where the 4 digit color codes are coming from):

[...]
*foreground: #fffefd
*background: #010203
[...]

I have tried deleting every other aspect of my ~/.tmux.conf, ~/.Xresources, ~/.bashrc (including PS1 and COMMAND_PROMPT), and ~/.bash_profile to no avail.

Removing my ~/.Xresources does not resolve the issue. root, via su - su root from a urxvt session as my normal user, experiences the same issue without any user-specific (i.e. root-specific) shell, tmux, or X11 configuration in /root/.

I've also tried adding set -x to /etc/profile to determine where at a system-level this is occurring. It seems to be occurring while /etc/profile is executing, but not as a result of anything in /etc/profile (it's asynchronous). For example, if I add a set -e; sleep 1 at the very beginning of /etc/profile, it appears in the trace during the sleep:

+ sleep 1
^[]10;rgb:ff00/fe00/fd00^[^[]11;rgb:0100/0200/0300^[+ '[' -x /usr/bin/id ']'
+ '[' -z 1000 ']'
++ /usr/bin/id -un
+ USER=user
1

There are 1 answers

0
tijko On

I've been using TMux in coordination with a couple of terminal-emulators depending on my environment that I'm using at the time.

That said, I've come across some configuration issues very similar to the one mentioned. Having a session start under VSCode and its integrated terminal there is this dump:

[tijko@tijko ~] 10;rgb:cccc/cccc/cccc11;rgb:1818/1818/1818

To show exactly what it looks like I've attached this image:

enter image description here

Now going into my .tmux.conf I found escape-time

Set the time in milliseconds for which tmux waits after an escape is input to determine if it is part of a function or meta key sequences. The default is 500 milliseconds.

My default was set to 10 milliseconds and by increasing this I no longer have the "escape sequence" dump.

.tmux.conf:

  23   │ setw -g xterm-keys on
  24   │ set -s escape-time 200                     # faster command sequences
  25   │ set -sg repeat-time 600                   # increase repeat timeout
  26   │ set -s focus-events on

You can see I've set my new escape-time to 200 milliseconds and it fixed the issue.