mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Merge branch 'master' of github.com:nvbn/thefuck
This commit is contained in:
		| @@ -157,6 +157,7 @@ using matched rule and run it. Rules enabled by default: | |||||||
| * `brew_unknown_command` – fixes wrong brew commands, for example `brew docto/brew doctor`; | * `brew_unknown_command` – fixes wrong brew commands, for example `brew docto/brew doctor`; | ||||||
| * `cd_parent` – changes `cd..` to `cd ..`; | * `cd_parent` – changes `cd..` to `cd ..`; | ||||||
| * `cp_omitting_directory` – adds `-a` when you `cp` directory; | * `cp_omitting_directory` – adds `-a` when you `cp` directory; | ||||||
|  | * `fix_alt_space` – replaces Alt+Space with Space character; | ||||||
| * `git_no_command` – fixes wrong git commands like `git brnch`; | * `git_no_command` – fixes wrong git commands like `git brnch`; | ||||||
| * `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`; | * `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`; | ||||||
| * `has_exists_script` – prepends `./` when script/binary exists; | * `has_exists_script` – prepends `./` when script/binary exists; | ||||||
|   | |||||||
							
								
								
									
										18
									
								
								tests/rules/test_fix_alt_space.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								tests/rules/test_fix_alt_space.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | |||||||
|  | # -*- encoding: utf-8 -*- | ||||||
|  |  | ||||||
|  |  | ||||||
|  | from thefuck.types import Command | ||||||
|  | from thefuck.rules.fix_alt_space import match, get_new_command | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def test_match(): | ||||||
|  |     """ The character before 'grep' is Alt+Space, which happens frequently on the Mac when typing | ||||||
|  |         the pipe character (Alt+7), and holding the Alt key pressed for longer than necessary. """ | ||||||
|  |     assert match(Command(u'ps -ef | grep foo', '', u'-bash:  grep: command not found'), None) | ||||||
|  |     assert not match(Command('ps -ef | grep foo', '', ''), None) | ||||||
|  |     assert not match(Command('', '', ''), None) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def test_get_new_command(): | ||||||
|  |     """ Replace the Alt+Space character by a simple space """ | ||||||
|  |     assert get_new_command(Command(u'ps -ef | grep foo', '', ''), None) == 'ps -ef | grep foo' | ||||||
							
								
								
									
										15
									
								
								thefuck/rules/fix_alt_space.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								thefuck/rules/fix_alt_space.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | # -*- encoding: utf-8 -*- | ||||||
|  |  | ||||||
|  | import re | ||||||
|  | from thefuck.utils import sudo_support | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @sudo_support | ||||||
|  | def match(command, settings): | ||||||
|  |     return ('command not found' in command.stderr.lower() | ||||||
|  |             and u' ' in command.script) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @sudo_support | ||||||
|  | def get_new_command(command, settings): | ||||||
|  |     return re.sub(u' ', ' ', command.script) | ||||||
		Reference in New Issue
	
	Block a user