I'm aware of the
--group-directories-first but that's not exactly what I want to achieve.
The output should be: (sorted by name ASC)
- Hidden Directories
- Hidden Files
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
-U option to tell
ls not to sort the file list is a GNU extension):
ls -lUd -- *(/) .*(/) .*(^/)
The problem though is that if any of those globs don't match, the command will be cancelled, so you could do:
myls() ( setopt cshnullglob ls -lUd -- *(/) .*(/) .*(^/) )
That emulates the
csh behaviour whereby globs with no match expand to nothing as long as there's at least one glob that expands to something in the command.
zsh globs never expand
.., so those two will never be included.