thefuck README

The project's README from github.com/nvbn/thefuck. As one markdown file: README.md.

The Fuck [![Version][version-badge]][version-link] [![Build Status][workflow-badge]][workflow-link] [![Coverage][coverage-badge]][coverage-link] ![MIT License][license-badge]

The Fuck is a magnificent app, inspired by a @liamosaur tweet, that corrects errors in previous console commands.

Is The Fuck too slow? Try the experimental instant mode!

[![gif with examples][examples-link]][examples-link]

More examples:

➜ 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
...
➜ 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.
...
➜ 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)
...
➜ git brnch
git: 'brnch' is not a git command. See 'git --help'.

Did you mean this?
    branch

➜ fuck
git branch [enter/↑/↓/ctrl+c]
* master
➜ lein rpl
'rpl' is not a task. See 'lein help'.

Did you mean this?
         repl

➜ fuck
lein repl [enter/↑/↓/ctrl+c]
nREPL server started on port 54848 on host 127.0.0.1 - nrepl://127.0.0.1:54848
REPL-y 0.3.1
...

If you're not afraid of blindly running corrected commands, the require_confirmation settings option can be disabled:

➜ 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
[sudo] password for nvbn:
Reading package lists... Done
...

Contents

  1. Requirements
  2. Installations
  3. Updating
  4. How it works
  5. Creating your own rules
  6. Settings
  7. Third party packages with rules
  8. Experimental instant mode
  9. Developing
  10. License

Requirements

Back to Contents

Installation

On macOS or Linux, you can install The Fuck via [Homebrew][homebrew]:

brew install thefuck

On Ubuntu / Mint, install The Fuck with the following commands:

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

On FreeBSD, install The Fuck with the following commands:

pkg install thefuck

On ChromeOS, install The Fuck using chromebrew with the following command:

crew install thefuck

On Arch based systems, install The Fuck with the following command:

sudo pacman -S thefuck

On other systems, install The Fuck by using pip:

pip install thefuck

Alternatively, you may use an OS package manager (OS X, Ubuntu, Arch).

# It is recommended that you place this command in your .bash_profile, .bashrc, .zshrc or other startup script:

eval $(thefuck --alias)
# You can use whatever you want as an alias, like for Mondays:
eval $(thefuck --alias FUCK)

Or in your shell config (Bash, Zsh, Fish, Powershell, tcsh).

Changes are only available in a new shell session. To make changes immediately available, run source ~/.bashrc (or your shell config file like .zshrc).

To run fixed commands without confirmation, use the --yeah option (or just -y for short, or --hard if you're especially frustrated):

fuck --yeah

To fix commands recursively until succeeding, use the -r option:

fuck -r
Back to Contents

Updating

pip3 install thefuck --upgrade

Note: Alias functionality was changed in v1.34 of The Fuck

Uninstall

To remove The Fuck, reverse the installation process:

How it works

The Fuck attempts to match the previous command with a rule. If a match is found, a new command is created using the matched rule and executed. The following rules are enabled by default:

Back to Contents

The following rules are enabled by default on specific platforms only:

The following commands are bundled with The Fuck, but are not enabled by default:

Back to Contents

Creating your own rules

To add your own rule, create a file named your-rule-name.py in ~/.config/thefuck/rules. The rule file must contain two functions:

match(command: Command) -> bool
get_new_command(command: Command) -> str | list[str]

Additionally, rules can contain optional functions:

side_effect(old_command: Command, fixed_command: str) -> None

Rules can also contain the optional variables enabled_by_default, requires_output and priority.

Command h

thefuck (nvbn/thefuck)

Searching Database…

97.9K ·GitHub
What is this?The Fuck is a command-line app that corrects your previous mistyped console command. Run 'fuck' after a failed command and it suggests a fixed version to run instead.
Is it a standalone program or a shell plugin?It's a Python CLI tool that you alias in your shell config (Bash, Zsh, Fish, PowerShell, tcsh), so typing 'fuck' re-runs the alias logic against your shell history.
How do I install and set it up?Install via Homebrew on macOS/Linux, apt/pip on Ubuntu/Mint, pip elsewhere, or your distro's package manager, then add the alias line to your shell startup file and reload the shell.
What do I need before installing it?You need Python 3.5+, pip, and python-dev installed first.
Do I need to confirm every fix it suggests?By default it asks for confirmation before running the corrected command; you can skip that with the --yeah/-y flag, or disable confirmation entirely via settings, and -r retries recursively until it succeeds.
Which shells does it work with?It works with Bash, Zsh, Fish, PowerShell, and tcsh, on macOS, Linux, FreeBSD, and ChromeOS.
How does it decide what the fix should be?It matches your previous failed command against a large built-in library of rules (for things like git, docker, npm, pip, cd typos, etc.); if a rule matches, it generates a corrected command and runs it.
Is there an instant/faster mode?Yes, there's an experimental instant mode aimed at speeding up the suggestion process if the normal flow feels too slow.
Can I write my own correction rules?Yes, the README documents a 'Creating your own rules' section, and there are also third-party packages that add extra rules.
What kinds of mistakes can it fix?Hundreds of built-in rules cover typos in git, docker, npm, pip, apt, go, cargo, mvn, grep, cd, ls, and many other common CLI tools, like fixing 'git brnch' or adding 'sudo' when permission is denied.
What are similar projects?git-extras, autojump, tmuxinator, n, oh-my-posh, diff-so-fancy, just, hub
Creator
nvbn
Size
3.9 MB
Stars
97.9K
Age
11y
Commits · 90 Days