antonmedv / walk

Terminal file manager
MIT License
3.29k stars 95 forks source link

Add a shortcut to view permissions and extended attributes on selected object? #116

Open ermo opened 1 year ago

ermo commented 1 year ago

Walk is great and is exactly what I've been looking for in an easy and convenient ls/cd replacement.

On systems with extended attributes, it might be super handy if walk had a way to show default (ls -l) and extended permissions (getfattr) with a shortcut for any particular highlighted file or directory?

The shortcut I would suggest is v, since that only changes the mode in vim/neovim and isn't associated with any other motion to the best of my knowledge.

Let me know what you think.

antonmedv commented 1 year ago

I like this idea. But we need to think it through. What gonna be displayed and how.

ermo commented 1 year ago

I like this idea. But we need to think it through. What gonna be displayed and how.

Could start by just listing ls -l? Or even the output of stat maybe? I was thinking that it'd be listed the same way as the view file (<SPACE>) functionality, with a window opening to the right?

The other option is to reflow the terminal and list it below the selected item if the terminal is too narrow for the output...?

EDIT: You know what, by default, I would suggest listing the ls -l output in a bar at the bottom/top for the item currently selected. Then you could use the v shortcut to view the extended attributes; stat for starters in a window on the right (if there's enough space) or on the bottom (if the terminal is too narrow for the fixed with of stat).

The reason for doing it like this is that, on SELinux systems, ls -l will show a small . if there is extended SELinux labelling available, which will be shown in stat as well.

This gives you the freedom to come up with a nice way to list extended attributes below the stat output once you settle on a good viewing format?

ermo commented 1 year ago

Here's the output of the most useful permission and file info tests I could come up with:

ermo@solbox:~/test-setfacl
$ ls -l
total 0
-rw-rw-r-- 1 ermo ermo 0 Sep  8 14:56 test-no-xattr
-rw-rw-r-- 1 ermo ermo 0 Sep  8 14:56 test-with-xattr
ermo@solbox:~/test-setfacl
$ getfacl test-no-xattr
# file: test-no-xattr
# owner: ermo
# group: ermo
user::rw-
group::rw-
other::r--

ermo@solbox:~/test-setfacl
$ getfacl test-with-xattr 
# file: test-with-xattr
# owner: ermo
# group: ermo
user::rw-
group::rw-
other::r--

ermo@solbox:~/test-setfacl
$ setfacl -m "g:adm:rw--" test-with-xattr 
ermo@solbox:~/test-setfacl
$ getfacl test-with-xattr 
# file: test-with-xattr
# owner: ermo
# group: ermo
user::rw-
group::rw-
group:adm:rw-
mask::rw-
other::r--

ermo@solbox:~/test-setfacl
$ ls -l
total 0
-rw-rw-r--  1 ermo ermo 0 Sep  8 14:56 test-no-xattr
-rw-rw-r--+ 1 ermo ermo 0 Sep  8 14:56 test-with-xattr
ermo@solbox:~/test-setfacl
$ stat test-with-xattr 
  File: test-with-xattr
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 8,1     Inode: 4195303     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/    ermo)   Gid: ( 1000/    ermo)
Access: 2023-09-08 14:56:31.423503726 +0200
Modify: 2023-09-08 14:56:31.423503726 +0200
Change: 2023-09-08 15:03:34.788450639 +0200
 Birth: 2023-09-08 14:56:31.423503726 +0200
ermo@solbox:~/test-setfacl
$ 

Notice how, if there are extended attributes (in this case ACL attributes) associated with a file, the ls -l output will append a +. This is entirely in line with SELinux's approach of appending a . if SELinux labels are detected.

antonmedv commented 1 year ago

Let’s just start with a bar at the end with permission/user/group, size (kb,MB,GB), modtime.

ermo commented 1 year ago

Good call.

Note that my rationale for suggesting the addition of an easy way to view extended attributes/ACLs for files is that, currently (to the best of my knowledge) no low-friction UX exists for doing so.

I see walk's approach as the ideal vessel for convenient terminal use of ACLs, in turn allowing the use of ACLs to become the norm, rather than the exception.

ermo commented 1 year ago

Just noting that I found POSIX Access Control Lists on Linux rather enlightening re. the mask: entries and the resulting effective permissions for a given ACL in case you care about that specific detail.

kice commented 10 months ago

I do not like the idea to "show file info" but rather "switch navigation mode".

For example, we can use a key shortcut for switch from ls to ls -l mode.

I think in ls -l mode, at least showing: size (human readable, or in bytes), permission, user/group, last modified time.

Check this out: https://github.com/kice/walk/commit/1c7829f3f0dae60edbb835a36c851c848819a8ac