Does anyone know how to install GNU Parallel from source so that the output of certain commands are displayed with colors? I found that the version 20170622 doesn't display colors when running, for example, nightmare with DEBUG=nightmare.
DEBUG=nightmare parallel node my-script.js
and outputs:
However, the version installed via apt install in Ubuntu (20141022+ds1-1) maintains the colors:
Let us assume your program is:
echo myfoobar | grep --color foo
This gives colors if grep
detects the output is a tty.
You can ask GNU Parallel to open the tty by using --tty
. --tty
defaults to -j1
so you need to set that, too:
parallel -j100% --tty 'echo myfoobar | grep --color' ::: foo
The problem is, that buffering is also disabled, so it activates --ungroup
, and that is why this is not default. As you can see here the outputs of the jobs mix:
fu() { echo myfoobar | grep --color "$@"; }
env_parallel -j100% --tty 'echo {}; fu {};sleep 0.1; echo {}; fu {}' ::: foo fo f b ba bar