thefuck
Command-line error correction tool that suggests and fixes typos in previously executed shell commands
The Fuck is a command-line utility that automatically corrects errors in previously executed shell commands. After typing a command that fails due to typos, missing permissions, or incorrect syntax, users can simply type fuck to see suggested corrections. The tool analyzes the failed command and applies one of over 100 built-in rules to generate a corrected version.
The correction engine handles common mistakes across many tools including Git commands (fixing branch names, adding missing flags like --set-upstream), package managers (adding sudo for permission errors), file operations (correcting cat directory to ls directory), and typos in command names. Each suggestion is presented with confirmation options, allowing users to accept, reject, or cycle through alternatives using arrow keys.
The tool supports shell integration through aliases and can be configured to run corrections automatically without confirmation. It includes an experimental instant mode for faster performance and allows custom rules for specialized workflows. The Fuck works across multiple shells (Bash, Zsh, Fish, PowerShell) and integrates with the user's existing command history and environment.
Installation
# via Homebrew
brew install thefuck
# via apt
sudo apt update && sudo apt install python3-dev python3-pip python3-setuptools && pip3 install thefuck --user
# via pip
pip install thefuck
Alternatives & related tools
starship
Cross-shell prompt that displays contextual information about Git repos, programming languages, and system status
Powerlevel10k
Zsh prompt theme with an interactive configuration wizard, instant prompt at shell startup, Git status segments, and Powerlevel9k config compatibility.
zx
JavaScript/TypeScript library and runner that wraps child_process with a $`...` template tag for writing cross-platform shell scripts with escaped arguments.
Nushell
Structured data shell that treats commands and files as typed data rather than raw text streams
zoxide
Smart cd replacement that remembers frequently used directories for quick navigation
add a badge to your README
Maintain thefuck? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/thefuck?utm_source=badge)<a href="https://www.trmn.sh/tools/thefuck?utm_source=badge"><img src="https://www.trmn.sh/badge/thefuck.svg" alt="Featured on trmn" height="20"></a>