2 releases
0.1.1 | May 2, 2024 |
---|---|
0.1.0 | May 2, 2024 |
#2077 in Command line utilities
22KB
285 lines
nepo
nepo
is a cli tool that open files with a program depending on the file extension.
For example,
nepo image.png
could open it with theviu
terminal image viewer andnepo book.epub
with theepy
epub reader.
Tldr
-
nepo
is configured at~/.nepo.yml
with simple association rulesepubs: ext: - epub - epub3 cmd: epy ${file}
-
nepo --mode=foo file.ext
allow you to select a different program to open the file -
nepo
is best used with shell aliases such asfunction view() { nepo --mode=view "$@" }
-
Can iterate over multiple files or open them all at once.
-
Have a look at my personal configuration file
Installation
With cargo:
$ cargo install nepo
Configuration
You must create a nepo configuration file in your home
directory named ~/.nepo.yml
.
default:
cmd: vim ${files}
epubs:
ext:
- epub
- epub3
cmd: epy ${file}
images:
ext:
- png
- jpg
cmd: viu ${files}
This yaml file contains associations that match file extensions to commands. If the file doesn't match any assocation, the top one will be used.
The cmd
configuration accepts ${file}
and ${files}
as parameters.
The singular variant contains the first filename provided, while the plural
will contains them all.
If multiple files are provided, only the files with the matching extensions will be provided to the command.
If multiple associations match a file the last one gets priority.
Modes
If you call nepo
with a mode (nepo --mode=view
), It will only consider assocations
with the selected mode.
view_json:
mode: view
ext: json
cmd: jless ${file}
You can define any mode you want, but the edit
and view
mode can be used with the
shorthands nepo --view, -v, --edit, -e
Dependencies
~3–13MB
~111K SLoC