thefuck
Run it after a failed command and it proposes the fixed version for you to confirm.
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
| Alternative | Type | Trade-off |
|---|---|---|
| pay-respects | Open source | A Rust rewrite, much faster to start |
sudo !! | Built in | The 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