From db1c2b8ce214bc555b8aa21114c6614e9071bf34 Mon Sep 17 00:00:00 2001 From: twells46 <173561638+twells46@users.noreply.github.com> Date: Wed, 1 Apr 2026 15:54:58 -0500 Subject: Add simple shell executable --- README.md | 17 ++++++++++++----- bin/cheat | 18 ++++++++++++++++++ cards.jsonl | 1 + cheat.db | Bin 118784 -> 118784 bytes 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100755 bin/cheat diff --git a/README.md b/README.md index 65f5a36..c611a0a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,13 @@ Then run a query like this: python query_index.py "get free disk space" ``` +Or install the wrapper script and use `cheat` from anywhere: + +```sh +ln -sf "$PWD/bin/cheat" ~/.local/bin/cheat +cheat "get free disk space" +``` + To add commands, add to `./cards.jsonl` and rebuild the index: ```sh @@ -36,19 +43,19 @@ python query_index.py --serve Then keep using the same query command: ```sh -python query_index.py "get free disk space" +cheat "get free disk space" ``` To run the server in the background: ```sh -nohup python query_index.py --serve >/tmp/cheat.log 2>&1 & +nohup cheat --serve >/tmp/cheat.log 2>&1 & ``` Useful controls: ```sh -python query_index.py --status -python query_index.py --reload -python query_index.py --stop +cheat --status +cheat --reload +cheat --stop ``` diff --git a/bin/cheat b/bin/cheat new file mode 100755 index 0000000..4988312 --- /dev/null +++ b/bin/cheat @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_PATH="$(readlink -f "$0")" +SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)" +REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" + +if [[ -x "$REPO_DIR/.venv/bin/python" ]]; then + PYTHON_BIN="$REPO_DIR/.venv/bin/python" +elif [[ -x "$REPO_DIR/venv/bin/python" ]]; then + PYTHON_BIN="$REPO_DIR/venv/bin/python" +else + echo "No project virtualenv found at $REPO_DIR/.venv or $REPO_DIR/venv" >&2 + exit 1 +fi + +cd "$REPO_DIR" +exec "$PYTHON_BIN" "$REPO_DIR/query_index.py" "$@" diff --git a/cards.jsonl b/cards.jsonl index ed19844..cb5c89c 100644 --- a/cards.jsonl +++ b/cards.jsonl @@ -29,3 +29,4 @@ {"id":"git_status_short","intent":["show git status briefly","check repo state","see changed files in git","short git status"],"command":"git status --short","alternatives":["git status"],"explanation":"Shows tracked and untracked file changes in a compact format.","requires":["git"],"packages":{},"tags":["git","status","repo"],"platform":["linux","macos"],"shell":["bash","zsh","fish"],"safety":"safe-readonly"} {"id":"git_log_oneline_graph","intent":["show concise git history","see commit graph briefly","inspect recent commits compactly","git log one line graph"],"command":"git log --oneline --graph --decorate -n 20","alternatives":[],"explanation":"Shows a compact decorated commit graph for recent history.","requires":["git"],"packages":{},"tags":["git","history","commits"],"platform":["linux","macos"],"shell":["bash","zsh","fish"],"safety":"safe-readonly"} {"id":"git_show_changed_files","intent":["show files changed in last commit","list files changed by commit","see modified files from HEAD","inspect changed paths in commit"],"command":"git show --name-only --oneline HEAD","alternatives":["git diff --name-only HEAD~1 HEAD"],"explanation":"Shows the last commit summary and the files it changed.","requires":["git"],"packages":{},"tags":["git","diff","files","commits"],"platform":["linux","macos"],"shell":["bash","zsh","fish"],"safety":"safe-readonly"} +{"id":"systemd_failed_units","intent":["show failed systemd units","systemctl failed units","view systemd failed services"],"command":"sudo systemctl list-units --state failed","alternatives":["sudo systemctl list-units --failed"],"explanation":"Show all units systemd has in memory, filtering the failed ones.","requires":["systemctl"],"packages":{},"tags":["systemctl","failed","service","unit"],"platform":["linux"],"shell":["bash","zsh","fish"],"safety":"safe-readonly"} diff --git a/cheat.db b/cheat.db index f3d4cb5..f174df6 100644 Binary files a/cheat.db and b/cheat.db differ -- cgit v1.2.3