Skip to content

thefuck

Run it after a failed command and it proposes the fixed version for you to confirm.

Homebrew formula

What it does

thefuck inspects the last command and its error output, matches it against a library of rules — missing sudo, a typo’d subcommand, git brnch, a forgotten -p on mkdir, the wrong package manager — and prints the corrected command. Enter runs it.

$ git brnch
git: 'brnch' is not a git command.
$ fuck
git branch [enter/↑/↓/ctrl+c]

Notes

  • Requires a shell alias: eval "$(thefuck --alias)", optionally renamed (thefuck --alias fix).
  • Written in Python, so it carries a Python dependency and adds noticeable startup latency to the alias.

Alternative to

AlternativeTypeTrade-off
pay-respectsOpen sourceA Rust rewrite, much faster to start
sudo !!Built inThe built-in answer to the most common case
Shell aliases for your own typos—Zero latency, and it fixes them permanently

Install

brew install thefuck

Links

This post is licensed under CC BY 4.0 by the author.
Last updated on