URxvt Terminal – Is It Possible to Select Tabs as Tabs with Mouse?

clipboardmouserxvtterminal

I am running urxvt on Arch Linux. I can select the output with mouse for copy / paste. The problem occurs when output contains tabulators. All tabulators are selected and copied as spaces. That makes it really difficult to preserve the structure of some outputs when copying them.

Is there any way to fix this behaviour?

EDIT: I am using zsh if that has any effect on the issue.

Best Answer

I don't know of any terminal that does, and I'll just say why I don't think any terminal does:

tab is one of the many characters that once displayed outputs more than one character on screen or moves the cursor. CR (move to beginning of line), LF (down), backspace (left) and all the escape sequences that move the cursor or change character attributes and/or don't display anything...

urxvt doesn't even get exactly what the application outputs. When an application sends a LF (\n) to the slave side of the pseudo-terminal, you'll notice that, most of the time, it does not just move the cursor down, as LF normally does, it also moves it back to the start of the line. That's because the pty driver translates the "\n" to "\r\n" before making it available for reading from the master side of the terminal by urxvt (you may use stty to change that behavior).

Also note that the selection will not capture trailing spaces.

The X selection selects the characters that are displayed, not the ones that have been sent by the application(s) to generate that display (consider that any character at any given position on the screen may have been overridden several times by one or more application(s)).

Some terminals though allow to capture all the characters that they receive on the master side of the pseudo-terminal, and if they don't, you can use "script" or "screen" to do it instead. But to get the output of an application into the X selection, you can also simply do:

the-command | xsel
Related Question