edit: I was in EternalTerminal session, and that was the source of the difference. In a regular ssh
, it works.
I need to get commands in a pipe to believe they are in a PTY and emit colorized output.
script -c
is known to be a workaround to do so.
But for me, ls --color=auto
is colorized, and in script -q -e -c 'ls --color=auto' log; cat log
nothing is colorized.
I do have LS_COLORS
set.
The same happens with gcc
: it's colorized in an interactive shell, but not in script -c
.
How do programs in script -c
find out that they are not in a tty? Why did it work before and doesn't now?
$ script -V
script from util-linux 2.33.2
$ ls --version
ls (GNU coreutils) 8.31
ls
doesn't apply colours by default, IIRC. Is yourls
an alias tols --color
? – muru Jun 10 '20 at 06:54ls --color=auto
. Updating the question. BTW, I'm also inssh
. – Victor Sergienko Jun 10 '20 at 07:01script -q -e -c 'ls --color' /tmp/log
shows colours (SSH to a Arch Linux system from a macOS iTerm): https://i.stack.imgur.com/iFyJX.jpg – muru Jun 10 '20 at 07:11script -q -e -c 'ls --color' /tmp/log
gives colours on Cygwin, Raspbian 10, Debian 10, and CentOS 7 – Chris Davies Jun 10 '20 at 08:45