fast small embed history backend
Project description
xontrib-looseene
A lightning-fast, compressed, inverted-index history backend for xonsh shell.
Looseene is a specialized history backend for xonsh that acts like a mini-search engine for your terminal. Unlike standard history (which scans text files), Looseene builds an inverted index using mmap, zlib, and struct, enabling instant search results even with massive history logs.
🚀 Features
- Full-Text Search: Uses BM25 ranking algorithm to find the most relevant commands, not just the most recent.
- Interactive UI: Built-in TUI (Terminal User Interface) triggered by
Ctrl+R. - Smart Deduplication: Automatically hashes commands (MD5) and ignores duplicates. Your history stays clean.
- Compression: Data is stored in compressed binary segments (
zlib), saving disk space. - Safe Stemming: Includes a lightweight English stemmer (e.g., searching for
commitwill also findcommitted). - Pure Python: No C-extensions or heavy dependencies (like ElasticSearch). It just works.
📦 Installation
Method 1: Standard xpip (Recommended)
Open xonsh and run:
xpip install xontrib-history-looseene
Method 2: For Pipx / Unix-managed environments
If you installed xonsh via pipx or your system prevents direct pip usage, use this command to inject the plugin:
# If using pipx:
pipx inject xonsh xontrib-looseene
# Or using the raw subprocess method (if pipx is not available):
xonsh -c "import sys, subprocess; subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'xontrib-looseene'])"
⚙️ Configuration
To activate the backend, add this line to your .xonshrc (usually located at ~/.xonshrc or ~/.config/xonsh/rc.xsh):
xontrib load history_looseene
Restart your shell. You should see a message Looseene: History backend loaded.
⌨️ Usage
Interactive Search
Press Ctrl+R to open the interactive search window.
- Type to search.
- Up/Down arrows to navigate results.
- Enter to select the command and place it on your command line.
CLI Search
You can also search from the command line without the UI:
hsearch "docker run"
# or alias:
hs "git commit"
Maintenance (Compaction)
Looseene stores history in small "segments" on disk to ensure fast writing. Over time, these files can accumulate. To optimize performance and merge segments into one file:
history-compact
Recommendation: Run this once a week or if you notice the history folder (~/.xonsh/history_search_db) getting crowded.
🛠 Technical Details
- Storage:
~/.local/share/xonsh/looseene_history - Index Structure: Inverted index with delta-encoded postings lists.
- Backend: Custom implementation inheriting from
xonsh.history.base.History.
🤝 Contributing
Contributions are welcome!
- Fork the repo.
- Install in editable mode:
xpip install -e . - Submit a Pull Request.
📄 License
MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xontrib_history_looseene-1.0.0.tar.gz.
File metadata
- Download URL: xontrib_history_looseene-1.0.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce206af5eb1b78458a48e19dc26104847e0e44ec5f98cfb0ee924d38ae38de64
|
|
| MD5 |
162ab607ad6b2bb246f48d2bf19b93ca
|
|
| BLAKE2b-256 |
e71cfeaad62b88048ceb01c860dad081b039b4fb5b48d7c3b425f735fc498728
|
File details
Details for the file xontrib_history_looseene-1.0.0-py3-none-any.whl.
File metadata
- Download URL: xontrib_history_looseene-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d77838b73615b58aa4e1243e1c682660840cf6e691b50dd3848bc457ea49043
|
|
| MD5 |
3c1313f78473f65b63d7749e4e0a491d
|
|
| BLAKE2b-256 |
44565af3a1346b2cf66b33ea8935e6a16e5e1e6ee9dd87a9292cdb9d3e495498
|