# thefuck

> Command-line error correction tool that suggests and fixes typos in previously executed shell commands

Stars: 97.9k · Language: Python · License: MIT · Categories: Shell

- Repository: https://github.com/nvbn/thefuck
- Page: https://www.trmn.sh/tools/thefuck

## Install

- Homebrew: `brew install thefuck`
- apt: `sudo apt update && sudo apt install python3-dev python3-pip python3-setuptools && pip3 install thefuck --user`
- pip: `pip install thefuck`

## Overview

The Fuck is a command-line utility that automatically corrects errors in previously executed shell commands. After typing a command that fails due to typos, missing permissions, or incorrect syntax, users can simply type `fuck` to see suggested corrections. The tool analyzes the failed command and applies one of over 100 built-in rules to generate a corrected version.

The correction engine handles common mistakes across many tools including Git commands (fixing branch names, adding missing flags like `--set-upstream`), package managers (adding `sudo` for permission errors), file operations (correcting `cat directory` to `ls directory`), and typos in command names. Each suggestion is presented with confirmation options, allowing users to accept, reject, or cycle through alternatives using arrow keys.

The tool supports shell integration through aliases and can be configured to run corrections automatically without confirmation. It includes an experimental instant mode for faster performance and allows custom rules for specialized workflows. The Fuck works across multiple shells (Bash, Zsh, Fish, PowerShell) and integrates with the user's existing command history and environment.

### Installation

```bash
# via Homebrew
brew install thefuck
```

```bash
# via apt
sudo apt update && sudo apt install python3-dev python3-pip python3-setuptools && pip3 install thefuck --user
```

```bash
# via pip
pip install thefuck
```

## Alternatives

- [starship](https://www.trmn.sh/tools/starship.md): Cross-shell prompt that displays contextual information about Git repos, programming languages, and system status (Rust, 60.6k stars)
- [Powerlevel10k](https://www.trmn.sh/tools/powerlevel10k.md): Zsh prompt theme with an interactive configuration wizard, instant prompt at shell startup, Git status segments, and Powerlevel9k config compatibility. (Shell, 55.3k stars)
- [zx](https://www.trmn.sh/tools/zx.md): JavaScript/TypeScript library and runner that wraps child_process with a $`...` template tag for writing cross-platform shell scripts with escaped arguments. (JavaScript, 45.8k stars)
- [Nushell](https://www.trmn.sh/tools/nushell.md): Structured data shell that treats commands and files as typed data rather than raw text streams (Rust, 40.8k stars)
- [zoxide](https://www.trmn.sh/tools/zoxide.md): Smart cd replacement that remembers frequently used directories for quick navigation (Rust, 40.4k stars)

---

Canonical: https://www.trmn.sh/tools/thefuck
