Redhat Linux - 更改目录颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8254705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 02:32:38  来源:igfitidea点击:

Redhat Linux - change directory color

linuxbashshellunixredhat

提问by saravana_pc

I am using Redhat Linux and the problem I am facing is that the "blue" colour of the directories is hardly visible on the black background. I found some posts on the web which asks to change some settings in the file /etc/profile.d/colorls.shand /etc/profile.d/colorls.csh. However, this will change the colour settings for everyone who logs into the system. Could someone please let me know how I can change the colour settings that will affect only me?

我使用的是 Redhat Linux,我面临的问题是目录的“蓝色”在黑色背景上几乎不可见。我在网上找到了一些帖子,要求更改文件/etc/profile.d/colorls.sh/etc/profile.d/colorls.csh中的一些设置。但是,这将更改登录系统的每个人的颜色设置。有人可以让我知道如何更改只会影响我的颜色设置吗?

采纳答案by William Pursell

To specify the colors of the output of ls, you need to set LS_COLORS. In your .zshrc, try adding:

要指定 ls 输出的颜色,您需要设置 LS_COLORS。在您的 .zshrc 中,尝试添加:

LS_COLORS="$LS_COLORS:di=00;33"

34 is blue, 33 is ... yellowish. Change that number and find what you like.

34 是蓝色,33 是……淡黄色。更改该数字并找到您喜欢的内容。

Use dircolorsto get a feel for what LS_COLORS should look like and add -p to see a color list.

使用dircolors来感受一下 LS_COLORS 应该是什么样子,并添加-p来查看颜色列表。

回答by Some programmer dude

You can see what is done in the global file, and then add it to your private ~/.profile (or similar file.)

您可以查看全局文件中做了什么,然后将其添加到您的私有 ~/.profile (或类似文件)中。

回答by sarnold

Joachim's answeris good for fixing the specific issue of directories, but if any other utilities output using the "blue" color, you will find them just as unreadable.

Joachim 的回答有助于解决目录的特定问题,但如果任何其他实用程序使用“蓝色”颜色输出,您会发现它们同样不可读。

Different terminal emulators have different settings for changing the colors; my terminal emulator of choice reads X resources to determine what colors to use:

不同的终端模拟器有不同的颜色设置;我选择的终端模拟器读取 X 资源以确定要使用的颜色:

      URxvt.color0:   #000000
      URxvt.color1:   #A80000
      URxvt.color2:   #00A800
      URxvt.color3:   #A8A800
      URxvt.color4:   #0000A8
      URxvt.color5:   #A800A8
      URxvt.color6:   #00A8A8
      URxvt.color7:   #A8A8A8

      URxvt.color8:   #000054
      URxvt.color9:   #FF0054
      URxvt.color10:  #00FF54
      URxvt.color11:  #FFFF54
      URxvt.color12:  #0000FF
      URxvt.color13:  #FF00FF
      URxvt.color14:  #00FFFF
      URxvt.color15:  #FFFFFF

color4is the blue in question; I have mine set like this:

color4是有问题的蓝色;我有这样的设置:

URxvt.background:       #000000
URxvt.foreground:       gray75
URxvt.color3:           DarkGoldenrod
URxvt.color4:           RoyalBlue
URxvt.color11:          LightGoldenrod
URxvt.color12:          LightSteelBlue
URxvt.color7:           gray75
URxvt.colorBD:          #ffffff
URxvt.colorUL:          LightSlateGrey
URxvt.colorIT:          SteelBlue
URxvt.cursorColor:      grey90
URxvt.highlightColor:   grey25

This gives a black background, not-too-bright foreground, and most other colors are reasonable enough. (I too found the default blue unreadable.) I put these into my ~/.Xresourcesfile, and they take effect after log in or after merging this file with the X resources database: xrdb -merge ~/.Xresources.

这给出了黑色背景,不太亮的前景,大多数其他颜色都足够合理。(我也发现默认的蓝色不可读。)我将它们放入我的~/.Xresources文件中,它们在登录或将此文件与 X 资源数据库合并后生效:xrdb -merge ~/.Xresources.

Of course, different terminals are configured differently. Check your terminal's manpage for more details on changing the colors of the usual colors.

当然,不同的终端配置不同。查看您终端的联机帮助页,了解有关更改常用颜色颜色的更多详细信息。

回答by pafinde

samolod solutionis good.

samolod 解决方案是好的。

In case of KDE konsole you go to Settings -> Edit current profile -> Appearance -> Edit -> Color 5. Then use graphical color chooser to make it brighter (I picked #5871FF).

如果是 KDE konsole,请转到设置 -> 编辑当前配置文件 -> 外观 -> 编辑 -> 颜色 5。然后使用图形颜色选择器使其更亮(我选择了 #5871FF)。