Magnificent app which corrects your previous console command.

Related tags

CLI Tools python shell
Overview

The Fuck Version Build Status Coverage MIT License

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

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
...

Requirements

  • python (3.4+)
  • pip
  • python-dev

Installation

On OS X, you can install The Fuck via Homebrew (or via Linuxbrew on Linux):

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
sudo pip3 install thefuck

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 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

Updating

pip3 install thefuck --upgrade

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

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:

  • adb_unknown_command – fixes misspelled commands like adb logcta;
  • ag_literal – adds -Q to ag when suggested;
  • aws_cli – fixes misspelled commands like aws dynamdb scan;
  • az_cli – fixes misspelled commands like az providers;
  • cargo – runs cargo build instead of cargo;
  • cargo_no_command – fixes wrongs commands like cargo buid;
  • cat_dir – replaces cat with ls when you try to cat a directory;
  • cd_correction – spellchecks and correct failed cd commands;
  • cd_mkdir – creates directories before cd'ing into them;
  • cd_parent – changes cd.. to cd ..;
  • chmod_x – add execution bit;
  • choco_install – append common suffixes for chocolatey packages;
  • composer_not_command – fixes composer command name;
  • cp_create_destination – creates a new directory when you attempt to cp or mv to a non existent one
  • cp_omitting_directory – adds -a when you cp directory;
  • cpp11 – adds missing -std=c++11 to g++ or clang++;
  • dirty_untar – fixes tar x command that untarred in the current directory;
  • dirty_unzip – fixes unzip command that unzipped in the current directory;
  • django_south_ghost – adds --delete-ghost-migrations to failed because ghosts django south migration;
  • django_south_merge – adds --merge to inconsistent django south migration;
  • docker_login – executes a docker login and repeats the previous command;
  • docker_not_command – fixes wrong docker commands like docker tags;
  • docker_image_being_used_by_container ‐ removes the container that is using the image before removing the image;
  • dry – fixes repetitions like git git push;
  • fab_command_not_found – fix misspelled fabric commands;
  • fix_alt_space – replaces Alt+Space with Space character;
  • fix_file – opens a file with an error in your $EDITOR;
  • gem_unknown_command – fixes wrong gem commands;
  • git_add – fixes "pathspec 'foo' did not match any file(s) known to git.";
  • git_add_force – adds --force to git add <pathspec>... when paths are .gitignore'd;
  • git_bisect_usage – fixes git bisect strt, git bisect goood, git bisect rset, etc. when bisecting;
  • git_branch_delete – changes git branch -d to git branch -D;
  • git_branch_delete_checked_out – changes git branch -d to git checkout master && git branch -D when trying to delete a checked out branch;
  • git_branch_exists – offers git branch -d foo, git branch -D foo or git checkout foo when creating a branch that already exists;
  • git_branch_list – catches git branch list in place of git branch and removes created branch;
  • git_checkout – fixes branch name or creates new branch;
  • git_clone_git_clone – replaces git clone git clone ... with git clone ...
  • git_commit_amend – offers git commit --amend after previous commit;
  • git_commit_reset – offers git reset HEAD~ after previous commit;
  • git_diff_no_index – adds --no-index to previous git diff on untracked files;
  • git_diff_staged – adds --staged to previous git diff with unexpected output;
  • git_fix_stash – fixes git stash commands (misspelled subcommand and missing save);
  • git_flag_after_filename – fixes fatal: bad flag '...' after filename
  • git_help_aliased – fixes git help <alias> commands replacing with the aliased command;
  • git_hook_bypass – adds --no-verify flag previous to git am, git commit, or git push command;
  • git_lfs_mistype – fixes mistyped git lfs <command> commands;
  • git_merge – adds remote to branch names;
  • git_merge_unrelated – adds --allow-unrelated-histories when required
  • git_not_command – fixes wrong git commands like git brnch;
  • git_pull – sets upstream before executing previous git pull;
  • git_pull_clone – clones instead of pulling when the repo does not exist;
  • git_pull_uncommitted_changes – stashes changes before pulling and pops them afterwards;
  • git_push – adds --set-upstream origin $branch to previous failed git push;
  • git_push_different_branch_names – fixes pushes when local brach name does not match remote branch name;
  • git_push_pull – runs git pull when push was rejected;
  • git_push_without_commits – Creates an initial commit if you forget and only git add ., when setting up a new project;
  • git_rebase_no_changes – runs git rebase --skip instead of git rebase --continue when there are no changes;
  • git_remote_delete – replaces git remote delete remote_name with git remote remove remote_name;
  • git_rm_local_modifications – adds -f or --cached when you try to rm a locally modified file;
  • git_rm_recursive – adds -r when you try to rm a directory;
  • git_rm_staged – adds -f or --cached when you try to rm a file with staged changes
  • git_rebase_merge_dir – offers git rebase (--continue | --abort | --skip) or removing the .git/rebase-merge dir when a rebase is in progress;
  • git_remote_seturl_add – runs git remote add when git remote set_url on nonexistent remote;
  • git_stash – stashes your local modifications before rebasing or switching branch;
  • git_stash_pop – adds your local modifications before popping stash, then resets;
  • git_tag_force – adds --force to git tag <tagname> when the tag already exists;
  • git_two_dashes – adds a missing dash to commands like git commit -amend or git rebase -continue;
  • go_run – appends .go extension when compiling/running Go programs;
  • go_unknown_command – fixes wrong go commands, for example go bulid;
  • gradle_no_task – fixes not found or ambiguous gradle task;
  • gradle_wrapper – replaces gradle with ./gradlew;
  • grep_arguments_order – fixes grep arguments order for situations like grep -lir . test;
  • grep_recursive – adds -r when you try to grep directory;
  • grunt_task_not_found – fixes misspelled grunt commands;
  • gulp_not_task – fixes misspelled gulp tasks;
  • has_exists_script – prepends ./ when script/binary exists;
  • heroku_multiple_apps – add --app <app> to heroku commands like heroku pg;
  • heroku_not_command – fixes wrong heroku commands like heroku log;
  • history – tries to replace command with most similar command from history;
  • hostscli – tries to fix hostscli usage;
  • ifconfig_device_not_found – fixes wrong device names like wlan0 to wlp2s0;
  • java – removes .java extension when running Java programs;
  • javac – appends missing .java when compiling Java files;
  • lein_not_task – fixes wrong lein tasks like lein rpl;
  • long_form_help – changes -h to --help when the short form version is not supported
  • ln_no_hard_link – catches hard link creation on directories, suggest symbolic link;
  • ln_s_order – fixes ln -s arguments order;
  • ls_all – adds -A to ls when output is empty;
  • ls_lah – adds -lah to ls;
  • man – changes manual section;
  • man_no_space – fixes man commands without spaces, for example mandiff;
  • mercurial – fixes wrong hg commands;
  • missing_space_before_subcommand – fixes command with missing space like npminstall;
  • mkdir_p – adds -p when you try to create a directory without parent;
  • mvn_no_command – adds clean package to mvn;
  • mvn_unknown_lifecycle_phase – fixes misspelled life cycle phases with mvn;
  • npm_missing_script – fixes npm custom script name in npm run-script <script>;
  • npm_run_script – adds missing run-script for custom npm scripts;
  • npm_wrong_command – fixes wrong npm commands like npm urgrade;
  • no_command – fixes wrong console commands, for example vom/vim;
  • no_such_file – creates missing directories with mv and cp commands;
  • open – either prepends http:// to address passed to open or create a new file or directory and passes it to open;
  • pip_install – fixes permission issues with pip install commands by adding --user or prepending sudo if necessary;
  • pip_unknown_command – fixes wrong pip commands, for example pip instatl/pip install;
  • php_s – replaces -s by -S when trying to run a local php server;
  • port_already_in_use – kills process that bound port;
  • prove_recursively – adds -r when called with directory;
  • pyenv_no_such_command – fixes wrong pyenv commands like pyenv isntall or pyenv list;
  • python_command – prepends python when you try to run non-executable/without ./ python script;
  • python_execute – appends missing .py when executing Python files;
  • python_module_error – fixes ModuleNotFoundError by trying to pip install that module;
  • quotation_marks – fixes uneven usage of ' and " when containing args';
  • path_from_history – replaces not found path with similar absolute path from history;
  • react_native_command_unrecognized – fixes unrecognized react-native commands;
  • remove_shell_prompt_literal – remove leading shell prompt symbol $, common when copying commands from documentations;
  • remove_trailing_cedilla – remove trailing cedillas ç, a common typo for european keyboard layouts;
  • rm_dir – adds -rf when you try to remove a directory;
  • scm_correction – corrects wrong scm like hg log to git log;
  • sed_unterminated_s – adds missing '/' to sed's s commands;
  • sl_ls – changes sl to ls;
  • ssh_known_hosts – removes host from known_hosts on warning;
  • sudo – prepends sudo to previous command if it failed because of permissions;
  • sudo_command_from_user_path – runs commands from users $PATH with sudo;
  • switch_lang – switches command from your local layout to en;
  • systemctl – correctly orders parameters of confusing systemctl;
  • terraform_init.py – run terraform init before plan or apply;
  • test.py – runs py.test instead of test.py;
  • touch – creates missing directories before "touching";
  • tsuru_login – runs tsuru login if not authenticated or session expired;
  • tsuru_not_command – fixes wrong tsuru commands like tsuru shell;
  • tmux – fixes tmux commands;
  • unknown_command – fixes hadoop hdfs-style "unknown command", for example adds missing '-' to the command on hdfs dfs ls;
  • unsudo – removes sudo from previous command if a process refuses to run on super user privilege.
  • vagrant_up – starts up the vagrant instance;
  • whois – fixes whois command;
  • workon_doesnt_exists – fixes virtualenvwrapper env name os suggests to create new.
  • yarn_alias – fixes aliased yarn commands like yarn ls;
  • yarn_command_not_found – fixes misspelled yarn commands;
  • yarn_command_replaced – fixes replaced yarn commands;
  • yarn_help – makes it easier to open yarn documentation;

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

  • apt_get – installs app from apt if it not installed (requires python-commandnotfound / python3-commandnotfound);
  • apt_get_search – changes trying to search using apt-get with searching using apt-cache;
  • apt_invalid_operation – fixes invalid apt and apt-get calls, like apt-get isntall vim;
  • apt_list_upgradable – helps you run apt list --upgradable after apt update;
  • apt_upgrade – helps you run apt upgrade after apt list --upgradable;
  • brew_cask_dependency – installs cask dependencies;
  • brew_install – fixes formula name for brew install;
  • brew_reinstall – turns brew install <formula> into brew reinstall <formula>;
  • brew_link – adds --overwrite --dry-run if linking fails;
  • brew_uninstall – adds --force to brew uninstall if multiple versions were installed;
  • brew_unknown_command – fixes wrong brew commands, for example brew docto/brew doctor;
  • brew_update_formula – turns brew update <formula> into brew upgrade <formula>;
  • dnf_no_such_command – fixes mistyped DNF commands;
  • nixos_cmd_not_found – installs apps on NixOS;
  • pacman – installs app with pacman if it is not installed (uses yay or yaourt if available);
  • pacman_invalid_option – replaces lowercase pacman options with uppercase.
  • pacman_not_found – fixes package name with pacman, yay or yaourt.
  • yum_invalid_operation – fixes invalid yum calls, like yum isntall vim;

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

  • git_push_force – adds --force-with-lease to a git push (may conflict with git_push_pull);
  • rm_root – adds --no-preserve-root to rm -rf / command.

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 has three attributes: script, output and script_parts. Your rule should not change Command.

