X
X
xotkot2021-12-26 23:15:55
linux
xotkot, 2021-12-26 23:15:55

How to keep the color when cutting?

simple example:

printf "111;\e[32m222\e[0m;333\n111;\e[32m1234567890abcdefj\e[0m;333\n" | column --table --separator ';' --table-columns 'A,B,C'

conclusion:
A    B                  C
111  222                333
111  1234567890abcdefj  333

where the second column ( B ) will be green

now the same, but only limit (--table-truncate) the size of the rows in column B to the specified number of characters (--output-width):
printf "111;\e[32m222\e[0m;333\n111;\e[32m1234567890abcdefj\e[0m;333\n" | column --table --separator ';' --table-columns 'A,B,C' --table-truncate 'B' --output-width 20

conclusion:
A    B           C
111  222         333
111  �[32m12345  333


where the string (1234567890abcdefj) in column B , which has an excess of characters, is displayed without the required (\e[32m, \033[32m, \u001b[32m) color and also with a garbage (�[32m) part from the color coding.

whether there is a possibility of a correct output through column with preservation of color at cropping of a line?

ps
$ column -V
column из util-linux 2.37.2


p.c2
it is clear that one of the options is to set the color after the column, but it will be terribly inconvenient in the context of solving some problem, so I would still like to set the color before hitting the column.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question