Grouping and sorting regular and symlinked folders before files with ls in zsh
by Hund | October 13, 2018
By default ls sorts all folders, symlinked folders and files by name and not by type and then by name, which I find quite annoying and sometimes even confusing.
Thankfully you can change this behavior pretty easy, you just need to add one small function to your zsh configuration:
dir1st() { [[ -d $REPLY ]] && REPLY=1-$REPLY || REPLY=2-$REPLY;}
Then call it like this:
ls -ldU -- *(o+dir1st)
And here’s an example image:

If you’re a Bash user and knows how to make this work there, let me know! I’m pretty sure there’s a lot of Bash users out there who would want this as well.
Comments
There's no comments for this post. Use this e-mail form if you would like to leave a /public/ comment on this post. Or simply send me a private e-mail message if you have any feedback, or just want to say hello.