Rules api changed in 3.0: To access a rule's settings, import it with from thefuck.conf import settings

settings is a special object assembled from ~/.config/thefuck/settings.py, and values from env (see more below).

A simple example rule for running a script with sudo:

def match(command):
    return ('permission denied' in command.output.lower()
            or 'EACCES' in command.output)


def get_new_command(command):
    return 'sudo {}'.format(command.script)

# Optional:
enabled_by_default = True

def side_effect(command, fixed_command):
    subprocess.call('chmod 777 .', shell=True)

priority = 1000  # Lower first, default is 1000

requires_output = True

More examples of rules, utility functions for rules, app/os-specific helpers.

Settings

Several The Fuck parameters can be changed in the file $XDG_CONFIG_HOME/thefuck/settings.py ($XDG_CONFIG_HOME defaults to ~/.config):

  • rules – list of enabled rules, by default thefuck.const.DEFAULT_RULES;
  • exclude_rules – list of disabled rules, by default [];
  • require_confirmation – requires confirmation before running new command, by default True;
  • wait_command – max amount of time in seconds for getting previous command output;
  • no_colors – disable colored output;
  • priority – dict with rules priorities, rule with lower priority will be matched first;
  • debug – enables debug output, by default False;
  • history_limit – numeric value of how many history commands will be scanned, like 2000;
  • alter_history – push fixed command to history, by default True;
  • wait_slow_command – max amount of time in seconds for getting previous command output if it in slow_commands list;
  • slow_commands – list of slow commands;
  • num_close_matches – maximum number of close matches to suggest, by default 3.

An example of settings.py:

rules = ['sudo', 'no_command']
exclude_rules = ['git_push']
require_confirmation = True
wait_command = 10
no_colors = False
priority = {'sudo': 100, 'no_command': 9999}
debug = False
history_limit = 9999
wait_slow_command = 20
slow_commands = ['react-native', 'gradle']
num_close_matches = 5

Or via environment variables:

  • THEFUCK_RULES – list of enabled rules, like DEFAULT_RULES:rm_root or sudo:no_command;
  • THEFUCK_EXCLUDE_RULES – list of disabled rules, like git_pull:git_push;
  • THEFUCK_REQUIRE_CONFIRMATION – require confirmation before running new command, true/false;
  • THEFUCK_WAIT_COMMAND – max amount of time in seconds for getting previous command output;
  • THEFUCK_NO_COLORS – disable colored output, true/false;
  • THEFUCK_PRIORITY – priority of the rules, like no_command=9999:apt_get=100, rule with lower priority will be matched first;
  • THEFUCK_DEBUG – enables debug output, true/false;
  • THEFUCK_HISTORY_LIMIT – how many history commands will be scanned, like 2000;
  • THEFUCK_ALTER_HISTORY – push fixed command to history true/false;
  • THEFUCK_WAIT_SLOW_COMMAND – max amount of time in seconds for getting previous command output if it in slow_commands list;
  • THEFUCK_SLOW_COMMANDS – list of slow commands, like lein:gradle;
  • THEFUCK_NUM_CLOSE_MATCHES – maximum number of close matches to suggest, like 5.

For example:

export THEFUCK_RULES='sudo:no_command'
export THEFUCK_EXCLUDE_RULES='git_pull:git_push'
export THEFUCK_REQUIRE_CONFIRMATION='true'
export THEFUCK_WAIT_COMMAND=10
export THEFUCK_NO_COLORS='false'
export THEFUCK_PRIORITY='no_command=9999:apt_get=100'
export THEFUCK_HISTORY_LIMIT='2000'
export THEFUCK_NUM_CLOSE_MATCHES='5'

Third-party packages with rules

If you'd like to make a specific set of non-public rules, but would still like to share them with others, create a package named thefuck_contrib_* with the following structure:

thefuck_contrib_foo
  thefuck_contrib_foo
    rules
      __init__.py
      *third-party rules*
    __init__.py
    *third-party-utils*
  setup.py

The Fuck will find rules located in the rules module.

Experimental instant mode

The default behavior of The Fuck requires time to re-run previous commands. When in instant mode, The Fuck saves time by logging output with script, then reading the log.

gif with instant mode

Currently, instant mode only supports Python 3 with bash or zsh. zsh's autocorrect function also needs to be disabled in order for thefuck to work properly.

To enable instant mode, add --enable-experimental-instant-mode to the alias initialization in .bashrc, .bash_profile or .zshrc.

For example:

eval $(thefuck --alias --enable-experimental-instant-mode)

Developing

See CONTRIBUTING.md

License MIT

Project License can be found here.

You might also like...
Limit your docker image size with a simple CLI command. Perfect to be used inside your CI process.

docker-image-size-limit Limit your docker image size with a simple CLI command. Perfect to be used inside your CI process. Read the announcing post. I

A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

commandpack - A package of modules for working with commands, command packages, files with command packages.
commandpack - A package of modules for working with commands, command packages, files with command packages.

commandpack Help the project financially: Donate: https://smartlegion.github.io/donate/ Yandex Money: https://yoomoney.ru/to/4100115206129186 PayPal:

AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Ros command - Unifying the ROS command line tools
Ros command - Unifying the ROS command line tools

Unifying the ROS command line tools One impairment to ROS 2 adoption is that all

Text based command line webcam photobooth app
Text based command line webcam photobooth app

Skunkbooth Why See it in action Usage Installation Run Media location Contributing Install Poetry Clone the repo Activate poetry shell Install dev dep

Command line util for grep.app - Search across a half million git repos
Command line util for grep.app - Search across a half million git repos

grepgithub Command line util for grep.app - Search across a half million git repos Grepgithub uses grep.app API to search GitHub repositories, providi

A simple command line chat app to communicate via the terminal.

A simple command line chat app to communicate via the terminal. I'm new to networking so sorry if some of my terminology or code is messed up.

A lightweight Python module and command-line tool for generating NATO APP-6(D) compliant military symbols from both ID codes and natural language names

Python military symbols This is a lightweight Python module, including a command-line script, to generate NATO APP-6(D) compliant military symbol icon

Comments
  • Add appimage build

    Add appimage build

    This PR adds support for building appimages that can be added to release assets as mentioned in #1349.

    The build process uses a shell script thefuck/appimage/thefuck-appimage-build.sh and a dockerfile to build and run a container that packages the app into an appimage that will reside in thefuck/build.

    Closes #1349

    opened by roborg-codes 0
  • Add terraform_init_upgrade

    Add terraform_init_upgrade

    When working on different branches, terraform provider versions may differ. Often you forget to run terraform init -upgrade before your regular terraform commands. This rule lets you fix that.

    Example:

    $ tf plan
    ╷
    │ Error: Inconsistent dependency lock file
    │ 
    │ The following dependency selections recorded in the lock file are inconsistent with the current configuration:
    │   - provider registry.terraform.io/hashicorp/google: locked version selection 4.42.1 doesn't match the updated version constraints "4.42.0"
    │ 
    │ To update the locked dependency selections to match a changed configuration, run:
    │   terraform init -upgrade
    ╵
    $ fuck
    terraform init -upgrade && terraform plan [enter/↑/↓/ctrl+c]
    
    Initializing the backend...
    
    Initializing provider plugins...
    - Finding hashicorp/google versions matching "4.42.0"...
    - Installing hashicorp/google v4.42.0...
    - Installed hashicorp/google v4.42.0 (signed by HashiCorp)
    
    Terraform has made some changes to the provider dependency selections recorded
    in the .terraform.lock.hcl file. Review those changes and commit them to your
    version control system if they represent changes you intended to make.
    
    Terraform has been successfully initialized!
    
    You may now begin working with Terraform. Try running "terraform plan" to see
    any changes that are required for your infrastructure. All Terraform commands
    should now work.
    
    If you ever set or change modules or backend configuration for Terraform,
    rerun this command to reinitialize your working directory. If you forget, other
    commands will detect it and remind you to do so if necessary.
    google_project_iam_member.[REDACTED]: Refreshing state... [REDACTED]
    
    No changes. Your infrastructure matches the configuration.
    
    Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
    
    opened by iFreilicht 0
  • Multiple problems

    Multiple problems

    When using this inside of vs code terminals it pretty much only works if you type "thefuck" every time you do something. Enabling experimental instant mode did not change anything. I am on "linux" even though it's in the chromebook vm version I tried thefuck --alias --enable-experimental-instant-mode and it says it worked, but doesn't do anything when a comman doesnt work, nor does running it after check it from any logged console output.

    I also noticed that they just use "fuck" as a command to check the last one, and this never worked for me. I tried setting up it's own command, I tried running that after enabling instant mode, and tried running it when I first installed it. I like the idea of this project, but goodness, it barely works. I found it because of fireship io on youtube, and thought it would be useful, but if I am going to have to add "thefuck" before everything I do just to use it then there really isn't any point.

    The Fuck 3.29 using Python 3.9.2 and Bash 5.1.4(1)-release

    opened by fufferpish 0
  • [fish] Some command output is missing

    [fish] Some command output is missing

    The Fuck 3.32 Python 3.10.8 Fish Shell 3.5.1 macOS Ventura

    I'm trying to create a rule to catch suggestions from fish for a command to try. An example:

    > set -x name=value
    set: name=value: invalid variable name. See `help identifiers`
    set: Did you mean `set name value`?
    (Type 'help set' for related documentation)
    
    # desired response from thefuck, does not currently work
    > fuck
    set name value
    

    However, after some debugging, I found that command.output is empty for some reason. This isn't the only anomaly like that; I also found that command.output for fish's command not found message is /bin/sh: x: command not found instead of fish: Unknown command: x (what shows in terminal). This leads me to believe that thefuck is trying to read some internal output instead of what Fish is actually outputting to the user.

    For reference, here's my WIP rule:

    import re;
    
    regex = r'Did you mean `(.*)`'
    
    def match(command):
        return re.match(regex, command.output)
    
    def get_new_command(command):
        return re.match(regex, command.output).group(1)
    

    And to debug the output, I used

    def match(command):
        return True
    
    def get_new_command(command):
        return command.output
    
    opened by asportnoy 1
Releases(3.32)
  • 3.32(Jan 2, 2022)

    • Addition of new rules
      • #942: Add new git_branch_0v_to_dash_v rule
      • #1210: Add rule 'rails_migrations_pending'
      • #1131: Add rule for Git commit with no added files
      • #1184: Add new rule for main / master Git branches
      • #977: Add wrong_hyphen_before_subcommand rule
    • Improvements to existing rules
      • #1039: Remove all leading $ not just one
      • #1123: Update composer_not_command rule (#1135)
      • #942: Improve git_branch_0flag rule - with a new name
      • #1131: Improve git_commit_add rule
      • #1184: Improve + fix git_main_master rule
      • #894: Combine commands with shell.and_ in docker_login rule
      • #618: Fix git_push_without_commits rule
      • #933: Correctly redefine the function with a cache
      • #579: Ignore commands of len 1 in missing_space_before_subcommand
      • #1227: Make git_support support output-independent rules
    • Improvements to documentation and development experience
      • Fix git_hook_bypass priority (#1207)
      • #1164: Optimize GIFs with ImgBot
      • #N/A: Fix grammar and spelling errors (#1193)
      • #455: [README] Add uninstall instructions (#1171)
      • #1150: Update the name of macOS on README
      • #1109: Fix a typo on a comment
      • #1184: Add devcontainer for easy Python development
      • #1184: Configure devcontainer shell with recommended way
      • #868: Fix outdated link to homebrew for Linux (#1226)
      • #1233: Use --user with pip, not sudo pip
    • Bug fixes
      • Avoid using pkg_resources
      • #N/A: Fix yield_fixture deprecation (#1211)
      • #1133: Match commands with path prefixes in @for_app decorations
      • #1215: Remove redirection to stderr with the ^ character
      • #1215: Initiate settings before printing the alias
      • #N/A: Replace only exact words when expanding a Git alias
      • #994: Replace decoding errors with the replacement marker
      • #1188: Remove only leading whitespace chars from script
      • #697: Encode expanded script on Python 2
      • #1250: Encapsulate force_command in _get_raw_command
    Source code(tar.gz)
    Source code(zip)
  • 3.31(Jun 9, 2021)

    • add excluded_search_path_prefixes setting #1165
    • add cd_cs rule #1167
    • extend pyenv rule to include goenv, nodenv and rbenv #1100
    • add conda rule #1138
    • add python_module_error rule #1151
    • fix possible changes in files outside of working directory in dirty_unzip and dirty_untar rules #1206
    • various improvements and bugfixes
    Source code(tar.gz)
    Source code(zip)
  • 3.30(Mar 19, 2020)

    • new nixos_cmd_not_found rule (#912, #922)
    • new terraform_init rule (#924)
    • new docker_image_being_used_by_container rule (#925, #928)
    • new go_unknown_command rule (#933)
    • new yum_invalid_operation rule (#968)
    • new git_branch_delete_checked_out rule (#985)
    • new remove_shell_prompt_literal rule (#996)
    • new choco_install rule (#998)
    • new cp_create_destination rule (#1061)
    • Korean support in switch_lang rule (#880, #981)
    • fix recursive shell nesting (#921, #923)
    • fix support of non-English output in apt_list_upgradable (#931)
    • fix git_checkout with git 2.22.0 (#934)
    • fix docker_not_command with newer docker versions (#937, #940)
    • fix rules_git_checkout with branches with slashes (#944)
    • fix apt_invalid_operation behaviour with apt uninstall (#950)
    • fix slow commands time out (#961)
    • fix powershell support (#1004)
    • fix apt_invalid_operation with newer apt-get versions (#1031)
    • fix pip_unknown_command (#1047, #1059)
    Source code(tar.gz)
    Source code(zip)
  • 3.29(May 27, 2019)

    • new pyenv_no_such_command rule (#918)
    • new pip_install rule (#895)
    • new docker_login rule (#894)
    • new git_commit_reset rule (#886)
    • yay support in pacman and pacman_not_found rules (#907)
    • Greek support in switch_lang rule (#862, #864)
    • support of -y/--yeah command line args in Fish Shell (#900)
    • improved fetching of shells version (#920)
    • improved windows support (#902, #917)
    • bugfixes (#861, #869, #872, #874)
    Source code(tar.gz)
    Source code(zip)
  • 3.28(Nov 29, 2018)

    • Ukrainian layout support in switch_lang rule (#855)
    • pwsh support (#844)
    • BSD style output support in touch rule (#360)
    • --yeah as an alternative arg to -y and --yes (#822)
    • bug fixes: #854, #835, #842, #827, #820, #818, #819
    Source code(tar.gz)
    Source code(zip)
  • 3.27(May 22, 2018)

  • 3.26(Apr 25, 2018)

    • Ubuntu 18.04 support (#786)
    • Improved fish alias (#727)
    • New unsudo rule (#787)
    • New git_merge_unrelated rule (#773)
    • New git_commit_amend rule (#664)
    • New adb_unknown_command rule (#765)
    • New apt_upgrade rule (#761)
    • New git_merge rule (#629)
    • Improved cd_mkdir rule (#784)
    • Improved cd_correction rule (#784)
    • Improved switch_lang rule (#776)
    • Improved git_branch_exists rule (#762)
    • Improved git_push rule (#740)
    • Improved git_checkout rule (#632)
    • No longer rely on $SHELL for detecting shell (#783)
    Source code(tar.gz)
    Source code(zip)
  • 3.25(Nov 23, 2017)

    • add support of third-party packages with rules (#737);
    • fix Windows support (#715);
    • fix zsh alias (#733);
    • new rule: heroku_multiple_apps – add --app <app> to heroku commands like heroku pg (#729);
    • new rule: apt_list_upgradable – helps you run apt list --upgradable after apt update (#732);
    • minor bug fixes.
    Source code(tar.gz)
    Source code(zip)
  • 3.24(Oct 16, 2017)

    • instant fuck mode support on macOS (#682);
    • command selection with ctrl+n and ctrl+p instead of and (#711);
    • improvements in cache (#707);
    • fixed exception in python3 + fish (#708);
    • fixed configuration code for fish shell (#658);
    • support parameters in PowerShell (#696);
    • rules api changed, Command.output instead of stdout/stderr (#682, #691);
    • multiline PS1 with instant mode (#692);
    • add php_s rule that replaces -s by -S when trying to run a local php server (#655);
    • add dnf_no_such_command rule that fixes mistyped DNF commands (#698);
    • add git_remote_delete rule that replaces git remote delete remote_name with git remote remove remote_name (#670);
    • add git_push_different_branch_names rule that fixes pushes when local brach name does not match remote branch name (#652);
    • add prove_recursively rule that adds -r when called with directory;
    • add brew_cask_dependency rule that installs cask dependencies;
    • fix brew_update_formula rule (#710).
    Source code(tar.gz)
    Source code(zip)
  • 3.23(Aug 29, 2017)

  • 3.22(Aug 29, 2017)

  • 3.21(Aug 21, 2017)

    Before:

    thefuck git br THEFUCK_ARGUMENT_PLACEHOLDER -y  0,36s user 0,02s system 97% cpu 0,383 total
    thefuck --alias  0,29s user 0,01s system 99% cpu 0,303 total
    

    After:

    thefuck git br THEFUCK_ARGUMENT_PLACEHOLDER -y  0,19s user 0,03s system 94% cpu 0,234 total
    thefuck --alias  0,13s user 0,02s system 99% cpu 0,149 total
    
    Source code(tar.gz)
    Source code(zip)
  • 3.20(Aug 16, 2017)

  • 3.19(Aug 3, 2017)

  • 3.18(May 10, 2017)

  • 3.17(May 10, 2017)

    • fix support of bash aliases (#549, #645)
    • appropriate message instead of "No fucks given" when alias isn't fuck (#635)
    • fix encoding with bash (#643)
    • fix suggestion on yarn require ... (#637)
    Source code(tar.gz)
    Source code(zip)
  • 3.16(Apr 10, 2017)

    • Repeated fucking fucks up with UnicodeDecodeError (Python 2.7.6) #623
    • Improve handling of command line arguments #620
    • idea: fuck-it repeatedly until command works #614
    • allow for a flag that executes immediately #531
    • Please put eval $(thefuck --alias) in your ~/.zshrc. #585
    Source code(tar.gz)
    Source code(zip)
Owner
Vladimir Iakovlev
Software Developer
Vladimir Iakovlev
Simple and convenient console ToDo list app

How do you handle remembering all that loads of plans you are going to realize everyday? Producing tons of paper notes, plastered all over the house?

null 3 Aug 3, 2022
A Python-based command prompt concept which includes windows command emulation.

PythonCMD A Python-based command prompt concept which includes windows command emulation. Current features: echo: Input your message and it will be cl

null 1 Feb 5, 2022
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Stream your favorite shows straight from the command line.

A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Installation pip install -r requirements.txt It use

Jonardon Hazarika 17 Dec 11, 2022
Fylm is a wonderful automated command line app for organizing your film media.

Overview Fylm is a wonderful automated command line app for organizing your film media. You can pronounce it Film or File 'em, whichever you like! It

Brandon Shelley 30 Dec 5, 2022
Bad Apple printed out on the console with Python!

Bad Apple printed out on the console with Python!

CalvinLoke 186 Dec 1, 2022
Enlighten Progress Bar is a console progress bar library for Python.

Overview Enlighten Progress Bar is a console progress bar library for Python. The main advantage of Enlighten is it allows writing to stdout and stder

Rockhopper Technologies 265 Dec 28, 2022
Python library & console tool for controlling Xiaomi smart appliances

python-miio This library (and its accompanying cli tool) can be used to interface with devices using Xiaomi's miIO and MIoT protocols. Getting started

Teemu R. 2.4k Jan 2, 2023
Todo list console based application. Todo's save to a seperate file.

Todo list console based application. Todo's save to a seperate file.

null 1 Dec 24, 2021
A simple automation script that logs into your kra account and files your taxes with one command

EASY_TAX A simple automation script that logs into your kra account and files your taxes with one command Currently works for Chrome users. Will creat

leon koech 13 Sep 23, 2021
Ralph is a command-line tool to fetch, extract, convert and push your tracking logs from various storage backends to your LRS or any other compatible storage or database backend.

Ralph is a command-line tool to fetch, extract, convert and push your tracking logs (aka learning events) from various storage backends to your

France Université Numérique 18 Jan 5, 2023