3 ms·
Question: can it preserve original colors and also highlight the given word? Like when you do an "apt search whatever | grep another", and it is formatted in a
by hwbunny 3y ago
Question: can it preserve original colors and also highlight the given word? Like when you do an "apt search whatever | grep another", and it is formatted in a nice way, but grep just eats the colors...
- gloria_mundi 3y agogrep doesn't eat the colours, apt detects that it is not outputting to a TTY and suppresses the colours. Try `printf 'a \e[36mb\e[0m c\n' | grep a`, the colour is preserved just fine. Some tools have an option to force coloured output regardless, e.g. GCC's `-fdiagnostics-color` or grep's own `--colour=always`, but apt doesn't seem to have anything like that. In theory one could have a command in the style of nohup or stdbuf which sets up a PTY to trick the command into outputting colours. So one could run `fakepty apt search whatever | grep another` ...