dt lets you run shell commands, record their outputs over time, and compare results between runs. It provides a simple interactive selector (skim‑style fuzzy filtering) and colored diffs.
Status: Not production‑ready yet. Interfaces, data layout and behavior may change frequently.
状态:当前为非正式发布版本,尚未达到生产可用级别;接口、数据结构与行为可能会频繁变更。
Generated previews:
- Build (debug):
cargo build - Build (release):
cargo build --release - Run examples:
cargo run -- run "ls | head -5"cargo run -- diff "ls | head -5"# interactive selector + preview/diffcargo run -- ls# non-interactive listing (use --json for scripts)
dt run <COMMAND>
- Executes the command (via
sh -c) and records stdout, stderr, exit code, duration, and metadata. - Options:
-d, --diff-with <TARGET>: After recording, immediately show a diff. TARGET can be:first: Compare with the earliest executionlast: Compare with the most recent execution<CODE>: Compare with a specific short code (e.g.,a,b,ab)
When a command includes pipes (|), redirection (>, <), or logical operators (&&, ||), wrap the entire command in single or double quotes so the outer shell does not pre-parse it.
# Recommended
dt run 'ls -l | wc'
# Incorrect: outer shell captures the pipeline first
dt run ls -l | wcdt diff [OPTIONS] [COMMAND]
- Interactive selection and comparison of historical runs.
- Options:
--max-shown <N>: Limit selector viewport rows.--linewise: Compare strictly line-by-line (no cross-line alignment)
dt ls [QUERY] [--json]
- Non-interactive listing of stored command runs, sorted by most recent.
- Accepts optional substring or subsequence
QUERYfilters; omit to show all. - Use
--jsonfor machine-readable output (records including timestamps and short codes).
dt parse [FILE] [--json]
- Parse a Bash snippet or file into an AST using tree-sitter-bash.
- If
FILEis omitted, reads from STDIN. Use--jsonto output the AST as JSON; otherwise prints an outline.
dt clean <SUBCOMMAND>
- Clean records by search, by file, or all.
- Subcommands:
search [QUERY]: Delete records matching QUERY (substring or subsequence). If missing, opens an interactive selector.file [PATH]: Delete records related to PATH (matching working directory, absolute/relative occurrences in commands).all: Delete all records.
- Safety confirmations:
- All deletes require confirmation: type
YES. - Type
ALLto confirm and skip further confirmations during this dt process (session-wide).
- All deletes require confirmation: type
Run dt <COMMAND> --help to see detailed usage for any subcommand.
- Skim‑style fuzzy search for interactive selection (no external
fzfrequired) - Colored diffs using
similar - Preview scrollbar; help overlay (
h/?); Enter-to-diff from either pane - Toggle preview target:
oor←/→switches stdout/stderr - Per-command short codes for quick reference
- Multi-language messages (English/Chinese) with English as default in code and docs
- Packaging scripts and usage docs
- Non-interactive listing for CI:
dt ls [QUERY] [--json] - Safe cleaning with previews and confirmations; dry-run available for
dt clean search|file
- Non-interactive listing for CI:
Config file is at ~/.dt/config.toml. Environment variables can override display settings.
[storage]
max_retention_days = 365
auto_archive = true
[display]
max_history_shown = 10
language = "auto" # auto/en/zh
tui_mode = "interactive" # interactive|simple
alt_screen = true # Use alternate screen in interactive mode (vim-like)Environment overrides:
DT_TUI=interactive|simple # force TUI mode
DT_ALT_SCREEN=1 # use alt screen in interactive mode (prefer 1)
- Left panel shows compact items:
code:<a..z> time:<YYYY-MM-DD HH:MM:SS> - Right panel preview:
- Header shows
Path: …andPreview: stdout|stderr - Content area supports vertical scrolling with a visible scrollbar
- Press
oor←/→to toggle stdout/stderr
- Header shows
- Bottom status bar summarizes keys; press
hor?for an overlay of preview shortcuts - Fuzzy filter: type to filter; substring/prefix/number priority plus skim‑style fuzzy fallback
- Navigation:
j/kor arrow keys; paging:PgUp/PgDnorCtrl+f/Ctrl+b(selection list),Space/fdown,b/Backspaceup (preview); half pages:d/u; top/bottom:g/G,Home/End - Selection:
Space/Entertoggle the focused item (also works in preview);Tabenters preview; arrow keys in preview jump back to the list; once two items are selected,Enterruns the diff immediately - Back/quit from preview:
q; quit app:Q; globalEscbacks/exits
- Records live under
~/.dt/records/<command_hash>/ - Index file
~/.dt/indexreferences all records - Optional yearly archives
~/.dt/index_YYYY.jsonwhenauto_archive = true
- Commands run via
sh -c. Do not pass untrusted input automatically. - Examples in tests and docs may show pipelines; quote commands appropriately.
Generate demo GIFs locally using VHS (not stored in git):
brew install vhs # or follow VHS installation guide
make gallery # renders docs/vhs/*.tape to docs/gallery/*.gif
open docs/gallery # view generated GIFs locallyTapes:
docs/vhs/dt-diff.tape→docs/gallery/dt-diff.gifdocs/vhs/dt-run.tape→docs/gallery/dt-run.gif
- This repo publishes a PR to
luw2007/homebrew-tapon every GitHub Release via the workflowupdate-tap.yml. - Configure a repo secret
TAP_PUSH_TOKENwith write access to the tap repo. Optional variables:TAP_REPO(defaultluw2007/homebrew-tap),TAP_DEFAULT_BRANCH(defaultmain). - For manual steps and local verification, see
docs/homebrew_formula.md.
MIT. See LICENSE for details.
Third‑party licenses are in THIRD_PARTY_NOTICES.md (e.g., fuzzy‑matcher’s MIT license).

