A modern command-line file opener for Linux that respects XDG MIME associations and provides an interactive fuzzy-finder interface for selecting applications.
- XDG Compliance: Respects system MIME type associations and desktop entries
- Interactive Selection: Choose applications using fzf or fuzzel
- Desktop Actions: Support for application-specific actions (edit, print, etc.)
- Caching: Fast desktop file parsing with intelligent caching
- JSON Output: Machine-readable output for integration with other tools
- Build Information: Detailed build and version information with git commit tracking
- Configurable Fuzzy Finders: Customize fuzzy finder commands and arguments with template support
git clone https://github.com/CaddyGlow/openit.git
cd openit
cargo install --path .cargo install openit# Open a file with interactive application selection
openit document.pdf
# Output available applications as JSON
openit document.pdf --json
# Show desktop actions as separate entries
openit image.png --actions
# Use a specific fuzzy finder
openit file.txt --selector fzfUsage: openit [OPTIONS] [FILE]
Arguments:
[FILE] File to open (not required when using --build-info or --clear-cache)
Options:
--selector <SELECTOR> Selector profile to use [default: auto] (profile name, e.g. auto, fzf, fuzzel, rofi)
-j, --json Output JSON instead of interactive mode
-a, --actions Show desktop actions as separate entries
--clear-cache Clear the desktop file cache
-v, --verbose Increase logging verbosity (-v = info, -vv = debug)
--build-info Show build information
--generate-config Generate default configuration file
--config <CONFIG> Path to configuration file
--terminal-mode <TERMINAL_MODE>
Override how terminal applications launch (`current` for in-place, `launcher` for external emulator)
-h, --help Print help
-V, --version Print version
openit document.pdfOpens an interactive fuzzy finder showing all applications that can handle PDF files.
openit document.pdf --json | jq .{
"file": "/path/to/document.pdf",
"mimetype": "application/pdf",
"xdg_associations": ["evince.desktop", "firefox.desktop"],
"applications": [
{
"name": "Document Viewer",
"exec": "evince %U",
"desktop_file": "/usr/share/applications/evince.desktop",
"comment": "View multipage documents",
"icon": "evince",
"is_xdg": true,
"xdg_priority": 0,
"is_default": true,
"action_id": null
}
]
}openit image.png --actionsShows both the main application entries and their available actions (edit, print, etc.).
openit --generate-configCreates a default configuration file at ~/.config/openit/config.toml with customizable fuzzy finder settings.
openit completions bash --output ~/.local/share/bash-completion/openitGenerates a completion script for the specified shell. Omitting --output prints the script to stdout. Dynamic completions are also available via COMPLETE=<shell> openit for shells that support clap's auto-completion protocol.
openit now exposes subcommands to edit the user mimeapps.list directly:
# Set (overwrite) the default handler for a MIME type or extension
openit set text/plain helix.desktop
# Add a secondary handler without replacing the default entry
openit add text/plain code.desktop
# Remove a specific handler
openit remove text/plain code.desktop
# Remove all handlers for a MIME type
openit unset text/plain
# Inspect configured handlers
openit list
openit list --json | jqFile extensions are automatically converted to their corresponding MIME types (e.g., openit set .md helix.desktop).
- Linux system with XDG desktop environment
- One of the following fuzzy finders:
fzf(recommended)fuzzel
The application reads standard XDG directories and files:
- Desktop entries from
/usr/share/applications/,~/.local/share/applications/ - MIME associations from
~/.config/mimeapps.list,/etc/xdg/mimeapps.list - XDG data directories as specified by environment variables
The application follows XDG Base Directory specifications:
- Cache:
~/.cache/openit/desktop_cache.json - Config:
~/.config/openit/config.toml - Data: Reads from standard XDG data directories
Generate a default configuration file:
openit --generate-configThis creates ~/.config/openit/config.toml with the following structure:
open_with = true
term_exec_args = "-e"
expand_wildcards = false
terminal_execution = "launcher"
app_launch_prefix = null
[default]
gui = "fuzzel"
tui = "fzf"
[selectors.fzf]
command = "fzf"
args = [
"--prompt", "{prompt}",
"--height=40%",
"--reverse",
"--header={header}",
"--cycle"
]
env = {}
[selectors.fuzzel]
command = "fuzzel"
args = [
"--dmenu",
"--prompt", "{prompt}",
"--index",
"--log-level=info"
]
env = {}
[selectors.rofi]
command = "rofi"
args = [
"-dmenu",
"-p", "{prompt}"
]
env = {}The [default] table configures which selector profile is preferred in GUI and TUI environments. When --selector auto (the default) is used, openit chooses the GUI profile when launched from a graphical session and the TUI profile otherwise. Use --selector <name> on the CLI to force a specific profile defined under [selectors.*].
app_launch_prefix lets you prepend another command before every launch (for example "flatpak run" or "env WAYLAND_DISPLAY=..."). Set it to an empty string or remove the key to disable the prefix.
The configuration supports template variables in command arguments:
{prompt}: Replaced with the file selection prompt (e.g., "Open 'file.txt' with: "){header}: Replaced with the application type indicators ("★=Default ▶=XDG Associated =Available"){file}: Replaced with the filename being opened
You can add modifiers to variables; for example {file|truncate:20} shortens the displayed file name to 20 characters and appends ... when truncation occurs.
You can add custom fuzzy finder configurations:
[selectors.wofi]
command = "wofi"
args = [
"-dmenu",
"-p", "{prompt}",
"-theme", "my-theme"
]
env = { "WOFI_THEME" = "custom.rasi" }If a desktop entry declares Terminal=true, openit automatically runs it inside a terminal emulator. Resolution happens in two steps:
- Check for handlers of the virtual MIME type
x-scheme-handler/terminal. - If none are registered, fall back to any desktop entry that advertises the
TerminalEmulatorcategory.
By default, the terminal command is invoked with -e to execute the target application. If your terminal expects different arguments you can adapt the behaviour in ~/.config/openit/config.toml (or in ~/.config/handlr/handlr.toml for handlr-compatibility) by updating term_exec_args:
# Terminals that need a different flag (replace `run` as required)
term_exec_args = "run"
# Terminals that already embed the command in the Exec line or do not
# require a launcher flag (e.g. WezTerm, kitty)
term_exec_args = ""When term_exec_args is an empty string or the key is omitted, no additional arguments are added before the target command.
Set terminal_execution = "current" to run terminal applications inside the invoking shell by replacing the openit process via exec.
This is equivalent to launching openit with --terminal-mode current. Keep the value at "launcher" (or pass --terminal-mode launcher) to continue spawning a separate terminal emulator.
XDG_DATA_HOME: User data directory (default:~/.local/share)XDG_CONFIG_HOME: User config directory (default:~/.config)XDG_DATA_DIRS: System data directories (default:/usr/local/share:/usr/share)XDG_CONFIG_DIRS: System config directories (default:/etc/xdg)XDG_CURRENT_DESKTOP: Current desktop environment
- Rust 1.80.0 or later
- System dependencies for development:
sudo apt-get install desktop-file-utils shared-mime-info xdg-utils
# Debug build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Run with logging
cargo run -- file.txt -vvThe application consists of several modules:
- cli: Command-line argument parsing and build information
- config: Configuration file handling with template support
- desktop_parser: Desktop entry file parsing
- mime_associations: XDG MIME type association handling
- xdg: XDG Base Directory specification utilities
Desktop files are parsed once and cached to ~/.cache/openit/desktop_cache.json for improved performance. The cache is automatically rebuilt when:
- Cache file doesn't exist
- Cache file is corrupted
--clear-cacheflag is used
The application supports multiple fuzzy finders with configurable commands and arguments:
- Auto-detection: Automatically detects available fuzzy finders (fzf, fuzzel)
- Template support: Command arguments support template variables for dynamic content
- Environment variables: Set custom environment variables for fuzzy finder execution
- Icon support: Fuzzel integration includes icon display for applications
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass:
cargo test - Ensure code is formatted:
cargo fmt - Ensure no clippy warnings:
cargo clippy - Submit a pull request
This project uses standard Rust formatting and linting:
cargo fmt
cargo clippyRun the full test suite:
# Unit tests
cargo test
# Integration tests
cargo test --test '*'
# Test with all features
cargo test --all-features
# Test documentation
cargo test --docThis project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a list of changes in each version.
- Built with clap for command-line parsing
- Uses serde for JSON serialization
- Follows XDG Base Directory Specification
- Respects Desktop Entry Specification