feat: Add support for listing file attributes (similar to ```lsattr```)
Feature Request: Add support for listing file attributes (similar to lsattr)
First of all, I'd like to thank you for all your work.
Description
Currently, eza is a fantastic modern replacement for ls, offering many enhanced features and better defaults. However, one feature that is missing and would be very useful is the ability to list file attributes, similar to what lsattr does.
The lsattr command is used to list the attributes of files on a Linux file system, such as immutability, append-only, and no-dump flags. These attributes are crucial for certain system administration tasks and security configurations.
Use Case
As a system administrator or a power user, I often need to check the attributes of files to ensure they are configured correctly for security and backup purposes. Having this functionality integrated into eza would streamline my workflow and reduce the need to switch between different commands.
Proposed Solution
Add a new option to eza (e.g., --attributes) that would display the file attributes in a similar format to lsattr on GNU/Linux and BSD, xattr on MacOSX or streams -s on Windaub. This feature should be compatible with various file systems and operating systems, including Linux (ext2/ext3/ext4, XFS, Btrfs), macOS (APFS, HFS+), Windows (NTFS), and BSD (UFS, ZFS).
So, ensure compatibility with different file systems that support extended attributes.
Document the new feature in the eza manual and help output.
Implementation Hints
To implement this feature, the following steps might be necessary:
- Modify the codebase to include new functions that read file attributes. This would likely involve using system calls to retrieve attribute information:
- Add new functions to read file attributes using system calls specific to each operating system and file system.
- For Linux, use system calls similar to those used by
lsattr. - For macOS, use the
xattrAPI. - For Windows, use tools like
streamsfrom Sysinternals or NTFS-specific system calls. - For BSD, use system calls similar to those in Linux or ZFS-specific tools.
- Update the output formatting to display the attributes in a user-friendly manner, possibly alongside the existing file information:
- Display attributes in a user-friendly manner, possibly alongside existing file information, and consistent with the existing coloration and style, particularly the display of permissions.
- Ensure compatibility with
lsattroptions that are similar tols(-ato display all files,-dfor directories,-Rfor recursive display). - Omit (or not) options like
-lfor long name,-pto list file's project number, and-v(which could be replaced by-V) to list file version/generation number. - Adapt the output format to be consistent with the conventions of each operating system.
- Add tests to ensure the new functionality works correctly and does not interfere with existing features.
- Thoroughly test the new feature to ensure it works correctly across different operating systems and file systems.
- Verify that the new feature does not interfere with existing
ezafunctionalities.
- Document the New Feature:
- Update the
ezamanual and online help to include information about the new--attributesoption. - Provide usage examples for each supported operating system.
Example Output
$ eza --attributes
----------------- /path/to/directory
I---------e-- ./file1
----i-------- ./file2
In this example, the attributes are displayed in a format similar to lsattr or the permissions, with each character representing a different attribute.
Additional Context
The lsattr command is part of the e2fsprogs package and is commonly used on ext2/ext3/ext4 file systems.
Adding this feature would make eza even more versatile and useful for system administration tasks.
Thank you for considering this feature request. I believe it would be a valuable addition to eza and would greatly enhance its functionality.
I'm open to the idea, sounds like a cool/useful feature!