Code Monkey home page Code Monkey logo

nepo's Introduction

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 the viu terminal image viewer and nepo book.epub with the epy epub reader.

nepo-recording-small.mp4

Tldr

  • nepo is configured at ~/.nepo.yml with simple association rules

    epubs:
      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 as function 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 -p ${files}

markdown:
  ext: md
  cmd: glow ${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

nepo's People

Contributors

fvdsn avatar

Watchers

 avatar

nepo's Issues

Match by filename

Files like Makefile Dockerfile and others don't have file extensions and are better matched by exact filename

Whitespaces in cmd

it is currently impossible to provide a cmd argument with a whitespace in it as it will be considered as two different

Handle Directories

What if we pass a directory as an argument ? investigate the use-case

Tests

sooner than later

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.