mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-11-04 00:52:04 +00:00 
			
		
		
		
	Compare commits
	
		
			11 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					f082ba829f | ||
| 
						 | 
					112e20d7c5 | ||
| 
						 | 
					95007220fb | ||
| 
						 | 
					56f636f3d8 | ||
| 
						 | 
					932a7c5db5 | ||
| 
						 | 
					1bed4d4e8d | ||
| 
						 | 
					e0bba379ff | ||
| 
						 | 
					045959ec47 | ||
| 
						 | 
					65aeea857e | ||
| 
						 | 
					793e883073 | ||
| 
						 | 
					a395ac568c | 
@@ -144,14 +144,17 @@ using matched rule and run it. Rules enabled by default:
 | 
				
			|||||||
* `cd_parent` – changes `cd..` to `cd ..`;
 | 
					* `cd_parent` – changes `cd..` to `cd ..`;
 | 
				
			||||||
* `cd_mkdir` – creates directories before cd'ing into them;
 | 
					* `cd_mkdir` – creates directories before cd'ing into them;
 | 
				
			||||||
* `cp_omitting_directory` – adds `-a` when you `cp` directory;
 | 
					* `cp_omitting_directory` – adds `-a` when you `cp` directory;
 | 
				
			||||||
 | 
					* `dry` – fix repetitions like "git git push";
 | 
				
			||||||
* `fix_alt_space` – replaces Alt+Space with Space character;
 | 
					* `fix_alt_space` – replaces Alt+Space with Space character;
 | 
				
			||||||
* `git_add` – fix *"Did you forget to 'git add'?"*;
 | 
					* `git_add` – fix *"Did you forget to 'git add'?"*;
 | 
				
			||||||
 | 
					* `git_checkout` – creates the branch before checking-out;
 | 
				
			||||||
* `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;
 | 
				
			||||||
* `lein_not_task` – fixes wrong `lein` tasks like `lein rpl`;
 | 
					* `lein_not_task` – fixes wrong `lein` tasks like `lein rpl`;
 | 
				
			||||||
* `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`;
 | 
				
			||||||
 | 
					* `man_no_space` – fixes man commands without spaces, for example `mandiff`;
 | 
				
			||||||
* `pacman` – installs app with `pacman` or `yaourt` if it is not installed;
 | 
					* `pacman` – installs app with `pacman` or `yaourt` if it is not installed;
 | 
				
			||||||
* `pip_unknown_command` – fixes wrong pip commands, for example `pip instatl/pip install`;
 | 
					* `pip_unknown_command` – fixes wrong pip commands, for example `pip instatl/pip install`;
 | 
				
			||||||
* `python_command` – prepends `python` when you trying to run not executable/without `./` python script;
 | 
					* `python_command` – prepends `python` when you trying to run not executable/without `./` python script;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
				
			|||||||
from setuptools import setup, find_packages
 | 
					from setuptools import setup, find_packages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
VERSION = '1.37'
 | 
					VERSION = '1.38'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
setup(name='thefuck',
 | 
					setup(name='thefuck',
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								tests/rules/test_dry.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/rules/test_dry.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					import pytest
 | 
				
			||||||
 | 
					from thefuck.rules.dry import match, get_new_command
 | 
				
			||||||
 | 
					from tests.utils import Command
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@pytest.mark.parametrize('command', [
 | 
				
			||||||
 | 
					    Command(script='cd cd foo'),
 | 
				
			||||||
 | 
					    Command(script='git git push origin/master')])
 | 
				
			||||||
 | 
					def test_match(command):
 | 
				
			||||||
 | 
					    assert match(command, None)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@pytest.mark.parametrize('command, new_command', [
 | 
				
			||||||
 | 
					    (Command('cd cd foo'), 'cd foo'),
 | 
				
			||||||
 | 
					    (Command('git git push origin/master'), 'git push origin/master')])
 | 
				
			||||||
 | 
					def test_get_new_command(command, new_command):
 | 
				
			||||||
 | 
					    assert get_new_command(command, None) == new_command
 | 
				
			||||||
							
								
								
									
										12
									
								
								tests/rules/test_man_no_space.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/rules/test_man_no_space.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					from thefuck.rules.man_no_space import match, get_new_command
 | 
				
			||||||
 | 
					from tests.utils import Command
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_match():
 | 
				
			||||||
 | 
					    assert match(Command('mandiff', stderr='mandiff: command not found'), None)
 | 
				
			||||||
 | 
					    assert not match(Command(), None)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_get_new_command():
 | 
				
			||||||
 | 
					    assert get_new_command(
 | 
				
			||||||
 | 
					        Command('mandiff'), None) == 'man diff'
 | 
				
			||||||
							
								
								
									
										12
									
								
								thefuck/rules/dry.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								thefuck/rules/dry.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					def match(command, settings):
 | 
				
			||||||
 | 
					    split_command = command.script.split()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return len(split_command) >= 2 and split_command[0] == split_command[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_new_command(command, settings):
 | 
				
			||||||
 | 
					    return command.script[command.script.find(' ')+1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# it should be rare enough to actually have to type twice the same word, so
 | 
				
			||||||
 | 
					# this rule can have a higher priority to come before things like "cd cd foo"
 | 
				
			||||||
 | 
					priority = 900
 | 
				
			||||||
							
								
								
									
										15
									
								
								thefuck/rules/git_checkout.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								thefuck/rules/git_checkout.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					import re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def match(command, settings):
 | 
				
			||||||
 | 
					    return ('git' in command.script
 | 
				
			||||||
 | 
					            and 'did not match any file(s) known to git.' in command.stderr
 | 
				
			||||||
 | 
					            and "Did you forget to 'git add'?" not in command.stderr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_new_command(command, settings):
 | 
				
			||||||
 | 
					    missing_file = re.findall(
 | 
				
			||||||
 | 
					            r"error: pathspec '([^']*)' "
 | 
				
			||||||
 | 
					            "did not match any file\(s\) known to git.", command.stderr)[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 'git branch {} && {}'.format(missing_file, command.script)
 | 
				
			||||||
							
								
								
									
										9
									
								
								thefuck/rules/man_no_space.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								thefuck/rules/man_no_space.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					def match(command, settings):
 | 
				
			||||||
 | 
					    return (command.script.startswith(u'man')
 | 
				
			||||||
 | 
					            and u'command not found' in command.stderr.lower())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_new_command(command, settings):
 | 
				
			||||||
 | 
					    return u'man {}'.format(command.script[3:])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					priority = 2000
 | 
				
			||||||
		Reference in New Issue
	
	Block a user