mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	Merge branch 'master' of github.com:nvbn/thefuck
This commit is contained in:
		| @@ -176,6 +176,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: | |||||||
| * `ls_lah` – adds -lah to ls; | * `ls_lah` – adds -lah to ls; | ||||||
| * `man` – change manual section; | * `man` – change manual section; | ||||||
| * `man_no_space` – fixes man commands without spaces, for example `mandiff`; | * `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; | * `mkdir_p` – adds `-p` when you trying to create directory without parent; | ||||||
| * `no_command` – fixes wrong console commands, for example `vom/vim`; | * `no_command` – fixes wrong console commands, for example `vom/vim`; | ||||||
| * `no_such_file` – creates missing directories with `mv` and `cp` commands; | * `no_such_file` – creates missing directories with `mv` and `cp` commands; | ||||||
| @@ -185,7 +186,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: | |||||||
| * `python_execute` – appends missing `.py` when executing Python files; | * `python_execute` – appends missing `.py` when executing Python files; | ||||||
| * `quotation_marks` – fixes uneven usage of `'` and `"` when containing args' | * `quotation_marks` – fixes uneven usage of `'` and `"` when containing args' | ||||||
| * `rm_dir` – adds `-rf` when you trying to remove directory; | * `rm_dir` – adds `-rf` when you trying to remove directory; | ||||||
| * `sed` – adds missing '/' to `sed`'s `s` commands; | * `sed_unterminated_s` – adds missing '/' to `sed`'s `s` commands; | ||||||
| * `sl_ls` – changes `sl` to `ls`; | * `sl_ls` – changes `sl` to `ls`; | ||||||
| * `ssh_known_hosts` – removes host from `known_hosts` on warning; | * `ssh_known_hosts` – removes host from `known_hosts` on warning; | ||||||
| * `sudo` – prepends `sudo` to previous command if it failed because of permissions; | * `sudo` – prepends `sudo` to previous command if it failed because of permissions; | ||||||
|   | |||||||
| @@ -16,4 +16,4 @@ def test_match(tmux_ambiguous): | |||||||
|  |  | ||||||
| def test_get_new_command(tmux_ambiguous): | def test_get_new_command(tmux_ambiguous): | ||||||
|     assert get_new_command(Command('tmux list', stderr=tmux_ambiguous), None)\ |     assert get_new_command(Command('tmux list', stderr=tmux_ambiguous), None)\ | ||||||
|         == 'tmux list-buffers' |         == 'tmux list-keys' | ||||||
|   | |||||||
| @@ -13,7 +13,8 @@ patterns = ['permission denied', | |||||||
|             'must be root', |             'must be root', | ||||||
|             'need to be root', |             'need to be root', | ||||||
|             'need root', |             'need root', | ||||||
|             'only root can do that'] |             'only root can do that', | ||||||
|  |             'authentication is required'] | ||||||
|  |  | ||||||
|  |  | ||||||
| def match(command, settings): | def match(command, settings): | ||||||
|   | |||||||
| @@ -1,3 +1,4 @@ | |||||||
|  | from thefuck.utils import get_closest | ||||||
| import re | import re | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -8,7 +9,12 @@ def match(command, settings): | |||||||
|  |  | ||||||
|  |  | ||||||
| def get_new_command(command, settings): | def get_new_command(command, settings): | ||||||
|     cmd = re.match(r"ambiguous command: (.*), could be: ([^, \n]*)", |     cmd = re.match(r"ambiguous command: (.*), could be: (.*)", | ||||||
|                    command.stderr) |                    command.stderr) | ||||||
|  |  | ||||||
|     return command.script.replace(cmd.group(1), cmd.group(2)) |     old_cmd = cmd.group(1) | ||||||
|  |     suggestions = [cmd.strip() for cmd in cmd.group(2).split(',')] | ||||||
|  |  | ||||||
|  |     new_cmd = get_closest(old_cmd, suggestions) | ||||||
|  |  | ||||||
|  |     return command.script.replace(old_cmd, new_cmd) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user