Created
February 10, 2026 12:36
-
-
Save floffy-f/a664c0fbe61fce3de382b619492a6ff4 to your computer and use it in GitHub Desktop.
A nushell function to adapt the output of eza to be compatible with the nushell format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def my-nu-eza [ | |
| p: path = "." | |
| ] { | |
| eza --oneline -l --time-style full-iso $p | |
| | lines | |
| | parse --regex '(?<type>l|d|\.)(?<mode>[xrw\-]*)\s+(?:(?:(?<fsize>[0-9]{1,3}\.?[0-9]?)(?<fsizeunit>\w*))|(?<dsize>-))\s+(?<user>\w+)\s+(?<modified>(?:[0-9\-]+)\s(?:[0-9\:\.]+)\s(?:\+[0-9]{4}))\s+(?<name>.*)' | |
| | update type { | |
| |row| match [$row.type $row.dsize $row.fsize] { | |
| ['.', '', _] => 'file' | |
| ['d', '-', ''] => 'dir' | |
| ['l', '-', ''] => 'symlink' | |
| _ => ("error: " + $row.type + $row.dsize + $row.fsize) | |
| } | |
| } | |
| | insert size { | |
| |row| match $row.type { | |
| 'dir' | 'symlink' => '-' | |
| 'file' => (($row.fsize + $row.fsizeunit) | into filesize) | |
| _ => "error" | |
| } | |
| } | |
| | reject fsize fsizeunit dsize | |
| | update modified {|row| $row.modified | into datetime} | |
| | move name --before type | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment