The Fuck: Automatically Correct Your Previous Console Commands

The Fuck: Automatically Correct Your Previous Console Commands

Summary

The Fuck is a magnificent and highly popular Python application designed to automatically correct errors in your previous console commands. Inspired by a tweet, this tool aims to significantly enhance productivity for anyone frequently working in the terminal by fixing common typos and mistakes. With over 95,000 stars on GitHub, it's a widely adopted solution for command-line efficiency.

Repository Info

Updated on January 31, 2026
View on GitHub

Tags

Click on any tag to explore related repositories

Introduction

The Fuck is a magnificent and highly popular Python application designed to automatically correct errors in your previous console commands. Inspired by a tweet, this tool aims to significantly enhance productivity for anyone frequently working in the terminal by fixing common typos and mistakes. With over 95,000 stars on GitHub, it's a widely adopted solution for command-line efficiency.

Installation

Installing The Fuck is straightforward and supported across various platforms.

On macOS or Linux (via Homebrew):

brew install thefuck

On Ubuntu / Mint:

sudo apt update
sudo apt install python3-dev python3-pip python3-setuptools
pip3 install thefuck --user

On Arch based systems:

sudo pacman -S thefuck

On other systems (via pip):

pip install thefuck

After installation, it is recommended to add an alias to your shell configuration file (e.g., .bashrc, .zshrc):

eval $(thefuck --alias)
# You can use a custom alias, for example:
eval $(thefuck --alias FUCK)

Remember to source your shell config file or open a new session for changes to take effect.

Updating:

To update The Fuck to the latest version, use:

pip3 install thefuck --upgrade

Examples

The Fuck shines in its ability to correct a wide range of common command-line errors. Here are a few illustrative examples:

Fixing sudo permissions:

? apt-get install vim
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

? fuck
sudo apt-get install vim [enter/?/?/ctrl+c]
[sudo] password for nvbn:
Reading package lists... Done
...

Correcting Git upstream issues:

? git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master


? fuck
git push --set-upstream origin master [enter/?/?/ctrl+c]
Counting objects: 9, done.
...

Typo correction for basic commands:

? puthon
No command 'puthon' found, did you mean:
 Command 'python' from package 'python-minimal' (main)
 Command 'python' from package 'python3' (main)
zsh: command not found: puthon

? fuck
python [enter/?/?/ctrl+c]
Python 3.4.2 (default, Oct  8 2014, 13:08:17)
...

The tool also supports running fixed commands without confirmation using fuck --yeah or fuck -y.

Why Use It

The Fuck is an invaluable tool for anyone who spends a significant amount of time in the terminal. Its primary benefits include:

  • Increased Productivity: By automatically correcting common mistakes, it saves time and reduces the frustration of retyping commands.
  • Reduced Errors: It intelligently identifies and fixes a vast array of errors, from simple typos to complex Git command issues and permission problems.
  • Extensibility: Users can create their own custom rules to address specific workflows or unique command patterns, making it highly adaptable.
  • Broad Compatibility: It supports various shells (Bash, Zsh, Fish, Powershell, tcsh) and integrates seamlessly into existing command-line environments.
  • Instant Mode: For even faster corrections, an experimental instant mode is available, which logs output and reads it directly, bypassing the need to re-run commands.

Links