Most of the similar questions / answers here don't work in Mac/OSX because there is not such a thing as --options.

I am using the ZSH shell, I've been trying commands said here: http://www.rayninfo.co.uk/tips/zshtips.html but without success.

Thanks for any help.


Instead of hacking around and parsing ls output—which is never a good idea—you could simply install the GNU Coreutils, which give you the GNU versions of ls, date, echo, head and tail, and many more, which offer much more than the BSD counterparts.

The easiest way to do that would be to install Homebrew, and then run brew install coreutils. Now, the GNU coreutils will be available prefixed with a g, and you could run:

gls -l --group-directories-first

Or, you could even alias that in your .zshrc:

alias ls='gls --group-directories-first'
  • It worked like a charm:) the only thing is that I lose my zsh colors/settings.(obviously) - A simple note for other persons, I had macports and a warning about possible conflict with homebrew but had no problem. I'm new to Mac / and not much more advanced in UNIX ecosystems so noob inside. – Kev Feb 2 '13 at 12:17
  • You shouldn't really need to use both, I guess MacPorts also has a Coreutils port? But if it works, then you're fine :) As for the colors, you can try running gls --color=auto. – slhck Feb 2 '13 at 12:26
  • 1
    gls --color=auto does the trick for me. Thanks for the this answer! – Johann Jan 3 '14 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.