Skip to main content

fast small embed history backend

Project description

xontrib-history-looseene
A lightning-fast, compressed, inverted-index history backend for xonsh shell.

License PyPI

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 commit will also find committed).
  • 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-history-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-history-looseene'])"

⚙️ Configuration

To activate the backend, add this line to your .xonshrc (usually located at ~/.xonshrc or ~/.config/xonsh/rc.xsh):

xontrib load 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!

  1. Fork the repo.
  2. Install in editable mode: xpip install -e .
  3. 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

xontrib_history_looseene-1.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xontrib_history_looseene-1.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file xontrib_history_looseene-1.1.0.tar.gz.

File metadata

  • Download URL: xontrib_history_looseene-1.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for xontrib_history_looseene-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bc227f3109e980436c81573011c210254f717bff1271601c21ee14480b4dab75
MD5 029667204c4a88bdee0fc97ddd8feba4
BLAKE2b-256 014860534c491b4d16534ea3e47ce332ecbbcec506937071ae1769d390ee5d40

See more details on using hashes here.

File details

Details for the file xontrib_history_looseene-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_history_looseene-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 711ff852a088d6274504e3577a577aee9dac03e0ce04f625b0808b24c87951d0
MD5 22f290a6999a4093f56f1293d1d1adb2
BLAKE2b-256 79185e002f979f12e1861192fd13d18e7007f806cf9ac4cbea29660ca90e55c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page