thefuck
Magnificent app which corrects your previous console command.
The Fuck, a tool that fixes your last command
The Fuck matches a failed console command against a rule and runs a corrected version, with options to skip confirmation for users in a hurry.
What it does
The README describes The Fuck as an app that corrects errors in previous console commands, inspired by a tweet. It sits in your shell as an alias. A --yeah flag, or -y, or --hard if you are frustrated, runs the fixed command without asking for confirmation.
Install and uninstall
Setup means adding a line to a startup script like .bashrc or .zshrc, and the README notes changes only show up in a new shell session unless you source the config. Removal reverses the steps, deleting the alias line and letting a package manager take out the binaries.
How the matching works
Given the previous command, the tool tries to match it against a rule. On a match it builds a corrected command from that rule and executes it. A large set of rules ships enabled by default, covering everyday mistakes across adb, cargo, cat, cd, apt, brew, pacman, and more.
Git and root
Two rules stand out. git push force adds --force-with-lease to a push, and rm root adds --no-preserve-root to a destructive rm -rf /. Both only fire on the command shape they are built for.
Writing your own rules
Custom rules live in a config directory as Python files, and each must define two functions. Optional variables control whether the rule is enabled by default, whether it needs command output, and its priority. A settings object pulls from a settings file plus environment values.
Editorial conclusion
Everything here follows the README's own account of the tool, its default rules, and its settings. No attempt was made to run it, so nothing is verified beyond the documentation.
Community notes