Hysen Labs
Open-source project
nvbn/thefuck avatar
nvbn

thefuck

Magnificent app which corrects your previous console command.

97,708 stars3,960 forksPythonMIT
01
DEEP OPEN-SOURCE ANALYSIS

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.

02
DEEP OPEN-SOURCE ANALYSIS

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.

03
DEEP OPEN-SOURCE ANALYSIS

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.

04
DEEP OPEN-SOURCE ANALYSIS

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.

05
DEEP OPEN-SOURCE ANALYSIS

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.

06
DEEP OPEN-SOURCE ANALYSIS

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.

07
DEEP OPEN-SOURCE ANALYSIS

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.

08
DEEP OPEN-SOURCE ANALYSIS

Official sources

09
Community notes

Community notes