问题
my ls
output colors all directories differently from files, regardless whether I type ls
or /bin/ls
. I don't have any LS_COLOR
stuff set in .bashrc
or related files that I can find.
How do I turn off these colors? (I am quite happy with just ls -F
)
Thanks!
回答1:
As noted in comment, OSX ls
pays attention to CLICOLOR
. The ls manual page is the place to look. It appears to be the same program as in FreeBSD, which uses the terminal database (in contrast to GNU ls). Likewise, note that the variable is LSCOLORS
, rather than LS_COLORS
:
CLICOLOR
Use ANSI color sequences to distinguish file types. See
LSCOLORS
below. In addition to the file types mentioned in the -F option some extra attributes (setuid bit set, etc.) are also displayed. The colorization is dependent on a terminal type with the proper termcap(5) capabilities. The default “cons25” console has the proper capabilities, but to display the colors in an xterm(1), for example, the TERM variable must be set to “xterm-color”. Other terminal types may require similar adjustments. Colorization is silently disabled if the output isn't directed to a terminal unless theCLICOLOR_FORCE
variable is defined.
CLICOLOR_FORCE
Color sequences are normally disabled if the output isn't directed to a terminal. This can be overridden by setting this flag. The
TERM
variable still needs to reference a color capable terminal however otherwise it is not possible to determine which color sequences to use.
TERM
The
CLICOLOR
functionality depends on a terminal type with color capabilities.
The wording about "termcap(5)" is outdated; both FreeBSD and OSX have used terminfo databases for more than ten years.
The GNU ls manual page does say LS_COLORS
(the two are not the same). The dircolors manual page makes an oblique reference to a "precompiled database" (this is unrelated to terminfo/termcap, and its use of TERM
to get similar results is a source of confusion).
来源:https://stackoverflow.com/questions/33160450/how-do-i-turn-off-colors-for-ls-output-in-terminal-on-osx