mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-28 05:28:38 +00:00
22 lines
593 B
Python
22 lines
593 B
Python
import re
|
|
from thefuck.utils import for_app, which, replace_argument
|
|
|
|
|
|
def _get_command_name(command):
|
|
found = re.findall(r'sudo: (.*): command not found', command.stderr)
|
|
if found:
|
|
return found[0]
|
|
|
|
|
|
@for_app('sudo')
|
|
def match(command):
|
|
if 'command not found' in command.stderr:
|
|
command_name = _get_command_name(command)
|
|
return which(command_name)
|
|
|
|
|
|
def get_new_command(command):
|
|
command_name = _get_command_name(command)
|
|
return replace_argument(command.script, command_name,
|
|
u'env "PATH=$PATH" {}'.format(command_name))
|