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

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"

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.

🤝 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.1.tar.gz (53.5 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.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xontrib_history_looseene-1.1.1.tar.gz
  • Upload date:
  • Size: 53.5 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.1.tar.gz
Algorithm Hash digest
SHA256 e4a0cb4920457d59f5b9920cc53e2bf2827e9534d718e1e50ccbbbbbbd8f9528
MD5 ae45f85a06a5a453e8b35972aca135b8
BLAKE2b-256 012a66c28d340bad74cb99d1e955188c12236a0466bbdd9a56c02ed9e6ba0f87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xontrib_history_looseene-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfff1959455511d048ab7efc669df802719a8d51483eed5a53d50deca700f101
MD5 60c3b436be54715f21d068898e4c9660
BLAKE2b-256 6efc037a0fa77e31cf378ca60f1e4cfe11dfe83868a28ff46a3edbae31fea10a

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