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.
# 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