Skip to main content

fast small embed history backend

Project description

xontrib-history-looseene
A smart, lightning-fast, and feature-rich history backend for the xonsh shell.

License PyPI

Looseene transforms your shell history into a mini search engine. It replaces xonsh's standard history with a compressed, inverted-index backend, enabling instant and relevant search results, even across massive command logs.

Looseene UI

🚀 Features

  • Interactive Search (Ctrl+R): A powerful full-screen UI to navigate, search, and manage your history.
  • Command Execution Counts: Automatically tracks how often you run each command, helping you find your most-used tools.
  • Custom Comments: Annotate commands with comments for context (F3 in UI or hs-comment command).
  • Prefix Search & Highlighting: Find commands by typing parts of a word (e.g., dist finds distribution), with matches highlighted in yellow.
  • Smart & Fast: Uses the BM25 ranking algorithm to find the most relevant commands, not just the most recent. Data is stored in compressed binary segments using mmap, zlib, and struct for instant access.
  • Smart Context Search: Commands executed in the current directory are ranked higher.
  • Fuzzy Search: Tolerates typos (e.g., gti statsu finds git status).
  • Analytics: Visualize your most used commands with hs-stats.
  • Pure Python: No C-extensions or heavy dependencies. It just works.

📦 Installation

Open xonsh and run:

xpip install xontrib-history-looseene

⚙️ Configuration

To activate the backend, add this line to your .xonshrc file (e.g., ~/.config/xonsh/rc.xsh):

xontrib load looseene

Restart your shell. You should see a message Looseene: History backend loaded....

⌨️ Usage

Interactive Search (Ctrl+R)

Press Ctrl+R to open the interactive search window. What you've already typed on the command line will be used as the initial search query.

  • Type to search in real-time.
  • Up/Down Arrows to navigate results.
  • Enter to select a command and place it on your command line.
  • F3 to add or edit a comment for the selected command.
  • Ctrl+C / Esc to exit; the text you typed in the search bar will be preserved on your command line.

Adding Comments (hs-comment)

You can annotate commands with comments for better context, either interactively or from the command line.

  1. Interactively (F3): Press F3 while in the Ctrl+R menu to open a dialog and add a comment to the selected command.
  2. Via CLI: Use the hs-comment alias.
# Usage: hs-comment <partial_command_to_find> "<your comment>"
hs-comment "docker-compose up" "start project services"

Statistics (hs-stats)

View a bar chart of your top 10 most frequently used commands:

hs-stats

CLI Search

You can also search directly from the command line without the UI:

# Full command
hsearch "docker run"

# Alias
hs "git commit"

Maintenance (Compaction)

Looseene stores history in small "segments" on disk for fast writing. Over time, these can accumulate. To merge all segments into a single, optimized file and finalize metadata (counts and comments):

history-compact

Recommendation: Run this command occasionally to keep performance high.

🛠 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.

🛠 Development & Testing

Looseene is designed to be lightweight and dependency-free. You can verify the core search engine logic using only the Python standard library.

Running Core Tests (Zero Dependencies)

No need to install pytest. Simply run the test script directly with Python:

python3 tests/test_native.py

Running Integration Tests

If you have pytest and xonsh installed and want to run the full suite (including xontrib loading tests):

pytest

🤝 Contributing

Contributions are welcome!

  1. Fork the repo.
  2. Install in editable mode: xpip install -e .
  3. Ensure tests pass: python3 tests/test_native.py
  4. 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.3.0.tar.gz (57.1 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.3.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xontrib_history_looseene-1.3.0.tar.gz
  • Upload date:
  • Size: 57.1 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.3.0.tar.gz
Algorithm Hash digest
SHA256 9e9852d18a11bfb6a67369e7898d1c18030291340551f02edf3efdcb4c2bc1d9
MD5 d23c15840a66b8308eddf7a532237f14
BLAKE2b-256 78ae80b0a369673a4a8c3bfee9e71653c5569529ff5eb1062da43ae0aebe1428

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xontrib_history_looseene-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42e060eb8321e48ecea204c74d35bc919760bfae4d1f2667aeb033fb23512534
MD5 3e31b6c0f54cec2880c020065a48babd
BLAKE2b-256 58a2e823f57c8045b3f9bff89a514264b1e0e48a26600fa87f69adf21edb704d

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