Skip to content

Repository files navigation

cmdtrail — find the command that worked

Private, cross-platform terminal memory for Linux, macOS, and Windows.

CI · MIT · Privacy · Changelog

Cmdtrail records terminal command metadata and helps you find what worked before. It keeps its database on your machine, redacts common secrets before storage, and never executes an old command without you explicitly copying it.

Cmdtrail fix command demo

Why

Shell history remembers text. It usually does not remember whether the command worked, how long it ran, which project it belonged to, or where you ran it.

Cmdtrail records that context so these questions have useful answers:

cmdtrail failed
cmdtrail search postgres
cmdtrail where uvicorn
cmdtrail project
cmdtrail fix

cmdtrail fix is deterministic. It compares the latest failure with successful commands already stored on your machine. There is no model call and no cloud dependency.

Install from source

Cmdtrail currently ships as an alpha. Rust 1.85 or newer is required.

git clone https://github.com/lemkyz/cmdtrail.git
cd cmdtrail
cargo install --path . --locked
cmdtrail init zsh

Replace zsh with bash, fish, or powershell. The init command installs both command recording and tab completion. Running it again is safe; existing Cmdtrail blocks are upgraded in place.

Open a new terminal, then verify the installation:

cmdtrail doctor
false
cmdtrail failed

Commands

cmdtrail last                 Show the latest recorded command
cmdtrail failed               Show recent failures
cmdtrail search <query>       Search commands and project context
cmdtrail fix                  Find a previous successful command
cmdtrail where <query>        Find where a command last succeeded
cmdtrail project              Show useful commands for this project
cmdtrail project --all        Include setup blocks and navigation commands
cmdtrail stats                Show local command statistics
cmdtrail rerun <id> --raw     Print a stored command; never execute it
cmdtrail pause                Stop recording
cmdtrail resume               Resume recording
cmdtrail status               Show database and recording status
cmdtrail doctor               Check the binary, database, and shell setup
cmdtrail init <shell>         Install hooks and completions

What gets stored

For each accepted command, Cmdtrail stores:

  • redacted command text
  • working directory
  • start time, finish time, and duration
  • exit code
  • shell and session identifier
  • operating system
  • executable name
  • Git repository, root, and branch when available

Command output is not captured.

The database lives in the platform's standard local application-data directory:

  • Linux: ~/.local/share/cmdtrail/cmdtrail.db
  • macOS: ~/Library/Application Support/dev.lemkyz.cmdtrail/cmdtrail.db
  • Windows: %LOCALAPPDATA%\lemkyz\cmdtrail\data\cmdtrail.db

Exact paths are shown by cmdtrail status.

Privacy

Redaction happens before SQLite insertion. Built-in rules cover common API-key assignments, bearer tokens, password and token flags, database password flags, Docker login passwords, GitHub tokens, and sk- style tokens.

Sensitive tools are ignored by default:

[privacy]
ignore_commands = ["pass", "gpg", "vault"]
ignore_directories = []

Pause recording at any time:

cmdtrail pause

Read the full privacy model before using Cmdtrail in an environment with unusual secret formats.

Output and color

Cmdtrail uses amber section headings, cyan context labels, green success markers, and red failure markers. Color is automatically disabled when output is redirected.

It also respects:

NO_COLOR=1 cmdtrail failed
CLICOLOR=0 cmdtrail stats

Platform support

Platform Recording shell support CI
Linux Zsh, Bash, Fish, PowerShell Yes
macOS Zsh, Bash, Fish, PowerShell Yes
Windows PowerShell Yes

Git Bash and Nushell are not part of the current alpha.

Development

cargo fmt --all -- --check
cargo check --all-targets
cargo test --all-targets
cargo build --release

To inspect generated integration scripts:

cmdtrail hook zsh
cmdtrail completions zsh

The visual rules are documented in docs/DESIGN.md.

Current limits

  • No command-output capture
  • No cloud account or synchronization
  • No natural-language model integration
  • No automatic execution of stored commands
  • Matching is intentionally conservative and may return no suggestion

License

MIT

About

Private, cross-platform terminal memory that finds the command that worked.

Resources

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages