pax_global_header00006660000000000000000000000064141644163450014522gustar00rootroot0000000000000052 comment=841e3f9e13f52747c18319b55c77ece8095df306 thefuck-3.32/000077500000000000000000000000001416441634500131025ustar00rootroot00000000000000thefuck-3.32/.devcontainer/000077500000000000000000000000001416441634500156415ustar00rootroot00000000000000thefuck-3.32/.devcontainer/Dockerfile000066400000000000000000000010301416441634500176250ustar00rootroot00000000000000# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.163.1/containers/python-3/.devcontainer/base.Dockerfile # [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6 ARG VARIANT="3" FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} # [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. COPY requirements.txt /tmp/pip-tmp/ RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ && rm -rf /tmp/pip-tmp thefuck-3.32/.devcontainer/devcontainer.json000066400000000000000000000027341416441634500212230ustar00rootroot00000000000000// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.163.1/containers/python-3 { "name": "Python 3", "build": { "dockerfile": "Dockerfile", "context": ".." }, // Set *default* container specific settings.json values on container create. "settings": { "terminal.integrated.profiles.linux": { "bash (login)": { "path": "bash", "args": ["-l"] } }, "python.pythonPath": "/usr/local/bin/python", "python.linting.enabled": true, "python.linting.pylintEnabled": true, "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", "python.formatting.blackPath": "/usr/local/py-utils/bin/black", "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-python.python" ], // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "pip3 install -r requirements.txt && python3 setup.py develop" } thefuck-3.32/.editorconfig000066400000000000000000000002211416441634500155520ustar00rootroot00000000000000root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 4 [*.py] max_line_length = 119 thefuck-3.32/.github/000077500000000000000000000000001416441634500144425ustar00rootroot00000000000000thefuck-3.32/.github/ISSUE_TEMPLATE.md000066400000000000000000000020711416441634500171470ustar00rootroot00000000000000 The output of `thefuck --version` (something like `The Fuck 3.1 using Python 3.5.0 and Bash 4.4.12(1)-release`): FILL THIS IN Your system (Debian 7, ArchLinux, Windows, etc.): FILL THIS IN How to reproduce the bug: FILL THIS IN The output of The Fuck with `THEFUCK_DEBUG=true` exported (typically execute `export THEFUCK_DEBUG=true` in your shell before The Fuck): FILL THIS IN If the bug only appears with a specific application, the output of that application and its version: FILL THIS IN Anything else you think is relevant: FILL THIS IN thefuck-3.32/.github/workflows/000077500000000000000000000000001416441634500164775ustar00rootroot00000000000000thefuck-3.32/.github/workflows/test.yml000066400000000000000000000034441416441634500202060ustar00rootroot00000000000000name: Tests on: [push, pull_request] env: PYTHON_LATEST: 3.9 jobs: test: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10-dev] fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Cache dependencies id: cache-deps uses: actions/cache@v2 with: path: | ${{ env.pythonLocation }}/bin/* ${{ env.pythonLocation }}/lib/* ${{ env.pythonLocation }}/scripts/* key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'requirements.txt') }} - name: Install The Fuck with all dependencies if: steps.cache-deps.outputs.cache-hit != 'true' run: | pip install -Ur requirements.txt coveralls python setup.py develop - name: Lint if: matrix.os == 'ubuntu-latest' && matrix.python-version == env.PYTHON_LATEST run: flake8 - name: Run tests if: matrix.os != 'ubuntu-latest' || matrix.python-version != env.PYTHON_LATEST run: coverage run --source=thefuck,tests -m pytest -v --capture=sys tests - name: Run tests (including functional) if: matrix.os == 'ubuntu-latest' && matrix.python-version == env.PYTHON_LATEST run: coverage run --source=thefuck,tests -m pytest -v --capture=sys tests --enable-functional - name: Post coverage results if: matrix.os == 'ubuntu-latest' && matrix.python-version == env.PYTHON_LATEST env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: coveralls --service=github thefuck-3.32/.gitignore000066400000000000000000000013501416441634500150710ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *,cover # Translations *.mo *.pot # Django stuff: *.log # Sphinx documentation docs/_build/ # PyBuilder target/ .env .idea # vim temporary files .*.swp thefuck-3.32/CONTRIBUTING.md000066400000000000000000000061721416441634500153410ustar00rootroot00000000000000# Report issues If you have any issue with The Fuck, sorry about that, but we will do what we can to fix that. Actually, maybe we already have, so first thing to do is to update The Fuck and see if the bug is still there. If it is (sorry again), check if the problem has not already been reported and if not, just open an issue on [GitHub](https://github.com/nvbn/thefuck) with the following basic information: - the output of `thefuck --version` (something like `The Fuck 3.1 using Python 3.5.0`); - your shell and its version (`bash`, `zsh`, *Windows PowerShell*, etc.); - your system (Debian 7, ArchLinux, Windows, etc.); - how to reproduce the bug; - the output of The Fuck with `THEFUCK_DEBUG=true` exported (typically execute `export THEFUCK_DEBUG=true` in your shell before The Fuck); - if the bug only appears with a specific application, the output of that application and its version; - anything else you think is relevant. It's only with enough information that we can do something to fix the problem. # Make a pull request We gladly accept pull request on the [official repository](https://github.com/nvbn/thefuck) for new rules, new features, bug fixes, etc. # Developing In order to develop locally, there are two options: - Develop using a local installation of Python 3 and setting up a virtual environment - Develop using an automated VSCode Dev Container. ## Develop using local Python installation [Create and activate a Python 3 virtual environment.](https://docs.python.org/3/tutorial/venv.html) Install `The Fuck` for development: ```bash pip install -r requirements.txt python setup.py develop ``` Run code style checks: ```bash flake8 ``` Run unit tests: ```bash py.test ``` Run unit and functional tests (requires docker): ```bash py.test --enable-functional ``` For sending package to pypi: ```bash sudo apt-get install pandoc ./release.py ``` ## Develop using Dev Container To make local development easier a [VSCode Devcontainer](https://code.visualstudio.com/docs/remote/remote-overview) is included with this repository. This will allows you to spin up a Docker container with all the necessary prerequisites for this project pre-installed ready to go, no local Python install/setup required. ### Prerequisites To use the container you require: - [Docker](https://www.docker.com/products/docker-desktop) - [VSCode](https://code.visualstudio.com/) - [VSCode Remote Development Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) - [Windows Users Only]: [Installation of WSL2 and configuration of Docker to use it](https://docs.docker.com/docker-for-windows/wsl/) Full notes about [installation are here](https://code.visualstudio.com/docs/remote/containers#_installation) ### Running the container Assuming you have the prerequisites: 1. Open VSCode 1. Open command palette (CMD+SHIFT+P (mac) or CTRL+SHIFT+P (windows)) 1. Select `Remote-Containers: Reopen in Container`. 1. Container will be built, install all pip requirements and your VSCode will mount into it automagically. 1. Your VSCode and container now essentially become a throw away environment.thefuck-3.32/LICENSE.md000066400000000000000000000021271416441634500145100ustar00rootroot00000000000000The MIT License (MIT) ===================== Copyright (c) 2015-2021 Vladimir Iakovlev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. thefuck-3.32/MANIFEST.in000066400000000000000000000000561416441634500146410ustar00rootroot00000000000000include LICENSE.md include fastentrypoints.py thefuck-3.32/README.md000066400000000000000000000631211416441634500143640ustar00rootroot00000000000000# The Fuck [![Version][version-badge]][version-link] [![Build Status][workflow-badge]][workflow-link] [![Coverage][coverage-badge]][coverage-link] [![MIT License][license-badge]](LICENSE.md) *The Fuck* is a magnificent app, inspired by a [@liamosaur](https://twitter.com/liamosaur/) [tweet](https://twitter.com/liamosaur/status/506975850596536320), that corrects errors in previous console commands. Is *The Fuck* too slow? [Try the experimental instant mode!](#experimental-instant-mode) [![gif with examples][examples-link]][examples-link] More examples: ```bash ➜ 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 ... ``` ```bash ➜ 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. ... ``` ```bash ➜ 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) ... ``` ```bash ➜ git brnch git: 'brnch' is not a git command. See 'git --help'. Did you mean this? branch ➜ fuck git branch [enter/↑/↓/ctrl+c] * master ``` ```bash ➜ 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](#settings) option can be disabled: ```bash ➜ 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](#requirements) 2. [Installations](#installation) 3. [Updating](#updating) 4. [How it works](#how-it-works) 5. [Creating your own rules](#creating-your-own-rules) 6. [Settings](#settings) 7. [Third party packages with rules](#third-party-packages-with-rules) 8. [Experimental instant mode](#experimental-instant-mode) 9. [Developing](#developing) 10. [License](#license-mit) ## Requirements - python (3.4+) - pip - python-dev ##### [Back to Contents](#contents) ## Installation On macOS or Linux, you can install *The Fuck* via [Homebrew][homebrew]: ```bash brew install thefuck ``` On Ubuntu / Mint, install *The Fuck* with the following commands: ```bash 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: ```bash pkg install thefuck ``` On ChromeOS, install *The Fuck* using [chromebrew](https://github.com/skycocker/chromebrew) with the following command: ```bash crew install thefuck ``` On other systems, install *The Fuck* by using `pip`: ```bash pip install thefuck ``` [Alternatively, you may use an OS package manager (OS X, Ubuntu, Arch).](https://github.com/nvbn/thefuck/wiki/Installation) # It is recommended that you place this command in your `.bash_profile`, `.bashrc`, `.zshrc` or other startup script: ```bash 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).](https://github.com/nvbn/thefuck/wiki/Shell-aliases) 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): ```bash fuck --yeah ``` To fix commands recursively until succeeding, use the `-r` option: ```bash fuck -r ``` ##### [Back to Contents](#contents) ## Updating ```bash pip3 install thefuck --upgrade ``` **Note: Alias functionality was changed in v1.34 of *The Fuck*** ## Uninstall To remove *The Fuck*, reverse the installation process: - erase or comment *thefuck* alias line from your Bash, Zsh, Fish, Powershell, tcsh, ... shell config - use your package manager (brew, pip3, pkg, crew, pip) to uninstall the binaries ## 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_cs` – changes `cs` to `cd`; * `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; * `conda_mistype` – fixes conda commands; * `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 ...` 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_branch_0flag` – fixes commands such as `git branch 0v` and `git branch 0r` removing the 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_add` – offers `git commit -a ...` or `git commit -p ...` after previous commit if it failed because nothing was staged; * `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 ` 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 ` commands; * `git_main_master` – fixes incorrect branch name between `main` and `master` * `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 branch 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 ` 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 ` to `heroku` commands like `heroku pg`; * `heroku_not_command` – fixes wrong `heroku` commands like `heroku log`; * `history` – tries to replace command with the 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 a 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