From 93b6a623e1c527b8e08093a986ca23fbb189d949 Mon Sep 17 00:00:00 2001 From: Lukas Vacek Date: Tue, 21 Apr 2015 17:59:44 +0200 Subject: [PATCH] adding rule to run "sudo apt-get install" --- thefuck/rules/apt_get.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 thefuck/rules/apt_get.py diff --git a/thefuck/rules/apt_get.py b/thefuck/rules/apt_get.py new file mode 100644 index 00000000..0e7af59e --- /dev/null +++ b/thefuck/rules/apt_get.py @@ -0,0 +1,28 @@ +import sys + +def match(command, settings): + try: + import CommandNotFound + if 'not found' in command.stderr: + try: + c = CommandNotFound.CommandNotFound() + pkgs = c.getPackages(command.script.split(" ")[0]) + name,_ = pkgs[0] + return True + except IndexError: + # IndexError is thrown when no matching package is found + return False + except: + return False + +def get_new_command(command, settings): + try: + import CommandNotFound + c = CommandNotFound.CommandNotFound() + if 'not found' in command.stderr: + pkgs = c.getPackages(command.script.split(" ")[0]) + name,_ = pkgs[0] + return "sudo apt-get install %s" % name + except: + sys.stderr.write("Can't apt fuck\n") + return ""