小编0xP*_*ter的帖子

在 Fish shell 中使用 ~/.dircolors

我最近刚刚从 bash 切换到 Fish shell,但在获取 dircolors 模板文件以获得为某些文件扩展名显示的自定义颜色时遇到了麻烦。

在 bash 中,我从~/.dircolors/dircolors.256dark. dircolors.256dark模板将不同的文件类型映射到不同的颜色。例如,当我使用 时ls,所有.wav文件都会显示为橙色。这是我的来源~/.bash_profile

# uses dircolors template
eval $(gdircolors ~/.dircolors/dircolors.256dark)

# Aliases
alias ls='gls --color=auto'
Run Code Online (Sandbox Code Playgroud)

然而,fish 并不真正使用 rc 文件,而是从config.fish, 文件获取源,但某些操作的语法在fish中是不同的。

我正在尝试弄清楚如何在鱼中实现这一目标。我喜欢能够通过颜色在视觉上区分不同的文件类型,因此如果在鱼中无法做到这一点,这对我来说可能会成为一个问题。

聚苯乙烯

为了清楚起见,我并不是试图简单地更改目录或可执行文件的颜色,而是更改具有不同文件扩展名的文件的颜色。例如,如果我ls在目录中执行此操作,我会得到以下结果:

my_file.py  # this file would be green for example
my_file.js  # this file would be yellow
my_file.wav # this file would be orange
Run Code Online (Sandbox Code Playgroud)

编辑:我在 macOS 上使用 homebrew 来获取 dircolors。

shell bash fish rc

4
推荐指数
1
解决办法
5155
查看次数

标签 统计

bash ×1

fish ×1

rc ×1

shell ×1