diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..f65e6333 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 + +[*.py] +max_line_length = 119 diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index aac757a9..4c0b95a1 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -6,17 +6,14 @@ update The Fuck and see if the bug is still there. --> 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`): - - FILL THIS IN - -Your shell and its version (`bash`, `zsh`, *Windows PowerShell*, etc.): +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: @@ -32,6 +29,6 @@ If the bug only appears with a specific application, the output of that applicat Anything else you think is relevant: - + FILL THIS IN diff --git a/.travis.yml b/.travis.yml index 3bc2c4a6..f4b3b60a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,25 @@ language: python sudo: false +os: linux +dist: xenial matrix: include: - - os: linux - dist: trusty - python: "3.6" - - os: linux - dist: trusty - python: "3.5" - - os: linux - dist: trusty - python: "3.4" - - os: linux - dist: trusty - python: "2.7" + - python: "nightly" + - python: "3.8-dev" + - python: "3.8" + - python: "3.7-dev" + - python: "3.7" + - python: "3.6-dev" + - python: "3.6" + - python: "3.5" + - python: "2.7" - os: osx - env: FORMULA="python" - language: generic - - os: osx - env: FORMULA="python3" language: generic + allow_failures: + - python: nightly + - python: 3.8-dev + - python: 3.7-dev + - python: 3.6-dev services: - docker addons: @@ -28,9 +28,11 @@ addons: - python-commandnotfound - python3-commandnotfound before_install: - - if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew update ; fi - - if [[ $TRAVIS_OS_NAME == "osx" ]]; then if brew ls --versions $FORMULA; then brew upgrade $FORMULA || echo Python is up to date; else brew install $FORMULA; fi; fi - - if [[ $TRAVIS_OS_NAME == "osx" ]]; then virtualenv venv -p $FORMULA; fi + - if [[ $TRAVIS_OS_NAME == "osx" ]]; then rm -rf /usr/local/include/c++; fi + - if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew update; fi + - if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew upgrade python; fi + - if [[ $TRAVIS_OS_NAME == "osx" ]]; then pip3 install virtualenv; fi + - if [[ $TRAVIS_OS_NAME == "osx" ]]; then virtualenv venv -p python3; fi - if [[ $TRAVIS_OS_NAME == "osx" ]]; then source venv/bin/activate; fi - pip install -U pip - pip install -U coveralls @@ -42,7 +44,7 @@ script: - flake8 - export COVERAGE_PYTHON_VERSION=python-${TRAVIS_PYTHON_VERSION:0:1} - export RUN_TESTS="coverage run --source=thefuck,tests -m py.test -v --capture=sys tests" - - if [[ $TRAVIS_PYTHON_VERSION == 3.6 && $TRAVIS_OS_NAME != "osx" ]]; then $RUN_TESTS --enable-functional; fi - - if [[ $TRAVIS_PYTHON_VERSION != 3.6 || $TRAVIS_OS_NAME == "osx" ]]; then $RUN_TESTS; fi + - if [[ $TRAVIS_PYTHON_VERSION == 3.8 && $TRAVIS_OS_NAME != "osx" ]]; then $RUN_TESTS --enable-functional; fi + - if [[ $TRAVIS_PYTHON_VERSION != 3.8 || $TRAVIS_OS_NAME == "osx" ]]; then $RUN_TESTS; fi after_success: - - if [[ $TRAVIS_PYTHON_VERSION == 3.6 && $TRAVIS_OS_NAME != "osx" ]]; then coveralls; fi + - if [[ $TRAVIS_PYTHON_VERSION == 3.8 && $TRAVIS_OS_NAME != "osx" ]]; then coveralls; fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 592a8acf..33b193da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,8 @@ fixes, etc. # Developing +[Create and activate a Python 3 virtual environment.](https://docs.python.org/3/tutorial/venv.html) + Install `The Fuck` for development: ```bash diff --git a/README.md b/README.md index 7505717f..4ff50cd2 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # The Fuck [![Version][version-badge]][version-link] [![Build Status][travis-badge]][travis-link] [![Windows Build Status][appveyor-badge]][appveyor-link] [![Coverage][coverage-badge]][coverage-link] [![MIT License][license-badge]](LICENSE.md) -Magnificent app which corrects your previous console command, -inspired by a [@liamosaur](https://twitter.com/liamosaur/) -[tweet](https://twitter.com/liamosaur/status/506975850596536320). +*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. -The Fuck is too slow? [Try experimental instant mode!](#experimental-instant-mode) + +Is *The Fuck* too slow? [Try the experimental instant mode!](#experimental-instant-mode) [![gif with examples][examples-link]][examples-link] -Few more examples: +More examples: ```bash ➜ apt-get install vim @@ -75,8 +76,8 @@ REPL-y 0.3.1 ... ``` -If you are not scared to blindly run the changed command, there is a `require_confirmation` -[settings](#settings) option: +If you're not afraid of blindly running corrected commands, the +`require_confirmation` [settings](#settings) option can be disabled: ```bash ➜ apt-get install vim @@ -98,29 +99,40 @@ Reading package lists... Done ## Installation -On OS X you can install `The Fuck` with [Homebrew][homebrew]: +On OS X, you can install *The Fuck* via [Homebrew][homebrew] (or via [Linuxbrew][linuxbrew] on Linux): ```bash brew install thefuck ``` -On Ubuntu you can install `The Fuck` with: +On Ubuntu / Mint, install *The Fuck* with the following commands: ```bash sudo apt update -sudo apt install python3-dev python3-pip +sudo apt install python3-dev python3-pip python3-setuptools sudo pip3 install thefuck ``` -On other systems you can install `The Fuck` with `pip`: +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 ``` -[Or using an OS package manager (OS X, Ubuntu, Arch).](https://github.com/nvbn/thefuck/wiki/Installation) +[Alternatively, you may use an OS package manager (OS X, Ubuntu, Arch).](https://github.com/nvbn/thefuck/wiki/Installation) # -You should place this command in your `.bash_profile`, `.bashrc`, `.zshrc` or other startup script: +It is recommended that you place this command in your `.bash_profile`, +`.bashrc`, `.zshrc` or other startup script: ```bash eval $(thefuck --alias) @@ -130,43 +142,47 @@ eval $(thefuck --alias FUCK) [Or in your shell config (Bash, Zsh, Fish, Powershell, tcsh).](https://github.com/nvbn/thefuck/wiki/Shell-aliases) -Changes will be available only in a new shell session. -To make them available immediately, run `source ~/.bashrc` (or your shell config file like `.zshrc`). +Changes are only available in a new shell session. To make changes immediately +available, run `source ~/.bashrc` (or your shell config file like `.zshrc`). -If you want to run fixed command without confirmation you can use `-y` option: +To run fixed commands without confirmation, use the `--yeah` option (or just `-y` for short, or `--hard` if you're especially frustrated): ```bash -fuck -y +fuck --yeah ``` -If you want to fix commands recursively until success you can use `-r` option: +To fix commands recursively until succeeding, use the `-r` option: ```bash fuck -r ``` -## Update +## Updating ```bash pip3 install thefuck --upgrade ``` -**Aliases changed in 1.34.** +**Note: Alias functionality was changed in v1.34 of *The Fuck*** ## How it works -The Fuck tries to match a rule for the previous command, creates a new command -using the matched rule and runs it. Rules enabled by default are as follows: +*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_omitting_directory` – adds `-a` when you `cp` directory; * `cpp11` – adds missing `-std=c++11` to `g++` or `clang++`; @@ -174,7 +190,9 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `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; @@ -184,16 +202,19 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `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_checkout` – fixes branch name or creates new branch; * `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_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; @@ -208,16 +229,17 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `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 nonexistant remote; +* `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 trying to `grep` directory; +* `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; @@ -229,6 +251,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `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; @@ -237,26 +260,29 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `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 trying to create directory without parent; +* `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 lifecycle phases with `mvn`; +* `mvn_unknown_lifecycle_phase` – fixes misspelled life cycle phases with `mvn`; * `npm_missing_script` – fixes `npm` custom script name in `npm run-script