如何在OSX的终端中关闭ls输出的颜色 [英] How do I turn OFF colors for ls output in Terminal on OSX

查看:120
本文介绍了如何在OSX的终端中关闭ls输出的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ls输出为所有目录着色的颜色与文件不同,无论我键入ls还是/bin/ls.我没有在.bashrc或相关文件中设置任何LS_COLOR内容.

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.

如何关闭这些颜色? (我对ls -F感到非常满意)

How do I turn off these colors? (I am quite happy with just ls -F)

谢谢!

推荐答案

如注释中所述,OSX ls注意 CLICOLOR . ls手册页面是您寻找的地方.它似乎与使用终端数据库的 FreeBSD 中的程序相同. (与GNU ls相反).同样,请注意,变量为 LSCOLORS ,而不是 LS_COLORS :

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

CLICOLOR

使用ANSI颜色序列区分文件类型.请参阅下面的 LSCOLORS .此外 -F选项中提到的文件类型还有一些额外的属性(setuid位设置, 等).着色取决于端子类型,并且 适当的termcap(5)功能.默认的"cons25"控制台具有适当的功能, 但要在xterm(1)中显示颜色,例如,TERM变量必须为 设置为"xterm-color".其他终端类型可能需要类似的调整.显色 如果没有将输出定向到终端,除非定义了 CLICOLOR_FORCE 变量,该选项将被静默禁用.

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 the CLICOLOR_FORCE variable is defined.

CLICOLOR_FORCE

CLICOLOR_FORCE

如果没有将输出定向到终端,则通常禁用颜色序列.这 可以通过设置此标志来覆盖. TERM 变量仍需要引用一个 具有颜色的终端,但是否则无法确定哪种颜色 要使用的序列.

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

TERM

CLICOLOR 功能取决于具有颜色功能的终端类型.

The CLICOLOR functionality depends on a terminal type with color capabilities.

有关"termcap(5)"的措词已过时; FreeBSD和OSX都使用terminfo数据库已有十多年了.

The wording about "termcap(5)" is outdated; both FreeBSD and OSX have used terminfo databases for more than ten years.

GNU ls手册页面确实显示 LS_COLORS (两者不相同). dircolors手册页对预编译数据库"(与terminfo/termcap无关,使用TERM获得相似结果是造成混乱的原因).

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).

这篇关于如何在OSX的终端中关闭ls输出的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