Windows上的Ubuntu上的Bash:无法更改(某些)目录颜色


9

在Windows(10)上的Ubuntu上的新Bash应用程序上,我尝试将目录颜色从蓝色更改为更明显的颜色,但由于某种原因而无法更改某些文件/目录颜色。如何更改所有目录/文件的颜色?我的.bashrc文件当前设置为在文件上具有颜色提示,目录颜色为绿色和其他亮色。设置为:

LS_COLORS=$LS_COLORS:'di=1;31:fi=0;31;bd=0;32:fi=0;33:cd=0;96';
export LS_COLORS

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[0;31m\]\u@\h\[\033[0,31m\]:\[\033[0;31m\]\w\[\033[0,31m\]\$ '

一些文件和文件夹的颜色更改了与我的.bashrc文件相对应的颜色,但其他文件和文件夹由于某些原因没有更改。

一些示例屏幕截图: 在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Answers:


9

当ls -l在wsl之外显示Windows文件时,其他可写原因导致绿色背景。正如Schmendrick van der Distel所说,在您的主目录中创建dircolors。然后,如下更改STICKY_OTHER_WRITABLE和OTHER_WRITABLE以删除背景。

dircolors -p > ~/.dircolors

将.dircolors更改为以下值:

STICKY_OTHER_WRITABLE 31;00 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 31;00 # dir that is other-writable (o+w) and not sticky

重新启动bash


3

我遇到了同样的问题,并通过以下方式解决了该问题:

在我的~/.bashrc文件中,找到了以下几行:

test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'

当我.dircolors在主目录中找不到命名的文件时,我通过dircolors -p > ~/.dircolors

现在,我将行更改DIR 01;36 # directoryDIR 01;34 # directory(将颜色从蓝色更改为青色),保存了文件并重新启动了BashonWindows。

希望对你有帮助


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.