Skip to content

sessions, search, export, stats, undo, diff, and record

asksh sessions [--all] [--limit N]

Lists recorded sessions from ~/.local/share/asksh/sessions.db.

Flag Default Description
--all false Include archived sessions
--limit 20 Maximum number of sessions to print

asksh search <query> [--limit N]

Runs an FTS5 full-text search across recorded session events.

Flag Default Description
--limit 20 Maximum number of matching hits to print

asksh export <session-id> [--format md|sh]

Exports a session transcript as Markdown (md or markdown, default) or a shell script (sh, bash, or shell).

asksh stats [--session id]

Prints request counts, token totals (Prompt, Cached, Completion, Total), and estimated USD cost for all sessions or a single --session <id>.

Cost estimates use a built-in prefix pricing table for Claude, OpenAI, and Gemini models. Models outside that table record $0.0000.

asksh diff [--session id]

Prints unified diffs (3 context lines) for pre-edit file snapshots stored in ~/.local/share/asksh/snapshots/<session-id>/. Defaults to the most recent session with snapshots if --session is omitted.

asksh undo [--session id] [--file path]

Atomically restores snapshotted files from ~/.local/share/asksh/snapshots/<session-id>/.

Flag Description
--session Session ID to restore from (defaults to the most recent snapshot session)
--file Restore only the specified file instead of all snapshotted files in the session

asksh record

asksh record --shell <shell> --exit <code> --duration <ms> --cmd <command> [--stderr <tail>]

Records a shell command execution event and ambient directory context. If askshd is running, asksh record sends the event over the daemon Unix socket (500ms timeout); otherwise it writes directly to sessions.db. --stderr is truncated to the trailing 4,096 bytes.

Blank commands are ignored, and asksh init hooks call this command automatically.