Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fdncred/nu_plugin_file
A nushell plugin that will inspect a file and return information based on it's magic number.
https://github.com/fdncred/nu_plugin_file
nushell nushell-plugin
Last synced: 21 days ago
JSON representation
A nushell plugin that will inspect a file and return information based on it's magic number.
- Host: GitHub
- URL: https://github.com/fdncred/nu_plugin_file
- Owner: fdncred
- License: agpl-3.0
- Created: 2023-08-09T16:19:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-21T20:25:38.000Z (26 days ago)
- Last Synced: 2024-10-22T14:50:07.959Z (25 days ago)
- Topics: nushell, nushell-plugin
- Language: Rust
- Homepage:
- Size: 80.5 MB
- Stars: 23
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nu - nu_plugin_file
README
# 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](https://github.com/spacedriveapp/spacedrive/tree/main/crates/file-ext) crate that I thought looked interesting.
## Usage:
```nushell
❯ help file
View file format informationUsage:
> fileFlags:
-h, --help - Display the help message for this commandParameters:
filename : full path to file name to inspectExamples:
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
```nushell
❯ file ~/.cargo/bin/nu | table -e
╭─────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ description │ mach-o binary, arm64 │
│ format │ Executable │
│ │ ╭─#─┬─offset─┬─length─┬────────bytes─────────╮ │
│ magics │ │ 0 │ 0 │ 4 │ [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`