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
Что это такое?The Fuck — консольное приложение, которое исправляет вашу предыдущую команду с опечаткой. Запустите 'fuck' после неудачной команды, и оно предложит исправленный вариант для выполнения.
Это отдельная программа или плагин для оболочки?Это CLI-инструмент на Python, который вы подключаете как алиас в конфиге вашей оболочки (Bash, Zsh, Fish, PowerShell, tcsh), поэтому при вводе 'fuck' логика алиаса запускается для истории команд вашей оболочки.
Как его установить и настроить?Установите через Homebrew на macOS/Linux, через apt или pip на Ubuntu/Mint, через pip в остальных системах или через менеджер пакетов вашего дистрибутива, затем добавьте строку с алиасом в стартовый файл оболочки и перезапустите оболочку.
Что нужно установить перед установкой?Сначала нужно установить Python 3.5+, pip и python-dev.
Нужно ли подтверждать каждое предложенное исправление?По умолчанию перед запуском исправленной команды приложение запрашивает подтверждение; пропустить его можно флагом --yeah/-y или полностью отключить подтверждение в настройках, а флаг -r повторяет попытки рекурсивно, пока команда не выполнится успешно.
С какими оболочками оно работает?Работает с Bash, Zsh, Fish, PowerShell и tcsh, на macOS, Linux, FreeBSD и ChromeOS.
Как оно решает, каким должно быть исправление?Оно сопоставляет вашу предыдущую неудачную команду с большой встроенной библиотекой правил (для git, docker, npm, pip, опечаток в cd и т. д.); если правило подходит, генерируется исправленная команда и запускается.
Есть ли режим мгновенной работы?Да, есть экспериментальный режим instant, который ускоряет предложение исправлений, если обычный процесс кажется слишком медленным.
Могу ли я написать собственные правила исправления?Да, в README описан раздел 'Creating your own rules', а также есть сторонние пакеты, которые добавляют дополнительные правила.
Какие ошибки оно может исправить?Сотни встроенных правил покрывают опечатки в git, docker, npm, pip, apt, go, cargo, mvn, grep, cd, ls и многих других распространённых CLI-инструментах, например исправляют 'git brnch' или добавляют 'sudo', когда доступ запрещён.
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