Giter Site home page Giter Site logo

just-open's Introduction

Just Open

Simple, configurable script to open files.

One can just give any file as a parameter, and it's then opened in the preferred application. It's configurable, so one can define their favorite apps, and just open the files like they want.

Requirements

  • Python 3.x

Other Python versions might work, but are unsupported.

Configuration file

The configuration file should be stored as:

~/.just-open.json

As the extension says, it's just plain JSON file. It should be formatted as:

{
    "runners": {
    },
    "extmap": {
    }
}

Those two sections should contain specific mappings, see definitions below or see just-open.sample.json for example.

Runners

First "runners" should have mime types mapped for application or command. The mime type should be JSON string just like "text/plain". Command should be string or list. For example:

"runners": {
    "text/plain": "vim",
    "inode/directory": ["ls", "-la", "--color=tty"],
}

This would mean that all files detected as "text/plain" are opened with "vim", so that command would be:

vim filename

Then all files that are detected to be "inode/directory" are opened as:

ls -la --color=tty filename

In case the filename should not be the last, use "$F" which is expanded to be the filename:

"runners": {
    "inode/directory": ["find", "$F", "-type", "f"],
}

Becomes:

find filename -type f

Extmap

Extmap maps simply extension to a mime type. This is simple string to string mapping. Extensions are split on every dot, and all possibilities are tried, thus test.tar.gz will be tested first for "tar.gz" and then for "gz".

If there's a match in "extmap", the matching mime type is used. After that the mime type is searched from the "runners" list. If there's no specification for it, fallback method is used to open the file.

Fallback

Fallback method for now is "xdg-open" which should utilize proper system configuration to open the file. This behaves similarly than clicking the file in (graphical) file browser. For non-graphical environment this might not work and the method fails.

Installation

To install it to you $HOME/bin just do:

make install

In order to install it under another folder, like /usr/local/bin:

make install DESTDIR=/usr/local

just-open's People

Contributors

jroivas avatar

Watchers

 avatar  avatar

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.