Screenshot your screen from the terminal, pull out the text and links, and search them later.
pip install "contextbox[ocr] @ git+https://github.com/jayhemnani9910/contextbox.git"OCR also needs the Tesseract binary, and on Linux a screenshot tool. On Debian or Ubuntu:
sudo apt install tesseract-ocr scrotcontextbox capture # screenshot, OCR, find URLs, save
contextbox list # what you have saved
contextbox search login # find captures by any word that was on screen
contextbox stats # count and database sizeAdd --log-level error before the command to hide the log lines.
Everything is stored in contextbox.db in the folder you run it from, and each capture also writes a JSON file and the PNG to artifacts/:
"extracted": {
"text": "TODO: fix login timeout in auth/session.py\nSee https://docs.python.org/3/library/sqlite3.html ...",
"urls": ["https://docs.python.org/3/library/sqlite3.html"]
}Move captures between machines with export and import:
contextbox export --all-contexts --format json -o captures.json # also csv, txt, markdown
contextbox import captures.jsoncontextbox ask and contextbox summarize are in the CLI but not implemented yet. They print a message and exit.
capturetakes a screenshot withscrot,gnome-screenshotorflameshoton Linux,screencaptureon macOS, orpyautoguion Windows.pytesseractreads the text out of the PNG. If OCR is not installed or finds no text, it saves basic system info instead (time, platform, working directory, and theUSER,HOME,SHELL,PATHandVIRTUAL_ENVvariables).- A regex pulls URLs out of the text.
- The capture goes into SQLite, and
searchis a SQLLIKEmatch over the stored text, window titles and URLs.
I have run it on Linux. The macOS and Windows paths are in the code but untested.
from contextbox import ContextBox
app = ContextBox({"database": {"db_path": "contextbox.db"}})
context_id = app.capture_context({"active_window": {"title": "Terminal"}, "clipboard": "copied text"})
results = app.database.search_contexts("copied")
context = app.get_context(context_id)There is also a Wikipedia extractor:
from contextbox.extractors import extract_wikipedia_content
page = extract_wikipedia_content("https://en.wikipedia.org/wiki/SQLite")
page["metadata"]["title"] # "SQLite"contextbox.llm has a client for GitHub Models (pip install "contextbox[llm] @ git+...", then set GITHUB_TOKEN). The default model is gpt-4o-mini. The CLI does not use it yet.
git clone https://github.com/jayhemnani9910/contextbox.git
cd contextbox
pip install -e ".[dev,ocr]"
pytestSee CONTRIBUTING.md.
MIT
