Using column or pr -T3 to columnize an input with ANSI escapes results in bad align of the items – they are under or overaligned. For example: ls -1 --color=always|column.
I'm writing a file manager and would want 2 columns format, like in Midnight Commander. The good part is that the project is written in Zsh script and I would want a nice way of columnizing color fd ./exa -1 --color=always/ls -1 --color=always output, including a Bash/Zsh/Awk/etc. script as a solution. Is there a way?
It looks like the
zshbuiltinprintcan handle colors when creating columns with the-Cand-coptions. The source code even has this note:Converting the command output to arguments for
printcan be slightly tricky, but this combination of a command substitution with$(...)and an expansion split by line using${(f)...}should work:You also can pass in data via a coprocess.