The whole output of ls will be printed in the last active color. If ls
is called without color:
$ printf '\e[0;31m color test\n'; /bin/ls color test filea fileb filec filed filee filef fileg fileh
will print the list of files in red.
Or, if there is no color change needed for ls, the last color will remain:
$ mkdir t1; cd t1; touch file{a..h} $ printf '\e[0;31m color test\n'; /bin/ls --color -l color test total 0 -rw-r--r-- 1 user user 0 Feb 23 01:16 filea -rw-r--r-- 1 user user 0 Feb 23 01:16 fileb -rw-r--r-- 1 user user 0 Feb 23 01:16 filec -rw-r--r-- 1 user user 0 Feb 23 01:16 filed -rw-r--r-- 1 user user 0 Feb 23 01:16 filee -rw-r--r-- 1 user user 0 Feb 23 01:16 filef -rw-r--r-- 1 user user 0 Feb 23 01:16 fileg -rw-r--r-- 1 user user 0 Feb 23 01:16 fileh
Still, all in red.
But, as soon as ls
needs to set a color (and then reset colors to the default used by the console), the color used from then on will be the console default.
$ printf '\e[0;31m color test\n'; /bin/ls --color -la color test total 8 drwxr-xr-x 2 user user 4096 Feb 23 01:16 . drwxr-x--- 7 user user 4096 Feb 23 01:15 .. -rw-r--r-- 1 user user 0 Feb 23 01:16 filea -rw-r--r-- 1 user user 0 Feb 23 01:16 fileb -rw-r--r-- 1 user user 0 Feb 23 01:16 filec -rw-r--r-- 1 user user 0 Feb 23 01:16 filed -rw-r--r-- 1 user user 0 Feb 23 01:16 filee -rw-r--r-- 1 user user 0 Feb 23 01:16 filef -rw-r--r-- 1 user user 0 Feb 23 01:16 fileg -rw-r--r-- 1 user user 0 Feb 23 01:16 fileh
With the first three lines (up to the blue dot) printed in red.
ls
command itself.LS_COLORS='rs=0;1' ls -l
, but it looks very different.ls
can change the color of its output.ls
can provide color. ;-)