Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
2  
I don't think you can avoid it, you might re-enter the tabs by piping the paste through unexpand. –  Thor Sep 8 '12 at 20:01

1 Answer 1

up vote 1 down vote accepted

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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