Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: owner user and group linemode #932

Closed
wants to merge 9 commits into from
Closed

Conversation

AidanV
Copy link
Contributor

@AidanV AidanV commented Apr 20, 2024

Added m => o linemode keymap that displays the user and group of the owner of a file or directory.

Adds dependency in yazi-shared
users = "0.11.0"
https://crates.io/crates/users

@@ -21,6 +21,8 @@ function Folder:linemode(area, files)
spans[#spans + 1] = ui.Span(time and os.date("%y-%m-%d %H:%M", time // 1) or "")
elseif mode == "permissions" then
spans[#spans + 1] = ui.Span(f.cha:permissions() or "")
elseif mode == "owner" then
spans[#spans + 1] = ui.Span(f.cha:owner() or "")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the existing user_name() instead, https://yazi-rs.github.io/docs/plugins/utils#ya.user_name

@AidanV
Copy link
Contributor Author

AidanV commented Apr 22, 2024

Made suggested change

@sxyazi sxyazi force-pushed the main branch 10 times, most recently from b98d00e to c65a14c Compare April 23, 2024 08:35
@@ -21,6 +21,12 @@ function Folder:linemode(area, files)
spans[#spans + 1] = ui.Span(time and os.date("%y-%m-%d %H:%M", time // 1) or "")
elseif mode == "permissions" then
spans[#spans + 1] = ui.Span(f.cha:permissions() or "")
elseif mode == "owner" then
local username = ya.user_name(f.cha.uid)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya.user_name, ya.group_name, cha.uid, and cha.gid are Unix-specific attributes/methods, they will break the UI rendering on the Windows platform.

Perhaps we can expose them to the Windows platform, but just return a nil value? Or add this code snippet to the Tips page so Unix users can copy it from there? Curious your thoughts!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is pretty important on Unix to be able to see the user and group of files by default. Additionally this functionality somewhat already exists through the status bar.

It would be nice if this functionality could work on Windows as well. It looks doable here, but more complicated than it should be.

If we expose these methods to the Windows platform we should remove the ability to see the ownership key-bind in the help page. It would be confusing for a Windows user to see the option and have it do nothing.

I am happy to implement either safely hiding it on Windows or having the ownership functionality on Windows, up to you.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, please implement the ownership functionality on Windows!

@sxyazi
Copy link
Owner

sxyazi commented May 16, 2024

I'm going to close this because it still needs some work and hasn't seen any activity recently. @AidanV thanks for the effort!

@sxyazi sxyazi closed this May 16, 2024
@AidanV
Copy link
Contributor Author

AidanV commented May 16, 2024

Sounds good, I do not have access to a Windows computer at the moment. I will pick it back up when I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants