Operations 4 min read

Fix Mistyped Terminal Commands Instantly with thefuck – Install & Use Guide

This guide introduces the open‑source tool thefuck, explains how it analyzes erroneous shell commands and suggests correct alternatives, provides concrete examples like fixing "git statis" to "git status", and details step‑by‑step installation on Linux, macOS, Windows and via pip, plus configuration tips.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Fix Mistyped Terminal Commands Instantly with thefuck – Install & Use Guide

thefuck is an open‑source command‑line utility that analyses failed commands from the shell history and suggests a corrected command based on a set of rules.

How it works

It scans the most recent command that returned a non‑zero exit status, matches the error against built‑in rules (e.g., misspelled program names, wrong sub‑commands, missing arguments) and outputs a replacement command. Example:

$ git statis
zsh: command not found: statis
$ fuck
git status

Another example with a typo in python:

$ pathon script.py
bash: pathon: command not found
$ fuck
python script.py

Supported environments

Works with most Unix‑like shells such as bash , zsh and fish . The rule set covers tools including Git, Docker, npm, apt and many others.

Installation

Linux

Debian/Ubuntu: sudo apt update && sudo apt install thefuck Fedora:

sudo dnf install thefuck

macOS

Homebrew: brew install thefuck pip:

pip install thefuck

Windows

Install the Windows Subsystem for Linux (WSL) and follow the Linux instructions, or install the Python package directly with pip install thefuck.

Universal pip method

pip install thefuck

Configuration

Add the generated alias to the shell startup file (e.g., ~/.bashrc or ~/.zshrc): eval $(thefuck --alias) Reload the file ( source ~/.bashrc or source ~/.zshrc). After that, typing fuck will display the suggested correction and, when confirmed, execute it.

Source repository

https://github.com/nvbn/thefuck

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxWindowsInstallationmacOSError Correctionterminalcommand-linethefuck
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.