Command Auto-Correction Tool

English | 简体中文
Press Esc Esc to fix typos automatically.
Why Typo?
There were a few reasons:
- TheFuck is no longer actively maintained, and issues and PRs are not being handled. This was the biggest reason.
- TheFuck is tied to Python versions, so installation took extra effort.
- TheFuck does not handle commands containing
"" very well.
For these reasons, I wrote Typo in Go. It is not a translation of TheFuck. It is built from scratch.
Quick Start
Install via Homebrew
Coming soon.
Or via script
curl -fsSL https://raw.githubusercontent.com/yuluo-yx/typo/main/tools/scripts/install.sh | bash
The script downloads a prebuilt Release binary by default. Go is only required when building from the main branch source.
Optional arguments:
# Install the latest release explicitly
curl -fsSL https://raw.githubusercontent.com/yuluo-yx/typo/main/tools/scripts/install.sh | bash -s -- -s latest
# Install a specific release (semver)
curl -fsSL https://raw.githubusercontent.com/yuluo-yx/typo/main/tools/scripts/install.sh | bash -s -- -s 0.2.0
# Build from the main branch source (requires Go)
curl -fsSL https://raw.githubusercontent.com/yuluo-yx/typo/main/tools/scripts/install.sh | bash -s -- -b
Note: The install script currently supports macOS and Linux.
Run
# Add to ~/.zshrc
eval "$(typo init zsh)"
Restart your terminal, then press Esc Esc after a typo. (No Enter can!)
Commands
More usage examples: use
typo fix - Fix a command
typo fix "gut stauts" # → git status
typo fix "gut status && dcoker ps" # → git status && docker ps
typo fix "gut status | grep main" # → git status | grep main
typo learn - Learn a correction
typo learn "gst" "git status" # Recommended for recurring personal fixes
Use learn for normal day-to-day teaching. typo learn and typo rules add both add the same user rule and clear conflicting history; learn is the simpler user-facing command, while rules add fits explicit rule management alongside rules list and rules remove.
typo rules - Manage rules
typo rules list # List all rules
typo rules add "gst" "git status" # Same effect as `learn`, but in rule-management flow
typo rules remove "gst" # Remove rule
typo history - View correction history
typo history list # Show past corrections
typo history clear # Clear history
typo doctor - Diagnose issues
typo doctor # Check configuration status
Other commands
typo init zsh # Print shell integration script
typo version # Show version
typo uninstall # Remove local config and print remaining cleanup steps
How It Works
Typo corrects commands in this priority:
- Error Parsing - Extracts command-specific suggestions from stderr when available
- User Rules - Applies learned and user-defined overrides first
- History - Reuses previously accepted corrections
- Built-in Rules - Applies bundled typo mappings
- Subcommand Repair - Tries known tool subcommands before falling back further
- Edit Distance - Uses keyboard-aware fuzzy matching with lower cost for adjacent-key substitutions
Supported Error Parsing
- git:
did you mean..., missing upstream, etc.
- docker: Unknown command suggestions
- npm: Command not found suggestions
-s <file> tells typo fix to read stderr from a file. This is mainly for parser-based fixes and is usually passed automatically by the zsh integration after a command fails.
Examples:
typo fix -s git.stderr "git remove -v" # → git remote -v
typo fix -s git.stderr "git pull" # → git pull --set-upstream origin main
typo fix -s docker.stderr "docker psa" # → docker ps
typo fix -s npm.stderr "npm isntall react" # → npm install react
Smart Subcommand Correction
Automatically parses tool subcommands for intelligent suggestions:
typo fix "git stattus" # → git status
typo fix "docker biuld" # → docker build
Supported: git, docker, npm, yarn, kubectl, cargo, go, pip, brew, terraform, helm
Configuration
Files stored in ~/.typo/:
~/.typo/
├── rules.json # Learned and user-defined rules
├── usage_history.json # Correction history persisted from accepted/direct fixes
└── subcommands.json # Subcommand cache
Build
make build # Build for current platform
make build-all # Build for all platforms
make install # Install typo to Go BIN
make test # Run tests
make coverage # Run tests with coverage
make lint # Run linter
Thanks to everyone who helped build Typo.
License
MIT