About
Typo -- Auto-correct mistyped shell commands🛠️
Developer ToolsWhat you can do
- Correct commands in place from zsh, bash, fish, and PowerShell.
- Fix top-level commands, subcommands, compound commands, pipes, and runtime errors when stderr context is available.
- Use active shell aliases and simple wrappers as correction context, such as k=kubectl.
- Correct mistyped environment variable names from the current shell context, such as $HOEM to $HOME.
Measured star growth
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +1
- in 1 month
- +1
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Original
Fix mistyped shell commands from the command line.
English | 简体中文
Typo is a command auto-correction tool written in Go. Type a command, press Esc Esc, and Typo replaces the command line with a likely correction.
TheFuck?
There is already TheFuck, so why write Typo?
There were a few reasons:
- TheFuck is no longer actively maintained, and issues and PRs are not being handled. This is the main 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.
Highlights
- Correct commands in place from zsh, bash, fish, and PowerShell.
- Fix top-level commands, subcommands, compound commands, pipes, and runtime errors when stderr context is available.
- Use active shell aliases and simple wrappers as correction context, such as
k=kubectl. - Correct mistyped environment variable names from the current shell context, such as
$HOEMto$HOME. - Teach personal corrections with
typo learn; Typo stores user rules and history under~/.typo. - Install native binaries on macOS, Linux, WSL, and Windows PowerShell 7+.
- Written in Go, with binary installs that do not require an external runtime.
Quick Start
Install with Homebrew using the project's own tap:
brew tap yuluo-yx/typo https://github.com/yuluo-yx/typo
brew install typo
Or manage the installation with mise:
mise use -g github:yuluo-yx/typo@latest
mise exec -- typo version
Or install on macOS / Linux with the script:
curl -fsSL https://raw.githubusercontent.com/yuluo-yx/typo/main/tools/scripts/install.sh | bash
On Windows PowerShell 7+:
iwr -useb https://raw.githubusercontent.com/yuluo-yx/typo/main/tools/scripts/quick-install.ps1 | iex
For upgrades, checksum verification, and platform-specific notes, see Quick Start.
Shell Integration
Install Typo first, then add the matching init command to your shell config.
| Shell | Config file | Init command |
|---|---|---|
| zsh | ~/.zshrc |
eval "$(typo init zsh)" |
| bash | ~/.bashrc |
eval "$(typo init bash)" |
| fish | ~/.config/fish/config.fish |
typo init fish | source |
| PowerShell 7+ | $PROFILE.CurrentUserCurrentHost |
Invoke-Expression (& typo init powershell | Out-String) |
Restart your terminal and check the setup:
typo doctor
Now type a command with a mistake and press Esc Esc:
gti stauts
# after pressing Esc Esc
git status
Shell integration also understands active aliases in the current session:
alias k=kubectl
k lgo
# after pressing Esc Esc
k logs
It also corrects mistyped environment variable names from the current shell context:
cd $HOEM/project
# after pressing Esc Esc
cd $HOME/project
When git pull has no upstream, typo preserves the pull and its options and adds
--set-upstream <remote> <branch> using verified repository references. When Git
reports divergent branches without a reconciliation strategy, typo suggests
git pull --rebase, preserving existing arguments. Explicit --rebase, -r,
--no-rebase, and --ff-only choices are kept. A push rejected because the
tracked remote branch moved ahead becomes git pull --rebase && git push, a
git push origin without upstream is completed with --set-upstream, a
mistyped branch in git checkout/git switch is replaced with the single
closest existing branch, and "Author identity unknown" suggests the unset
git config --global user.name/user.email key for you to fill in. These
corrections recognize localized Git output by matching Git's untranslated
suggested commands and verifying the repository state. Suggestions are placed
in the command buffer for you to execute; generating one does not change Git
history or repository configuration.
CLI Commands
Use the CLI directly when you want explicit output or custom rules:
typo fix "gut status && dcoker ps"
typo learn "gst" "git status"
typo config list
typo config set candidates.enabled true
typo config set candidates.limit 3
typo rules list
typo history list
With candidate selection enabled, shell integrations show up to the configured
number of valid correction candidates after Esc Esc. Choose with 1-9, or
move with Up/Down and press Enter.
See Command Reference for all subcommands and flags.
Documentation
- Quick Start
- Command Reference
- Usage Examples
- Stability Contract
- Troubleshooting
- Upgrading from 0.x
- How Typo Works
Development
Development requires Go 1.26.3 and GNU Make.
make setup
make test-unit
make test
make ci
Use make test-unit for fast local Go feedback. Use make test and make ci
before submitting changes.
Before submitting changes, make sure the Git pre-commit hooks pass. See Contributing for coding standards, test expectations, and commit message format.
Release Integrity
The current GitHub Release workflow publishes a checksums.txt file with SHA-256 hashes for all platform binaries. Some historical Releases may not include that file.
The macOS/Linux install script and Windows quick-install script verify downloaded Release binaries against checksums.txt when it is available.
If you install from release assets directly, verify the downloaded binary against checksums.txt when it is available before placing it on your PATH.
For step-by-step verification commands, see Quick Start.
Contributors
Thanks to everyone who helped build Typo.
License
MIT
Explore related projects
Loading…