Skip to content

dvorakchen/open

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

open

Smart file opener — dispatches files and directories to different programs based on type.

Features

  • Type-aware dispatching: Opens video, audio, image, and text files each with their own configured program.
  • Special keywords: music, wifi, mail, im, cb, db, postman — launch apps or run pipelines with a single word.
  • Configurable: Edit ~/.config/open/open.toml to set your preferred programs for each type.
  • Sensible defaults: Works out of the box with common terminal tools (termusic, mpv, nvim, yazi, etc.).

Installation

# Make it executable
chmod +x open

# Copy to somewhere in your PATH
cp open ~/.local/bin/open

Requires Python 3.11+ (for tomllib).

Usage

open <music|wifi|mail|im|cb|db|postman|path>

Special keywords

Keyword Action Default
music Launch music player termusic
wifi WiFi manager nmtui
mail Email client aerc
im Instant messaging iamb (Matrix client)
cb Clipboard manager cliphist list | fzf | cliphist decode | copy
db Database client gobang
postman API client atac

File types

| Type | Handler |

GIF mpv
Directory yazi
Video mpv
Audio mpv
Image kitty +kitten icat
Text nvim
Default xdg-open

Configuration

On first run, a config file is created at ~/.config/open/open.toml with the defaults shown above. Edit it to use your preferred programs:

# ~/.config/open/open.toml

# Special keywords
music = "spotify-tui"
wifi = "iwgtk"
mail = "mutt"
im = "weechat"
clipboard = "cliphist list | fzf | cliphist decode | wl-copy"
db = "gobang"
postman = "atac"

# Directory handler
directory = "lf"

# MIME-type handlers
video = "vlc"
audio = "audacious"
image = "nsxiv"
text = "helix"

# Fallback for unknown file types
default = "xdg-open"

Handlers can include arguments (e.g., kitty +kitten icat) or shell pipelines (e.g., cliphist list | fzf | ...). Pipeline commands are run through the shell; everything else is split with shlex and passed to subprocess.run.

Examples

open ~/music/playlist/     # Opens in yazi (file manager)
open video.mp4              # Opens in mpv
open photo.png              # Opens in kitty image viewer
open document.md            # Opens in nvim
open music                  # Launches termusic
open wifi                   # Opens nmtui
open mail                   # Opens aerc
open im                     # Opens iamb (Matrix)
open cb                     # Opens clipboard manager (fzf pick → decode → copy)
open db                     # Opens gobang (database client)
open postman                # Opens atac (API client)

Dependencies

Program Used for
Python 3.11+ (for tomllib) Runtime
termusic / mpv / nvim / yazi / kitty Default handlers (configurable)
aerc / iamb / cliphist / nmtui Default keyword handlers
gobang / atac Default keyword handlers

License

Apache License 2.0

About

python script to open anything

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages