4 releases (breaking)

0.11.0 Nov 14, 2024
0.10.0 Nov 14, 2024
0.9.0 Oct 21, 2024
0.8.0 Sep 18, 2024
0.7.0 Sep 9, 2024

#251 in Parser implementations

Download history 107/week @ 2024-09-06 179/week @ 2024-09-13 49/week @ 2024-09-20 18/week @ 2024-09-27 6/week @ 2024-10-04 1/week @ 2024-10-11 164/week @ 2024-10-18 19/week @ 2024-10-25 7/week @ 2024-11-01 133/week @ 2024-11-08 112/week @ 2024-11-15

280 downloads per month

AGPL-3.0-only

56KB
1K SLoC

nu_plugin_file

This nushell plugin will open files to inspect them and report back a little information. It uses magic bytes to determine many file formats. The core code was "borrowed" from a spacedrive crate that I thought looked interesting.

Usage:

❯ help file
View file format information

Usage:
  > file <filename>

Flags:
  -h, --help - Display the help message for this command

Parameters:
  filename <string>: full path to file name to inspect

Examples:
  Get format information from file
  > file some.jpg
  ╭──────────────┬──────────╮
  │ description  │ Image    │
  │ format       │ jpg      │
  │ magic_offset │ 0        │
  │ magic_length │ 2        │
  │ magic_bytes  │ [FF, D8] │
  ╰──────────────┴──────────╯

Example with MacOS executable

❯ file ~/.cargo/bin/nu | table -e 
╭─────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ description │ mach-o binary, arm64                                                                                     │
│ format      │ Executable                                                                                               │
│             │ ╭─#─┬─offset─┬─length─┬────────bytes─────────╮                                                           │
│ magics      │ │ 004[207, 250, 237, 254] │                                                           │
│             │ ╰───┴────────┴────────┴──────────────────────╯                                                           │
│             │ ╭──────────────┬───────────────────────────────────────────────────────────────────────────────────────╮ │
│ details     │ │ arch         │ arm64                                                                                 │ │
│             │ │ format       │ mach-o                                                                                │ │
│             │ │              │ ╭───┬───────────────────────────────────────────────────────────────────────────────╮ │ │
│             │ │ dependencies │ │ 0/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation         │ │ │
│             │ │              │ │ 1/usr/lib/libobjc.A.dylib                                                      │ │ │
│             │ │              │ │ 2/System/Library/Frameworks/Security.framework/Versions/A/Security             │ │ │
│             │ │              │ │ 3/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation │ │ │
│             │ │              │ │ 4/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices     │ │ │
│             │ │              │ │ 5/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit                   │ │ │
│             │ │              │ │ 6/usr/lib/libiconv.2.dylib                                                     │ │ │
│             │ │              │ │ 7/usr/lib/libSystem.B.dylib                                                    │ │ │
│             │ │              │ ╰───┴───────────────────────────────────────────────────────────────────────────────╯ │ │
│             │ ╰──────────────┴───────────────────────────────────────────────────────────────────────────────────────╯ │
╰─────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Installation

  1. clone repo git clone https://github.com/fdncred/nu_plugin_file.git
  2. install with cargo cargo install --path .
  3. register plugin with nushell plugin add /path/to/nu_plugin_file
  4. bring plugin into scope plugin use /path/to/nu_plugin_file
  5. inspect a file file some.jpg

Dependencies

~24–54MB
~1M SLoC