1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-15 15:18:53 +00:00
2015-07-10 09:49:49 +02:00

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)