Skip to content

Instantly share code, notes, and snippets.

@floffy-f
Created February 10, 2026 12:36
Show Gist options
  • Select an option

  • Save floffy-f/a664c0fbe61fce3de382b619492a6ff4 to your computer and use it in GitHub Desktop.

Select an option

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
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