mirror of
https://github.com/nvbn/thefuck.git
synced 2025-11-01 07:32:09 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bbba9a0c8 | ||
|
|
b978c3793e | ||
|
|
8a83b30e73 | ||
|
|
fd20a3f832 | ||
|
|
b6ed499103 | ||
|
|
76600cf40a | ||
|
|
e62666181a | ||
|
|
c88b0792b8 | ||
|
|
06a89427e2 |
@@ -106,13 +106,13 @@ On Ubuntu you can install `The Fuck` with:
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install python3-dev python3-pip
|
||||
pip3 install --user thefuck
|
||||
sudo pip3 install thefuck
|
||||
```
|
||||
|
||||
On other systems you can install `The Fuck` with `pip`:
|
||||
|
||||
```bash
|
||||
pip install --user thefuck
|
||||
pip install thefuck
|
||||
```
|
||||
|
||||
[Or using an OS package manager (OS X, Ubuntu, Arch).](https://github.com/nvbn/thefuck/wiki/Installation)
|
||||
@@ -139,7 +139,7 @@ alias fuck-it='export THEFUCK_REQUIRE_CONFIRMATION=False; fuck; export THEFUCK_R
|
||||
## Update
|
||||
|
||||
```bash
|
||||
pip install --user thefuck --upgrade
|
||||
pip install thefuck --upgrade
|
||||
```
|
||||
|
||||
**Aliases changed in 1.34.**
|
||||
|
||||
2
setup.py
2
setup.py
@@ -29,7 +29,7 @@ elif (3, 0) < version < (3, 3):
|
||||
' ({}.{} detected).'.format(*version))
|
||||
sys.exit(-1)
|
||||
|
||||
VERSION = '3.17'
|
||||
VERSION = '3.19'
|
||||
|
||||
install_requires = ['psutil', 'colorama', 'six', 'decorator']
|
||||
extras_require = {':python_version<"3.4"': ['pathlib2'],
|
||||
|
||||
@@ -39,7 +39,6 @@ parametrize_extensions = pytest.mark.parametrize('ext', tar_extensions)
|
||||
# (filename as typed by the user, unquoted filename, quoted filename as per shells.quote)
|
||||
parametrize_filename = pytest.mark.parametrize('filename, unquoted, quoted', [
|
||||
('foo{}', 'foo{}', 'foo{}'),
|
||||
('foo\ bar{}', 'foo bar{}', "'foo bar{}'"),
|
||||
('"foo bar{}"', 'foo bar{}', "'foo bar{}'")])
|
||||
|
||||
parametrize_script = pytest.mark.parametrize('script, fixed', [
|
||||
|
||||
@@ -64,7 +64,6 @@ def test_side_effect(zip_error, script, filename):
|
||||
@pytest.mark.parametrize('script,fixed,filename', [
|
||||
(u'unzip café', u"unzip café -d 'café'", u'café.zip'),
|
||||
(u'unzip foo', u'unzip foo -d foo', u'foo.zip'),
|
||||
(u"unzip foo\\ bar.zip", u"unzip foo\\ bar.zip -d 'foo bar'", u'foo.zip'),
|
||||
(u"unzip 'foo bar.zip'", u"unzip 'foo bar.zip' -d 'foo bar'", u'foo.zip'),
|
||||
(u'unzip foo.zip', u'unzip foo.zip -d foo', u'foo.zip')])
|
||||
def test_get_new_command(zip_error, script, fixed, filename):
|
||||
|
||||
@@ -7,7 +7,7 @@ from tests.utils import Command
|
||||
def git_not_command():
|
||||
return """git: 'brnch' is not a git command. See 'git --help'.
|
||||
|
||||
Did you mean this?
|
||||
The most similar command is
|
||||
branch
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@ branch
|
||||
def git_not_command_one_of_this():
|
||||
return """git: 'st' is not a git command. See 'git --help'.
|
||||
|
||||
Did you mean one of these?
|
||||
The most similar commands are
|
||||
status
|
||||
reset
|
||||
stage
|
||||
@@ -29,7 +29,7 @@ stats
|
||||
def git_not_command_closest():
|
||||
return '''git: 'tags' is not a git command. See 'git --help'.
|
||||
|
||||
Did you mean one of these?
|
||||
The most similar commands are
|
||||
\tstage
|
||||
\ttag
|
||||
'''
|
||||
|
||||
@@ -6,12 +6,13 @@ from thefuck.specific.git import git_support
|
||||
@git_support
|
||||
def match(command):
|
||||
return (" is not a git command. See 'git --help'." in command.stderr
|
||||
and 'Did you mean' in command.stderr)
|
||||
and ('The most similar command' in command.stderr
|
||||
or 'Did you mean' in command.stderr))
|
||||
|
||||
|
||||
@git_support
|
||||
def get_new_command(command):
|
||||
broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
|
||||
command.stderr)[0]
|
||||
matched = get_all_matched_commands(command.stderr)
|
||||
matched = get_all_matched_commands(command.stderr, ['The most similar command', 'Did you mean'])
|
||||
return replace_command(command, broken_cmd, matched)
|
||||
|
||||
@@ -11,12 +11,14 @@ class Bash(Generic):
|
||||
return '''
|
||||
function {name} () {{
|
||||
TF_PREVIOUS=$(fc -ln -1);
|
||||
TF_PYTHONIOENCODING=$PYTHONIOENCODING;
|
||||
export TF_ALIAS={name};
|
||||
export TF_SHELL_ALIASES=$(alias);
|
||||
export PYTHONIOENCODING=utf-8;
|
||||
TF_CMD=$(
|
||||
export TF_ALIAS={name}
|
||||
export TF_SHELL_ALIASES=$(alias)
|
||||
export PYTHONIOENCODING=utf-8
|
||||
thefuck $TF_PREVIOUS {argument_placeholder} $@
|
||||
) && eval $TF_CMD;
|
||||
export PYTHONIOENCODING=$TF_PYTHONIOENCODING;
|
||||
{alter_history}
|
||||
}}
|
||||
'''.format(
|
||||
|
||||
@@ -77,7 +77,7 @@ class Generic(object):
|
||||
encoded = self.encode_utf8(command)
|
||||
|
||||
try:
|
||||
splitted = shlex.split(encoded)
|
||||
splitted = [s.replace("??", "\ ") for s in shlex.split(encoded.replace('\ ', '??'))]
|
||||
except ValueError:
|
||||
splitted = encoded.split(' ')
|
||||
|
||||
|
||||
@@ -141,12 +141,17 @@ def eager(fn, *args, **kwargs):
|
||||
|
||||
@eager
|
||||
def get_all_matched_commands(stderr, separator='Did you mean'):
|
||||
if not isinstance(separator, list):
|
||||
separator = [separator]
|
||||
should_yield = False
|
||||
for line in stderr.split('\n'):
|
||||
if separator in line:
|
||||
should_yield = True
|
||||
elif should_yield and line:
|
||||
yield line.strip()
|
||||
for sep in separator:
|
||||
if sep in line:
|
||||
should_yield = True
|
||||
break
|
||||
else:
|
||||
if should_yield and line:
|
||||
yield line.strip()
|
||||
|
||||
|
||||
def replace_command(command, broken, matched):
|
||||
|
||||
Reference in New Issue
Block a user