On my macOS (10.11.6) terminal, I did some installations on python virtual env. After that my ls
command stopped working.
It is giving an error:
$ ls
ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
$ alias ls
alias ls='colourify ls --color'
Best Answer
Your
ls
command is untouched. Yourls
alias most likely comes from an erroneous Bourne Again shell setup.Note that your
ls
alias is running a command namedgrc
, via another alias namedcolourify
. This comes from Radovan Garabík's Generic Colourizer, whose Bourne Again shell aliases (ingrc.bashrc
) and Z shell aliases (ingrc.zsh
) set up an alias namedls
.Somewhere, in an rc file, you are adding these aliases to your interactive Bourne Again shell, per recommendations like this Stack Overflow answer.
The Z shell alias is
which passes the--colour-auto
option to thegrc
command, which is the command that takes that option.However, The Bourne Again shell alias is
which is (via thecolourify
alias) effectively which is both running the output of thels
command through a colourizer and trying to get thels
command to colourize its output.The basic problem is that the author of these Bourne Shell aliases (which was Isaias Piña from Oracle in May 2016) hasn't catered for running the Bourne Again shell on anything other than a Linux operating system, probably expecting that if you are using MacOS you are using something like Oh My Zsh. An additional problem is that the author hasn't allowed for
grc
to colourize the output ofls
and is, rather, expectingls
to colourize its own output.So you have a number of options:
ls
alias to use the-G
option on MacOS.ls
alias to not use any option and instead rely upon the colourizer'sconf.ls
file to do its actual job; as Tom Mulder has.ls
alias entirely, using theCLICOLOR
environment variable for colourization instead; as Noel B Alonso does.ls
alias entirely, using your ownls
alias; as Arthur Nisnevich does.