mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-26 04:29:21 +00:00
* Add rule to remove shell prompt literals $ Rule added to handle cases where the $ symbol is used in the command, this usually happens when the command is copy pasted from a documentation that includes the shell prompt symbol in the code blocks. * Change files using black and flake8 style check * Refactor tests and rule - Refactor test for cleaner test tables - Removed unnecessary requires_output=True option
23 lines
522 B
Python
23 lines
522 B
Python
"""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()
|