The Fuck: A Rule-Based Command-Line Corrector for Your Typos
Magnificent app which corrects your previous console command.
At a glance
- What is it?
- The Fuck is a Python utility that rewrites your failed shell commands based on a library of rules. It is for developers who spend too much time retyping commands after trivial errors, and it works by matching the previous command against known failure patterns.
- Who is it for?
- Adopt The Fuck if you are a developer or sysadmin who frequently hits the same command typos and want a quick, rule-based fix without leaving the terminal. Skip it if you work in a highly restricted environment where installing Python packages or shell aliases is not allowed, or if you prefer to type commands deliberately and rarely mistype.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Probably not. The repository last received commits 28 months ago, on July 19, 2024.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- nvbn/thefuck97,956 ★ · +241
| Repository | 2026-08-18 | 2026-11-15 |
|---|---|---|
| nvbn/thefuck | 97.7k | 98k |
241 Stars in the last 89 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The Problem It Solves
The Fuck addresses a specific annoyance: when you type a command and the shell rejects it, you have to read the error, figure out what went wrong, and retype the whole line. Common causes are misspellings, missing sudo, missing flags, or wrong subcommands. The Fuck automates that correction step. It is aimed at anyone who lives in a terminal, from developers to system administrators, and it is especially useful for those who use many different tools with their own command syntax, like git, docker, or package managers. The tool does not fix logic errors in scripts or semantic mistakes; it only handles cases where the command itself is malformed or fails due to a known environment condition, such as a permission issue.
How It Works: Rule Matching and Execution
The core mechanism is simple: when you run `fuck`, it takes your previous command and tries to match it against a set of rules. Each rule is a Python function that checks if the command matches a known failure pattern and, if so, produces a corrected command. The README lists dozens of default rules, like `cd_correction` for misspelled directory names, `git_push` for adding `--set-upstream`, and `cd_mkdir` for creating directories before cd'ing into them. Once a rule matches, the corrected command is displayed with a prompt showing `[enter/↑/↓/ctrl+c]`, letting you accept, scroll through alternatives, or cancel. If you disable `require_confirmation`, the corrected command runs immediately. There is also a recursive mode (`-r`) that reruns the correction until the command succeeds, which is useful for chains of errors.
Installation and First Use
Installation is straightforward on most systems. On macOS, use `brew install thefuck`. On Ubuntu, you first install Python dependencies with `sudo apt install python3-dev python3-pip python3-setuptools`, then run `pip3 install thefuck --user`. FreeBSD uses `pkg install thefuck`, Arch uses `sudo pacman -S thefuck`, and ChromeOS uses `crew install thefuck`. For other systems, `pip install thefuck` works. After installation, you must add an alias to your shell config. The README recommends putting `eval $(thefuck --alias)` in your `.bashrc` or `.zshrc`. You can customize the alias, for example `eval $(thefuck --alias FUCK)` for a different trigger word. The alias is what sets your shell up to use it. Changes take effect in a new shell session, or you can run `source ~/.bashrc` immediately.
Settings and Modes
One key setting is `require_confirmation`. By default, The Fuck asks for confirmation before running the corrected command, which is a safety measure. If you are comfortable with blindly running fixes, you can disable that option, and then `fuck` will execute the correction immediately. There is also the `--yeah` flag (or `-y`) to run without confirmation for a single invocation, and `--hard` for especially frustrating situations. The `-r` flag runs corrections recursively until success. The README also points to an experimental instant mode for people who find The Fuck too slow.
Creating Your Own Rules
The README has a section titled 'Creating your own rules', so you can extend The Fuck with custom corrections. This is important because the default rules are finite and may not cover your specific workflow. For example, if you frequently mistype a command for an internal tool, you would need to write a rule for it. The rules are Python functions, so you need some Python knowledge. The README also mentions 'Third party packages with rules', which points to rule sets published as separate packages. This extensibility is a strength, but it also adds a maintenance burden: you must keep your custom rules up to date with changes in your tools' behavior.
Limitations and When It Is the Wrong Tool
The Fuck is not a general-purpose command corrector. It only works when a rule matches, and the rule set is biased toward common Unix tools and package managers. If you use niche tools, you will likely get no suggestion, and the tool will do nothing. The confirmation prompt is a safety feature, but disabling it can be dangerous because the corrected command might be wrong. For example, a rule that adds `sudo` could run a command with elevated privileges that you did not intend. The README frames disabling confirmation as for people who are 'not afraid of blindly running corrected commands', so the risk is acknowledged. Another limitation is that the tool is Python-based, so it requires Python 3.5+ and pip, which may not be available in minimal container images or locked-down systems. In such environments, installing The Fuck is more trouble than it is worth.
Alternatives and Comparison
A direct alternative is the shell's own history expansion and editing features. For example, in Bash, you can use `!!` to repeat the last command, and you can manually edit it with the arrow keys. This is built-in and requires no extra software, but it does not suggest corrections. Another alternative is `zsh-autosuggestions`, which suggests completions based on history, but it does not fix errors. There is also `shellcheck` for static analysis of shell scripts, but that is for scripts, not interactive commands. The Fuck's difference is that it actively transforms the failed command based on error patterns, not just repeats it. Compared to manual editing, The Fuck can save keystrokes, but it introduces a dependency and a learning curve. For users who are comfortable with shell shortcuts, the built-in features may be sufficient. The choice depends on how often you hit errors and whether you want automated suggestions.
Maintenance and License
The latest release is 3.32 from 2022-01-02 and the repository's last push was on 2024-07-19, so the project appears to be in maintenance mode rather than actively developed. This is not necessarily bad, as the tool is mature and the rules are stable. However, it means that new shell features or changes in tool error messages may not be reflected, and you might need to write your own rules over time. The license is MIT, which is permissive: you can use, modify, and redistribute the code, including in commercial products, as long as you preserve the copyright notice. There is no explicit maintenance cost for users, but if you rely on custom rules, you have to maintain them yourself. Upgrading is simple with `pip3 install thefuck --upgrade`, but note that the alias functionality changed in v1.34, so older aliases may break after an upgrade. Always check the release notes before upgrading if you have a customized setup.
Editorial conclusion
Adopt The Fuck if you are a developer or sysadmin who frequently hits the same command typos and want a quick, rule-based fix without leaving the terminal. Skip it if you work in a highly restricted environment where installing Python packages or shell aliases is not allowed, or if you prefer to type commands deliberately and rarely mistype. Before adopting, verify that your shell is supported (Bash, Zsh, Fish, Powershell, tcsh are listed) and that the default rules cover the tools you use most, since the rule set is finite and you may need to write custom rules for your own frequent errors.
Frequently asked questions
How do I install thefuck on my system?
The install depends on your platform: brew install thefuck on macOS or Linux, a pip3 install thefuck --user after installing python3-dev and python3-pip on Ubuntu or Mint, pkg install thefuck on FreeBSD, crew install thefuck on ChromeOS, sudo pacman -S thefuck on Arch, or a plain pip install thefuck elsewhere. You also need to add eval $(thefuck --alias) to your shell startup file. Python 3.5 or later is required.
Why does my shell say thefuck or fuck is not found after installing?
The package installs a command, but you still have to make the shell know about it by adding eval $(thefuck --alias) to your .bashrc, .zshrc, or another startup script. The README notes changes are only picked up in a new shell session, so you also need to source your config file such as source ~/.bashrc to make it available immediately.
Can thefuck run the corrected command without me confirming it?
Yes. There is a --yeah option, with -y as the short form and --hard as an alternative, that runs the fixed command without waiting for you. There is also a require_confirmation setting you can disable in the settings, and a recursive -r option that keeps fixing commands until one succeeds.
Does thefuck work if the last command produced no error?
The tool works by matching the previous command and its output against a set of rules, so it depends on a rule matching that specific situation. Rules cover cases like cd into a missing directory, a tar or unzip that unpacked in the current directory, docker login, and mistyped subcommands for tools like git, adb, cargo, and lein. If no rule matches your case, the tool has nothing to suggest.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/nvbn-thefuck)Star history chart for your README
[](https://hysenlabs.com/projects/nvbn-thefuck)Was this useful?