macOS:ls 命令停止工作

Sha*_*h-G 9 osx terminal

在我的 macOS (10.11.6) 终端上,我在 python virtual env 上做了一些安装。之后我的ls命令停止工作。它给出了一个错误:

$ ls
ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]

$ alias ls
alias ls='colourify ls --color'
Run Code Online (Sandbox Code Playgroud)

Jde*_*eBP 6

哪个程序首先真正搞砸了我的lscmd,它是python吗?

您的ls命令未受影响。您的ls 别名很可能来自错误的 Bourne Again shell 设置。

请注意,您的ls别名正在运行一个名为 的命令grc,通过另一个名为colourify. 这来自Radovan Garabík 的 Generic Colourizer,其 Bourne Again shell 别名 (in grc.bashrc) 和 Z shell 别名 (in grc.zsh) 设置了一个名为ls.

在某个地方,在一个 rc 文件中,您将这些别名添加到交互式 Bourne Again shell 中,根据Stack Overflow answer 之类的建议。

Z shell 别名是

别名 ls="grc --colour=auto ls"
它将--colour-auto选项传递给grc命令,该命令是采用该选项的命令。

但是,The Bourne Again shell 别名是

别名 ls='colourify ls --color'
这是(通过colourify别名)有效

别名 ls='grc -es --colour=auto ls --color'
这是两个运行的输出ls通过colourizer命令,并试图让ls命令colourize其输出。

基本问题是,这些 Bourne Shell 别名的作者(2016 年 5 月来自 Oracle 的 Isaias Piña)并未满足在 Linux 操作系统以外的任何其他系统上运行 Bourne Again shell,如果您使用的是 MacOS,可能会期望你正在使用类似 Oh My Zsh 的东西。另一个问题是作者不允许对grc输出进行着色ls,而是希望ls对自己的输出进行着色。

所以你有很多选择:

  • Find where you are adding these aliases and fix Isaias Piña's erroneous ls alias to use the -G option on MacOS.
  • Find where you are adding these aliases and fix Isaias Piña's erroneous ls alias to not use any option and instead rely upon the colourizer's conf.ls file to do its actual job; as Tom Mulder has.
  • Find where you are adding these aliases and remove Isaias Piña's erroneous ls alias entirely, using the CLICOLOR environment variable for colourization instead; as Noel B Alonso does.
  • Find where you are adding these aliases and remove Isaias Piña's erroneous ls alias entirely, using your own ls alias; as Arthur Nisnevich does.
  • 完全卸载通用着色器。
  • 使用 Z 壳。


Sha*_*h-G 0

Homebrew更新到新版本的grc 1.10_1,这个问题已经解决。