From afc089bc3c673d028eb6523888913b2534d038db Mon Sep 17 00:00:00 2001 From: mcarton Date: Mon, 20 Jul 2015 13:06:57 +0200 Subject: [PATCH 1/5] Be more consistent in README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bc65acdf..2fea7ba3 100644 --- a/README.md +++ b/README.md @@ -138,12 +138,12 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `cd_parent` – changes `cd..` to `cd ..`; * `composer_not_command` – fixes composer command name; * `cp_omitting_directory` – adds `-a` when you `cp` directory; -* `cpp11` – add missing `-std=c++11` to `g++` or `clang++`; +* `cpp11` – adds missing `-std=c++11` to `g++` or `clang++`; * `django_south_ghost` – adds `--delete-ghost-migrations` to failed because ghosts django south migration; * `django_south_merge` – adds `--merge` to inconsistent django south migration; -* `dry` – fix repetitions like "git git push"; +* `dry` – fixes repetitions like "git git push"; * `fix_alt_space` – replaces Alt+Space with Space character; -* `git_add` – fix *"Did you forget to 'git add'?"*; +* `git_add` – fixes *"Did you forget to 'git add'?"*; * `git_branch_delete` – changes `git branch -d` to `git branch -D`; * `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; @@ -162,7 +162,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `javac` – appends missing `.java` when compiling Java files; * `lein_not_task` – fixes wrong `lein` tasks like `lein rpl`; * `ls_lah` – adds -lah to ls; -* `man` – change manual section; +* `man` – changes manual section; * `man_no_space` – fixes man commands without spaces, for example `mandiff`; * `mercurial` – fixes wrong `hg` commands; * `mkdir_p` – adds `-p` when you trying to create directory without parent; @@ -243,7 +243,7 @@ The Fuck has a few settings parameters which can be changed in `~/.thefuck/setti * `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`; +* `debug` – enables debug output, by default `False`. Example of `settings.py`: From d4fada8e4c7478f0258871e28d16ec45b28b5506 Mon Sep 17 00:00:00 2001 From: mcarton Date: Mon, 20 Jul 2015 21:06:59 +0200 Subject: [PATCH 2/5] Reflect the new default for require_confirmation --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2fea7ba3..fbb28e42 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ 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 apt-get install vim [Enter/Ctrl+C] [sudo] password for nvbn: Reading package lists... Done ... @@ -29,7 +29,7 @@ To push the current branch and set the remote as upstream, use ➜ fuck -git push --set-upstream origin master +git push --set-upstream origin master [Enter/Ctrl+C] Counting objects: 9, done. ... ``` @@ -42,7 +42,7 @@ No command 'puthon' found, did you mean: zsh: command not found: puthon ➜ fuck -python +python [Enter/Ctrl+C] Python 3.4.2 (default, Oct 8 2014, 13:08:17) ... ``` @@ -55,7 +55,7 @@ Did you mean this? branch ➜ fuck -git branch +git branch [Enter/Ctrl+C] * master ``` @@ -67,13 +67,13 @@ Did you mean this? repl ➜ fuck -lein repl +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 are scared to blindly run the changed command, there is a `require_confirmation` +If you are not scared to blindly run the changed command, there is a `require_confirmation` [settings](#settings) option: ```bash @@ -82,7 +82,7 @@ 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 apt-get install vim [sudo] password for nvbn: Reading package lists... Done ... From 33b1536c286c65c42265278bd06ca726c7c79b1e Mon Sep 17 00:00:00 2001 From: mcarton Date: Mon, 20 Jul 2015 21:07:56 +0200 Subject: [PATCH 3/5] Move misplaced rule in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fbb28e42..3238f454 100644 --- a/README.md +++ b/README.md @@ -190,11 +190,11 @@ Enabled by default only on specific platforms: * `brew_install` – fixes formula name for `brew install`; * `brew_unknown_command` – fixes wrong brew commands, for example `brew docto/brew doctor`; * `brew_upgrade` – appends `--all` to `brew upgrade` as per Homebrew's new behaviour; -* `git_push_force` – adds `--force` to a `git push` (may conflict with `git_push_pull`); * `pacman` – installs app with `pacman` or `yaourt` if it is not installed. Bundled, but not enabled by default: +* `git_push_force` – adds `--force` to a `git push` (may conflict with `git_push_pull`); * `rm_root` – adds `--no-preserve-root` to `rm -rf /` command. ## Creating your own rules From e572cab1f3a13b0536e58cc7070a4d8cfbebb2ba Mon Sep 17 00:00:00 2001 From: mcarton Date: Mon, 20 Jul 2015 21:08:46 +0200 Subject: [PATCH 4/5] Have the README look better --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3238f454..f1ba1a1e 100644 --- a/README.md +++ b/README.md @@ -200,16 +200,19 @@ Bundled, but not enabled by default: ## Creating your own rules For adding your own rule you should create `your-rule-name.py` -in `~/.thefuck/rules`. Rule should contain two functions: -`match(command: Command, settings: Settings) -> bool` -and `get_new_command(command: Command, settings: Settings) -> str`. -Also the rule can contain optional function -`side_effect(command: Command, settings: Settings) -> None` and +in `~/.thefuck/rules`. The rule should contain two functions: +```python +match(command: Command, settings: Settings) -> bool +get_new_command(command: Command, settings: Settings) -> str +``` + +Also the rule can contain an optional function +`side_effect(command: Command, settings: Settings) -> None` and an optional boolean `enabled_by_default`. `Command` has three attributes: `script`, `stdout` and `stderr`. -`Settings` is a special object filled with `~/.thefuck/settings.py` and values from env, [more](#settings). +`Settings` is a special object filled with `~/.thefuck/settings.py` and values from env ([see more below](#settings)). Simple example of the rule for running script with `sudo`: From 92cca7b6418b0db0d618ca7e0f9a96efce289af6 Mon Sep 17 00:00:00 2001 From: nvbn Date: Mon, 20 Jul 2015 22:49:21 +0300 Subject: [PATCH 5/5] #296 Fix `[enter/ctrl+c]` case in the readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f1ba1a1e..ef6c01a1 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ 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 apt-get install vim [enter/ctrl+c] [sudo] password for nvbn: Reading package lists... Done ... @@ -29,7 +29,7 @@ To push the current branch and set the remote as upstream, use ➜ fuck -git push --set-upstream origin master [Enter/Ctrl+C] +git push --set-upstream origin master [enter/ctrl+c] Counting objects: 9, done. ... ``` @@ -42,7 +42,7 @@ No command 'puthon' found, did you mean: zsh: command not found: puthon ➜ fuck -python [Enter/Ctrl+C] +python [enter/ctrl+c] Python 3.4.2 (default, Oct 8 2014, 13:08:17) ... ``` @@ -55,7 +55,7 @@ Did you mean this? branch ➜ fuck -git branch [Enter/Ctrl+C] +git branch [enter/ctrl+c] * master ``` @@ -67,7 +67,7 @@ Did you mean this? repl ➜ fuck -lein repl [Enter/Ctrl+C] +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 ...