Skip to content

Latest commit

 

History

History
357 lines (284 loc) · 11 KB

File metadata and controls

357 lines (284 loc) · 11 KB

Command Reference

English | 简体中文

typo fix

Fix a command and print the corrected result to stdout.

typo fix "gut stauts"
typo fix "gut status && dcoker ps"
typo fix "gut status | grep main"
typo fix "typ doctro"
typo fix "typo hsitory lsit"

Useful flags:

  • -s <file>: read stderr from a file captured by shell integration.
  • --exit-code <n>: reuse the previous exit code as additional correction context.
  • --no-history: do not persist the accepted correction into history.
  • --alias-context <file>: read the shell correction context captured by shell integration.
  • --select: when candidate selection is enabled, show a terminal menu for multiple correction candidates.
  • --debug: print the fix trace to stderr without changing the corrected command written to stdout.
  • --debug=json: print the same trace as structured JSON with schema_version=1.
  • --trace-file <file>: write the structured JSON trace to a file without changing stdout.

--select is used by shell integrations. When candidates.enabled=true and at least two valid candidates are available, Typo opens a terminal menu showing up to candidates.limit choices. Press 1-9 to choose directly, use Up/Down plus Enter to choose the highlighted command, or press q/Esc to cancel. The menu is written to the terminal; stdout still contains only the selected command so shell buffers are updated with one command. If no interactive terminal is available, Typo falls back to the best candidate.

If typo fix --select ... prints only the best correction and no menu appears, check typo config get candidates.enabled. When it is false, Typo writes a stderr hint and keeps stdout limited to the best correction. Enable the menu with typo config set candidates.enabled true.

--alias-context is mainly used by typo init <shell> scripts. The context is temporary and session-local; it lets Typo expand aliases such as k=kubectl, match $VAR tokens against live environment variable names such as $HOME, and print the corrected result back with the original alias when that is safe.

Repeated accepted corrections can be promoted into silent user rules automatically once they reach the configured threshold. Set typo config set auto-learn-threshold 0 to disable this behavior.

--debug includes the current fix-chain visibility for:

  • matched stages and the before/after command for each pass
  • whether alias context, parser, history, subcommand, and other stages were used
  • whether Typo loaded additional commands from PATH
  • rejected high-scoring candidates, when any exist
  • auto-learn attempt, timeout, and reason details
  • total time, engine fix time, and auto-learn wait time

typo explain

Explain why Typo chose a correction. It uses the same fix trace as typo fix --debug, but prints a user-facing step list and does not record history or run auto-learn.

typo explain "gut stattus"
typo explain -s /tmp/typo-stderr "dcoker ps"
typo explain --alias-context /tmp/typo-aliases "k get podz"

The text output is meant for people and issue reports, so the exact wording can evolve. Use typo fix --debug=json or typo fix --trace-file <file> when tools need a stable structured payload.

typo learn

Teach Typo a personal correction pair.

typo learn "gst" "git status"

Use learn for day-to-day teaching. typo learn and typo rules add both add the same user rule, persist it to ~/.typo/rules.json, and clear conflicting history; learn is the simpler user-facing command.

It is especially useful as a last-resort override for outrageous typos that the shortest-path matcher may not infer, such as teaching gitsss -> git. For shell aliases, prefer the shell integration first: zsh, bash, fish, and PowerShell can pass the active alias context automatically. Use learn for aliases only when you want a persistent manual rule outside that live shell context.

typo config

Manage persisted runtime settings in ~/.typo/config.json.

typo config list
typo config get keyboard
typo config set keyboard dvorak
typo config reset
typo config gen
typo config gen --force

The current configurable keys are:

  • similarity-threshold
  • max-edit-distance
  • max-fix-passes
  • auto-learn-threshold
  • keyboard
  • history.enabled
  • candidates.enabled (default: false)
  • candidates.limit (default: 3, valid range: 1..10; this is a maximum, not a quota)
  • experimental.long-option-correction.enabled (Experimental; default: false)
  • rules.<scope>.enabled

typo rules

Manage user rules and builtin rule scopes.

typo rules list
typo rules add "gst" "git status"
typo rules remove "gst"
typo rules disable git
typo rules enable docker

Persistence details:

  • typo rules add and typo rules remove update user rules in ~/.typo/rules.json.
  • typo rules enable and typo rules disable update builtin scope switches in ~/.typo/config.json through rules.<scope>.enabled.

Builtin scopes currently available through rules.<scope>.enabled:

  • git, docker, npm, yarn, kubectl, cargo, brew, helm
  • terraform, python, pip, go, java, system

typo history

Inspect or clear accepted correction history.

typo history list
typo history clear

typo stats

Analyze accepted correction history with a lightweight summary.

typo stats
typo stats --since 7
typo stats --top 5

