Colors in the Terminal

Often, the .bashrc/.bash_login or .zsh does an alias so that "ls" actually means "ls --color=auto"

 

Using "auto" means "ls" adds color when being used by a user in a terminal, but when being used in a cron job or dumping output to a file (like: "ls > dir.txt") then there is no color, since the color codes would get in the way or be recorded in a file.

 

Auto also means that no color is used in piping, for example: ls -la | less

So, to do that, do this: ls -la --color=y | less

 

(since "less" can handle color just fine)

Powered by Linux