lsd icon indicating copy to clipboard operation
lsd copied to clipboard

How to Show Hidden Files/Directories Last?

Open amarakon opened this issue 2 years ago • 8 comments

If I use "lsd -a", hidden files and directories are listed first since they start with '.'. I would like for them to actually be listed last.

amarakon avatar Jan 30 '22 19:01 amarakon

You can reverse the order using -r or --reverse flag.

meain avatar Jan 31 '22 12:01 meain

I would like to have the ability to keep things in alphabetical order but also have hidden files and directories listed after the non hidden files and directories.

amarakon avatar Feb 01 '22 01:02 amarakon

As of now, I don't really see a strong usecase for this, but I will keep this open as of now and if there is enough interest we can add --group-hidden flag similar to group directories.

meain avatar Feb 02 '22 04:02 meain

i think this would be better as a config option and not a command switch personally

Hellzbellz123 avatar Jun 26 '22 05:06 Hellzbellz123

If this gets implemented, it will be available both as a cli flag and a config option like most other flags.

meain avatar Jun 26 '22 05:06 meain

This sounds like a collation thing. like LC_COLLATE=C causes hidden files to be first - the only proper way :)

grimm26 avatar Jul 02 '22 21:07 grimm26

I prefer sorting this way as well; looking to use alongside --group-directories-first: {dirs} {dot dirs} {files} {dot files}

acamso avatar Aug 15 '22 20:08 acamso

As I commented on #814,

If you don't mind the inefficiency of running ls first, I'm currently using the following work-around to get the sorting that I prefer from ls with the display niceties of lsd (zsh shell on Fedora 38):

alias ll="ls -1X --sort=extension --group-directories-first --color=never | xargs lsd -Uld"

  • The -1 flag to ls outputs one item per line.
  • --color=never suppresses terminal escape sequences in the output, leaving pure file and directory names as outputs.
  • piping to xargs lsd takes the lines of output from ls, in the right order, and makes them arguments for lsd.
  • -U suppresses the sorting done by lsd, maintaining the order given by the order of the arguments.
  • -d makes lsd print info on a directory, rather than its contents.

raabrp avatar Sep 06 '23 19:09 raabrp