Skip to content

解决WSL运行ls后文件夹名显示背景色问题

背景

  • 环境: Windows Subsystem Linux

  • 终端: Windows Terminal

  • 系统: Ubuntu

操作

bash

在终端运行如下指令:

bash
$ cd ~
$ dircolors -p > .dircolors
$ vim .dircolors

找到OTHER_WRITABLE,将34;42修改为34;49,保存后即生效

zsh

~/.bashrc文件中找到以下配置:

bash
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

将以上内容追加到到~/.zshrc末尾中,执行以下命令生效:

bash
source ~/.zshrc

Lljxww's Fantasy, Powered by VitePress