lsd-rs / lsd

The next gen ls command
Apache License 2.0
13.63k stars 437 forks source link

User/Group: display only if different from default (or allow substitution filter) #793

Open eugenesvk opened 1 year ago

eugenesvk commented 1 year ago

For a lot of contexts when browsing your files, you expect the permissions to be, for example, user staff, so it's just visual noise and extra column width to see these in every single line. This also prevents you from easily spotting something less common, e.g., some root file.

As an illustration, notice how easier it is to spot that there is a different group in one file, and another one is owned by root, in the second example vs. the first

user staff name
user staff name
user staff name
user staff name
user staff name
root wheel name
user staff name
user admin name
user staff name
user staff name
user staff name
user staff name
           name
           name
           name
           name
           name
root wheel name
           name
     admin name
           name
           name
           name
           name

One solution would be to have different colors, but I think a better one would be to allow a more general text filter substitution, e.g., it would allow you to auto-replace any occurence in the name column:

      name
      name
      name
      name
      name
🔐 ☸  name
      name
   🛠 name
      name
      name
      name
      name
meain commented 1 year ago

Both this as https://github.com/Peltoche/lsd/issues/795. They seem useful on the surface, but I can't think of a usecase where one would need this.

eugenesvk commented 1 year ago

What deeper meaning do you seek if clarity of output and differentiation between permissions (along with https://github.com/Peltoche/lsd/issues/800) is not enough?

meain commented 1 year ago

I'm just wondering what would be a usecase where one would want to hide the common ones? Just wanted to understand the usecase to make sure we are getting the feature right.

eugenesvk commented 1 year ago

I'm just wondering what would be a usecase where one would want to hide the common ones?

To avoid information noise. To easier see the diffs and spot inconsistencies. To save horizontal space. Also, you don't need to hide them, you can make them less visible

user with 👤 (or with blank space or _ or ...)

So the usecase is very similar to every other formatting option like colors and number alignment, which help organize and highlight relevant information

zwpaper commented 1 year ago

IMHO, it is a funny functionality, I would vote +1 for this feature.

the only concern is which symbol can represent the meaning of the default user/group.

using icons is a great option, but we still need a text solution if we really want to do this

eugenesvk commented 1 year ago

the only concern is which symbol can represent the meaning of the default user/group.

using icons is a great option, but we still need a text solution if we really want to do this

Not really, you don't need to have any solution, all this input can come from the user, who can abbreviate to whatever they like, a simple me or def or anything more fancy (btw, the icons above are regular unicode text just like in your unicode format, not patched fancy font icons or any images)

That's the beauty of a simple text substitution filter The default could still be whatever you have now, i.e., the full text name

meain commented 1 year ago

To easier see the diffs and spot inconsistencies.

What I am looking for was to understand when one would need a feature like this. What would be a situation where you are looking for files that are not by the current user where something like ls -l | grep -v 'user or a find command isn't better.

Also, you don't need to hide them, you can make them less visible

This seems like a less obtrusive way to do this where we can use a fainter color for default values. Having a text substitution seems like too much. Same can probably work for https://github.com/Peltoche/lsd/issues/795 as well.

zwpaper commented 1 year ago

What would be a situation where you are looking for files that are not by the current user where something like ls -l | grep -v 'user or a find command isn't better.

grep or find could do this, but we have to do 2 commands, lsd and grep/find, every time, in most cases, I only want to know the general overall in a glance.

eugenesvk commented 1 year ago

What I am looking for was to understand when one would need a feature like this. What would be a situation where you are looking for files that are not by the current user where something like ls -l | grep -v 'user or a find command isn't better

Any situation? Why would I need the mental overhead of extra filters when I can simply use lsd as usual and get this for free? Also your grep is only for the user, but the proposed solution covers both the user and the group, so you need to adjust grep for that. Also, what about persmissions, that's also related, that's another grep.

This seems like a less obtrusive way to do this where we can use a fainter color for default values. Having a text substitution seems like too much. Same can probably work for #795 as well.

Also, text substitution would also work for:

meain commented 1 year ago

Colors don't allow you to save precious space in a dense table

Even if we have one entry that is not the default value, we will end up taking up the space for all entries. So don't think this change would make a huge difference.

is more visible than

This is arguable IMO

customizable size labels

The problem with this is that we are adding more surface area without a strong usecase (as of now). Also, how would an interface for this look like?

I'd love to remove the uselessly wide 3-letter days with a single letter

What do you have in mind for how we customize this in lsd? Providing text substitutions, while it a general solution, I don't think is a good one in this particular situation.

eugenesvk commented 1 year ago

Even if we have one entry that is not the default value, we will end up taking up the space for all entries. So don't think this change would make a huge difference.

Of course it would, for the most obvious reason — when you abbreviate values (root to r), then the space for all entries goes down. Also if you abbreviate username to `` (and it's very common for all files to have the same) then you don't even get this column shown at all, so you also save on the padding space.

For example, not taking file names into account, I have a line of ~47chars, out of which ~15 is for the username/usergroup, that's a saving of ~30% if fully eliminated and ~25 if non-defaults are abbreviated This is a huge difference! And colors simply can't match this

This is arguable IMO

So what's you argument that two dimensions of change (nothing→something and color1→color2) is less visible than just one?

customizable size labels

The problem with this is that we are adding more surface area without a strong usecase (as of now).

I fail to understand the weakness of saving a lot of space, using proper and common tabular alignment in a table for numbers, while at the same time increasing readability

Also, how would an interface for this look like?

As a very simple text/regex substitution?

# a simple match or a regex sub
# with a more general soulution you can have 'user-name'/'group-name'/'date' as subfields to a 'substitution'
user-name-substitution  :                           #
  - username            ''                          # simple text sub 'username'→'' blank
  - root                '🔐'                         #
  - regex               ['username1|username2','']' # regex sub of either of the user names→'' blank
group-name-substitution :                           #
  - staff               ''                          # blank
  - wheel               '☸'                         #
  - admin               '🛠'                         #
  - regex               ['group1|group2','']'       # blank either of the group names

I'd love to remove the uselessly wide 3-letter days with a single letter

What do you have in mind for how we customize this in lsd? Providing text substitutions, while it a general solution, I don't think is a good one in this particular situation.

Why not? It's a great common tool that I can use anywhere that would solve several of the opened issues More customizing power to the user!

meain commented 1 year ago

I still don't think text substitution is a good choice. We can probably detect the current user and default group names and hide it automatically, just wondering what to replace it with or what the flag should be.

Just FYI, you can reduce the size of the ls display by choosing the blocks that you want to display. This is how it looks for me and I hide the user, group column unless I want explicitly take a look at it. 2023-01-19-10-09-46

More customizing power to the user!

Not to sound like a fun killer, but the problem with it is that it adds unnecessary maintenance burden when you have features that are not very useful, but touches a relatively large chunk of the codebase.

eugenesvk commented 1 year ago

unless I want explicitly take a look at it.

And then you'd need to remember which flag to use or edit a config file, which is such a waste! With my propoal I can just always use one universal l command that will be smart enough to show me all that info in a more dense, but also more readable way vs. what is currently available. So you can "explicitely take a look at it" just by looking at the column

With text sub you could also replace

2 months ago
2 weeks ago
2 day ago
2 months ago
2 weeks  ago
2 day    ago

or even better (the ago is useless as always know it's the past from the context of the column)

2 mon
2 wk
2 d

That's the design power of generic substitutions