Useful flags:

  • --since <days>: only include history pairs whose last accepted timestamp falls within the last N days. The displayed count remains the cumulative count stored for that pair.
  • --top <n>: limit the number of typo pairs shown in the summary.

typo init

Print the shell integration script for a supported shell.

typo init zsh
typo init bash
typo init fish
typo init powershell

Supported shell names:

  • zsh
  • bash
  • fish
  • powershell
  • pwsh is accepted as an alias and normalizes to powershell

typo update

Update the running typo binary. When you invoke typo normally from PATH, the target and install method match what typo doctor reports.

# Build from the main branch for script installs; use brew for Homebrew installs
typo update

# Check current version, latest Release, and latest main commit
typo update --check

# Show what would happen without downloading, building, or calling brew
typo update --dry-run

# Install a specific Release tag for script installs
typo update --version 1.1.0

Supported update paths:

  • curl install.sh installs on macOS and Linux. typo update builds from the main branch by default and requires go. typo update --version main and typo update --version latest are accepted aliases for the same main-branch source build.
  • typo update --version <tag> installs a specific Release through the same script, for example typo update --version 1.1.0.
  • Homebrew installs run brew update and brew upgrade typo. Version pinning is not supported through typo update --version.

Unsupported update paths:

  • go install binaries. Use go install github.com/yuluo-yx/typo/cmd/typo@latest.
  • manual Release binaries. Reinstall with the script or Homebrew for managed updates.
  • Windows quick install. Re-run the PowerShell quick-install command.

typo doctor

Check the current environment, effective config, and shell integration hints.

typo doctor
typo doctor --json

The output includes:

  • shell detection
  • binary discovery
  • config directory state
  • shell integration guidance
  • install method detection for Homebrew, the curl install script, manual Release binaries, Windows quick install, and go install
  • whether typo update supports the detected install method
  • common shell setup misconfiguration warnings, such as fish using the wrong init command style
  • Go bin PATH guidance when installed through go install

Use --json when you need machine-readable diagnostics for issue reports or local tooling. The JSON output preserves the same exit-code behavior as the human-readable command. The shell.stderr_cache_supported field indicates whether the current shell integration can pass real stderr cache files to typo fix -s; fish currently reports false.

Example output:

{
  "schema_version": 1,
  "ok": false,
  "checks": [
    {
      "id": "config_directory",
      "name": "config directory",
      "status": "pass",
      "message": "/Users/alice/.typo",
      "path": "/Users/alice/.typo"
    },
    {
      "id": "config_file",
      "name": "config file",
      "status": "pass",
      "message": "/Users/alice/.typo/config.json",
      "path": "/Users/alice/.typo/config.json"
    },
    {
      "id": "typo_command",
      "name": "typo command",
      "status": "pass",
      "message": "available in PATH",
      "path": "/opt/homebrew/bin/typo"
    },
    {
      "id": "shell_integration",
      "name": "shell integration",
      "status": "fail",
      "message": "not loaded"
    },
    {
      "id": "install_method",
      "name": "install method",
      "status": "pass",
      "message": "Homebrew",
      "path": "/opt/homebrew/bin/typo"
    },
    {
      "id": "go_bin_path",
      "name": "Go bin PATH",
      "status": "skip",
      "message": "not a go install binary"
    }
  ],
  "shell": {
    "name": "fish",
    "config_file": "~/.config/fish/config.fish",
    "init_command": "typo init fish | source",
    "reload_command": "source ~/.config/fish/config.fish",
    "integration_loaded": false,
    "stderr_cache_supported": false,
    "alias_context_supported": true,
    "environment_context_supported": true
  },
  "config": {
    "dir": "/Users/alice/.typo",
    "dir_exists": true,
    "file": "/Users/alice/.typo/config.json",
    "file_exists": true,
    "settings": [
      {
        "key": "similarity-threshold",
        "value": "0.72"
      },
      {
        "key": "max-edit-distance",
        "value": "2"
      },
      {
        "key": "history.enabled",
        "value": "true"
      }
    ]
  },
  "install": {
    "method": "Homebrew",
    "detail": "/opt/homebrew/bin",
    "path": "/opt/homebrew/bin/typo",
    "action": "brew update && brew upgrade typo",
    "update_supported": true
  },
  "go_bin_path": {
    "dir": "/Users/alice/go/bin",
    "typo_in_go_bin": false,
    "configured": false
  },
  "actions": [
    {
      "id": "enable_shell_integration",
      "command": "typo init fish | source"
    }
  ]
}

The JSON may include local paths from your machine. Redact user names or paths before posting it publicly if they are sensitive.

typo version

Print the current version, commit, and build date when available.

typo version

typo uninstall

Remove local Typo config files and print any remaining manual cleanup steps.

typo uninstall

Related docs