TopGit
GitHub Repo Review

TheFuck Command Correction

nvbn/thefuck
TTopGit review image for nvbn/thefuck
Review by Topgit.dev for nvbn/thefuck, with GitHub repository stats and README context.
Quick verdict

The Fuck is worth installing if you spend real time in a terminal — the 100+ built-in rules cover actual mistakes developers make daily, from `git brnch` to `apt-get` permission errors. The tradeoff is that invoking Python on every failed command adds noticeable latency; the experimental instant mode exists but is marked as such. I would skip it only if you work in fish shell (which has built-in autocorrect), rarely mistype commands, or can't install dependencies on a shared system.

Stars
★ 97.6k
Forks
⑂ 4.0k
Contributors
👥 196
Language
Python
License
MIT
Topic
Backend
Updated
Jul 2024
Homepage
GitHub

Tired of Typos in Your Terminal?

You type a command, hit enter, see the error, then waste time backspacing and retyping the correct version. Tab completion prevents some typos but doesn't help when you've already executed something wrong.

What is The Fuck?

The Fuck is a Python CLI tool that hooks into your shell and watches for failed commands. When it catches one, it matches the error against a library of over 100 built-in rules and generates a corrected version for you to approve or run immediately.

How The Fuck Corrects Your Commands

  • Over 100 built-in rules covering git subcommands, package managers (apt, brew, pip, npm, cargo), and typos like `sl` → `ls`
  • Rule-based matching: each failed command is tested against pattern-match functions that generate a corrected script
  • Supports Bash, Zsh, Fish, Powershell, and tcsh through shell-specific alias setup
  • Custom rules via Python files in `~/.config/thefuck/rules` with `match()` and `get_new_command()` functions
  • Three execution modes: confirmation prompt (default), `--yeah` for instant run, `-r` for recursive correction until one succeeds
  • Platform-specific rules activate automatically on Ubuntu (apt), macOS (brew), Arch (pacman), FreeBSD (pkg), and NixOS
How this repository's GitHub stars have grown over time. Source: star-history.com.View the star history

Getting Started with The Fuck

Python 3.5+, pip, and python-dev are required. On macOS: `brew install thefuck`. On Ubuntu/Mint: `sudo apt install python3-dev python3-pip python3-setuptools && pip3 install thefuck --user`. On Arch: `sudo pacman -S thefuck`. On FreeBSD: `pkg install thefuck`. Otherwise: `pip install thefuck`. After installation, add `eval $(thefuck --alias)` to your `.bashrc`, `.zshrc`, or equivalent shell config, then start a new session or run `source ~/.bashrc`.

Using The Fuck in Your Shell

After the alias is active, type your command as usual. When it fails, type `fuck` and press Enter. The corrected command appears on the command line — press Enter to run it, ↑/↓ to cycle through alternatives, or Ctrl+C to cancel. Use `fuck --yeah` (or `fuck -y`) to skip confirmation and run the first match immediately. Use `fuck -r` to keep applying corrections recursively until one succeeds. The README notes that `--yeah` satisfies the alias expansion, while `--hard` exists for when you want to skip even faster.

Strengths

  • Covers real mistakes developers actually make — git typos, missing sudo, mistyped npm commands — not just generic shell errors
  • Extensible rule system: drop a Python file with `match()` and `get_new_command()` into a config directory and it loads automatically
  • Works across the five most common shells, with platform-specific rules for apt, brew, pacman, and other package managers
  • Free, open-source, and MIT-licensed — no cost, no vendor lock-in
  • The community has contributed rules for an unusually wide range of tools (terraform, lein, gradle, react-native, yarn, and dozens more)

Considerations Before You `fuck`

  • Launches a Python interpreter on every failed command — on slower systems or over SSH, this latency is tangible; the experimental instant mode is the official workaround but is not yet stable
  • Requires installing python-dev headers and pip, which may be impractical in restricted CI/CD environments or locked-down containers
  • Platform-specific rules (apt, brew, pacman) only work when you are on that platform, so rules you rely on locally won't apply in Docker images running a different base OS
  • Confirmation mode is on by default but the README warns that disabling it means blindly executing corrected commands — a security consideration for commands involving sudo or file deletion

Other Shell Command Fixers

fish shell includes built-in command correction and works without installing any additional tool, but switching shells is a larger commitment than installing a single utilityzsh with the correct plugin (like Zsh Autosuggestions) can surface similar commands from history but doesn't actively match errors against rules the way The Fuck doesMurex is a shell designed from scratch with built-in error correction and documentation, but it replaces your entire shell rather than augmenting an existing one

Common Questions About The Fuck

Is The Fuck safe to use without confirmation?

By default, The Fuck shows the corrected command and waits for you to press Enter before executing. Disabling confirmation with `--yeah` or `--hard` means corrections run immediately — for harmless typos like `git brnch` this is fine, but be cautious with commands involving sudo or file deletion.

What shells does The Fuck support?

The Fuck supports Bash, Zsh, Fish, Powershell, and tcsh. For each, you add a shell-specific alias line to your startup config, then reload your session.

Can I create custom correction rules for The Fuck?

Yes — create a Python file in `~/.config/thefuck/rules` with a `match(command)` function that returns True when the error matches and a `get_new_command(command)` function that returns the corrected command string or list of strings.

How do I update The Fuck to the latest version?

Run `pip3 install thefuck --upgrade` to fetch the newest release. The README notes that alias behavior changed in v1.34, so check your config after upgrading.

What operating systems does The Fuck run on?

The Fuck runs on macOS, Linux (Ubuntu, Mint, Arch, FreeBSD, NixOS, and ChromeOS via chromebrew), and any system with Python 3.5+ and pip — essentially any platform that can run Python in a shell.

What is the license for The Fuck?

The Fuck is MIT-licensed, meaning you can use, modify, and distribute it freely. The license text is in LICENSE.md on the GitHub repo.

Best use cases

  • Fixing `git brnch` → `git branch` or `git push` without upstream branch in one keystroke
  • Automatically adding `sudo` when an apt or pip command fails due to permissions
  • Correcting `puthon` → `python` or `sl` → `ls` without retyping
  • Fixing permission and configuration errors in docker, vagrant, and heroku commands
  • Creating project-specific rules for internal CLI tools or proprietary scripts

Who should try it — and who should skip

Install it if you use Bash or Zsh daily, make typos in git or package manager commands, and don't mind a Python dependency. Skip it if you run fish shell (which has native autocorrect), work in environments where you cannot install packages, or rarely type wrong commands.

Related repositories

Source & attribution

https://github.com/nvbn/thefuck

GitHub data · last synced Aug 6, 2026Reviewed by Henry
Back to TopGit