mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-15 15:18:53 +00:00
21 lines
556 B
Python
21 lines
556 B
Python
from thefuck.utils import get_closest
|
|
import re
|
|
|
|
|
|
def match(command, settings):
|
|
return ('tmux' in command.script
|
|
and 'ambiguous command:' in command.stderr
|
|
and 'could be:' in command.stderr)
|
|
|
|
|
|
def get_new_command(command, settings):
|
|
cmd = re.match(r"ambiguous command: (.*), could be: (.*)",
|
|
command.stderr)
|
|
|
|
old_cmd = cmd.group(1)
|
|
suggestions = [cmd.strip() for cmd in cmd.group(2).split(',')]
|
|
|
|
new_cmd = get_closest(old_cmd, suggestions)
|
|
|
|
return command.script.replace(old_cmd, new_cmd)
|