简体   繁体   English

在 macOS 上使用 fish 更改 LSCOLORS

[英]Change LSCOLORS using fish on macOS

I'm trying to set the colour of dirs in Terminal on the latest version of macOS (12.5) with an M1 using fish.我正在尝试在最新版本的 macOS(12.5)的终端中设置 dirs 的颜色,其中 M1 使用 fish。

I've tried both the suggested commands: set LSCOLORS XXXX and set -Ux LSCOLORS XXXX with XXXX being the desired colour eg G or "dir=1:37".我已经尝试了两个建议的命令: set LSCOLORS XXXXset -Ux LSCOLORS XXXX ,其中 XXXX 是所需的颜色,例如 G 或“dir=1:37”。

Both options do change the values in fish_variables (found in the.config/fish dir) but the colours stay the same.这两个选项都会更改 fish_variables 中的值(在 .config/fish 目录中),但颜色保持不变。

I've looked through the preferences pane for Terminal itself as well as the fish_config but I can't see anything overriding what I'm trying to alter.我已经查看了终端本身的首选项窗格以及 fish_config,但我看不到任何覆盖我要更改的内容的内容。

What am I missing?我错过了什么? Thank you in advance for any help you can offer.提前感谢您提供的任何帮助。

Don't use set -U when exporting env vars.导出环境变量时不要使用set -U It's likely to cause problems.这很可能会导致问题。 Just do set -x to export an env var.只需执行set -x即可导出环境变量。 You should be able to confirm it is exported by running env | grep LS_COLORS您应该能够通过运行env | grep LS_COLORS来确认它是否已导出。 env | grep LS_COLORS . env | grep LS_COLORS For example, on my system:例如,在我的系统上:

> env | grep LS_COLORS
LS_COLORS=di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34:su=0:sg=0:tw=0:ow=0:

If the var is exported and not producing the expected result then the problem has nothing to do with Fish.如果 var 被导出并且没有产生预期的结果,那么问题与 Fish 无关。 In particular, note that the macOS ls command (the /bin/ls one) does not recognize the LS_COLORS env var.特别要注意 macOS ls命令( /bin/ls之一)无法识别LS_COLORS That is a GNU Linux extension.那是一个 GNU Linux 扩展。 I recommend installing the Homebrew package manager and then brew install coreutils which will provide gls command.我建议安装 Homebrew package 管理器,然后brew install coreutils它将提供gls命令。 You can then create a Fish function that invokes gls when you type ls .然后,您可以创建一个 Fish gls ,在您键入ls时调用 gls。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM