1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-31 02:01:13 +00:00

adding rule to run "sudo apt-get install"

This commit is contained in:
Lukas Vacek 2015-04-21 17:59:44 +02:00
parent 5b97992d50
commit 93b6a623e1

28
thefuck/rules/apt_get.py Normal file
View File

@ -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 ""