1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 14:48:49 +00:00

add start of aliases rule

This commit is contained in:
Vince van Oosten 2016-09-14 14:16:06 +02:00
parent bcc11219e6
commit 47f553f269

37
thefuck/rules/aliases.py Normal file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env python2
import subprocess
import re
from thefuck.corrector import get_corrected_command
enabled_by_default = True
priority = 100000
def list_aliases():
aliases_list = subprocess.check_output(["bash", "-li", "-c", "alias"]).strip().split('\n')
p = re.compile(r'^alias ')
aliases_list = {re.sub(p, '', a).split("=")[0]: re.sub(p, '', a).split("=")[1] for a in aliases_list}
return aliases_list
def match(command):
return command in list_aliases()
def get_new_command(command):
command = list_aliases()[command]
return get_corrected_command(command)
if __name__ == "__main__":
command = "gs"
m = match(command)
print(m)
if m:
print(get_new_command(command))