systemctl
does not appear to have a mechanism for specifying when to color the output. A quick solution would be to shim isatty(3)
to always return true, thus tricking systemctl
into thinking stdout is interactive. Namely you could do:
# echo "int isatty(int fd) { return 1; }" | gcc -O2 -fpic -shared -ldl -o isatty.so -xc - # LD_PRELOAD=./isatty.so watch -n300 --color systemctl status plexmediaserver
The -xc -
at the end of the gcc
command tells gcc
to compile C code (-xc
) from stdin (-
). The rest of the flags tell gcc
to create a shared object file named isatty.so
. Note that this could very well break other programs which rely on isatty
to return a legitimate value. It however appears to be fine for systemctl
as isatty
appears to be solely used for the purpose of determining if it should color its output.