mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 09:39:01 +00:00
Merge branch 'master' into fix-readme-typos
This commit is contained in:
commit
e62d75dff9
42
.travis.yml
42
.travis.yml
@ -1,37 +1,19 @@
|
|||||||
language: python
|
language: python
|
||||||
sudo: false
|
sudo: false
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- python: "nightly"
|
||||||
dist: xenial
|
- python: "3.8-dev"
|
||||||
python: "nightly"
|
- python: "3.8"
|
||||||
- os: linux
|
- python: "3.7-dev"
|
||||||
dist: xenial
|
- python: "3.7"
|
||||||
python: "3.8-dev"
|
- python: "3.6-dev"
|
||||||
- os: linux
|
- python: "3.6"
|
||||||
dist: xenial
|
- python: "3.5"
|
||||||
python: "3.8"
|
- python: "3.4"
|
||||||
- os: linux
|
- python: "2.7"
|
||||||
dist: xenial
|
|
||||||
python: "3.7-dev"
|
|
||||||
- os: linux
|
|
||||||
dist: xenial
|
|
||||||
python: "3.7"
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
python: "3.6-dev"
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
python: "3.6"
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
python: "3.5"
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
python: "3.4"
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
python: "2.7"
|
|
||||||
- os: osx
|
- os: osx
|
||||||
language: generic
|
language: generic
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
@ -279,6 +279,7 @@ following rules are enabled by default:
|
|||||||
* `quotation_marks` – fixes uneven usage of `'` and `"` when containing args';
|
* `quotation_marks` – fixes uneven usage of `'` and `"` when containing args';
|
||||||
* `path_from_history` – replaces not found path with similar absolute path from history;
|
* `path_from_history` – replaces not found path with similar absolute path from history;
|
||||||
* `react_native_command_unrecognized` – fixes unrecognized `react-native` commands;
|
* `react_native_command_unrecognized` – fixes unrecognized `react-native` commands;
|
||||||
|
* `remove_shell_prompt_literal` – remove leading shell prompt symbol `$`, common when copying commands from documentations;
|
||||||
* `remove_trailing_cedilla` – remove trailing cedillas `ç`, a common typo for european keyboard layouts;
|
* `remove_trailing_cedilla` – remove trailing cedillas `ç`, a common typo for european keyboard layouts;
|
||||||
* `rm_dir` – adds `-rf` when you try to remove a directory;
|
* `rm_dir` – adds `-rf` when you try to remove a directory;
|
||||||
* `scm_correction` – corrects wrong scm like `hg log` to `git log`;
|
* `scm_correction` – corrects wrong scm like `hg log` to `git log`;
|
||||||
@ -389,7 +390,7 @@ requires_output = True
|
|||||||
Several *The Fuck* parameters can be changed in the file `$XDG_CONFIG_HOME/thefuck/settings.py`
|
Several *The Fuck* parameters can be changed in the file `$XDG_CONFIG_HOME/thefuck/settings.py`
|
||||||
(`$XDG_CONFIG_HOME` defaults to `~/.config`):
|
(`$XDG_CONFIG_HOME` defaults to `~/.config`):
|
||||||
|
|
||||||
* `rules` – list of enabled rules, by default `thefuck.conf.DEFAULT_RULES`;
|
* `rules` – list of enabled rules, by default `thefuck.const.DEFAULT_RULES`;
|
||||||
* `exclude_rules` – list of disabled rules, by default `[]`;
|
* `exclude_rules` – list of disabled rules, by default `[]`;
|
||||||
* `require_confirmation` – requires confirmation before running new command, by default `True`;
|
* `require_confirmation` – requires confirmation before running new command, by default `True`;
|
||||||
* `wait_command` – max amount of time in seconds for getting previous command output;
|
* `wait_command` – max amount of time in seconds for getting previous command output;
|
||||||
|
38
tests/rules/test_remove_shell_prompt_literal.py
Normal file
38
tests/rules/test_remove_shell_prompt_literal.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.remove_shell_prompt_literal import match, get_new_command
|
||||||
|
from thefuck.types import Command
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def output():
|
||||||
|
return "$: command not found"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("script", ["$ cd newdir", " $ cd newdir"])
|
||||||
|
def test_match(script, output):
|
||||||
|
assert match(Command(script, output))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"command",
|
||||||
|
[
|
||||||
|
Command("$", "$: command not found"),
|
||||||
|
Command(" $", "$: command not found"),
|
||||||
|
Command("$?", "127: command not found"),
|
||||||
|
Command(" $?", "127: command not found"),
|
||||||
|
Command("", ""),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_not_match(command):
|
||||||
|
assert not match(command)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"script, new_command",
|
||||||
|
[
|
||||||
|
("$ cd newdir", "cd newdir"),
|
||||||
|
("$ python3 -m virtualenv env", "python3 -m virtualenv env"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_get_new_command(script, new_command, output):
|
||||||
|
assert get_new_command(Command(script, output)) == new_command
|
22
thefuck/rules/remove_shell_prompt_literal.py
Normal file
22
thefuck/rules/remove_shell_prompt_literal.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
"""Fixes error for commands containing the shell prompt symbol '$'.
|
||||||
|
|
||||||
|
This usually happens when commands are copied from documentations
|
||||||
|
including them in their code blocks.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
> $ git clone https://github.com/nvbn/thefuck.git
|
||||||
|
bash: $: command not found...
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def match(command):
|
||||||
|
return (
|
||||||
|
"$: command not found" in command.output
|
||||||
|
and re.search(r"^[\s]*\$ [\S]+", command.script) is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_command(command):
|
||||||
|
return command.script.replace("$", "", 1).strip()
|
@ -24,9 +24,9 @@ class Powershell(Generic):
|
|||||||
|
|
||||||
def how_to_configure(self):
|
def how_to_configure(self):
|
||||||
return ShellConfiguration(
|
return ShellConfiguration(
|
||||||
content=u'iex "thefuck --alias"',
|
content=u'iex "$(thefuck --alias)"',
|
||||||
path='$profile',
|
path='$profile',
|
||||||
reload='& $profile',
|
reload='. $profile',
|
||||||
can_configure_automatically=False)
|
can_configure_automatically=False)
|
||||||
|
|
||||||
def _get_version(self):
|
def _get_version(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user