1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-20 09:39:01 +00:00

closer... and changed my mind on --add_fuckup

This commit is contained in:
Jared Henry Oviatt 2015-05-11 10:39:51 -07:00
parent c6ae4594a2
commit 65543c43bb

View File

@ -77,7 +77,7 @@ def check_args(settings, args, cmd):
for opt, val in options: for opt, val in options:
try: try:
if opt == '--ifuckedup' or opt == '--add_fuckup': if opt == '--ifuckedup':
custom_fuckups.add_fuckup(cmd, val) custom_fuckups.add_fuckup(cmd, val)
return True return True
elif opt == '--remove': elif opt == '--remove':
@ -93,24 +93,24 @@ def check_args(settings, args, cmd):
def get_command(settings): def get_command(settings):
"""Creates command from `args` and executes it.""" """Creates command from `args` and executes it."""
# trying to use... # trying to use history to get recent calls instead of using the alias
# subprocess.check_output("bash fc -ln -1; history -r", shell=True).split()
# ... to get recent calls instead of using the alias
# - no need for alias with that ^^^ # - no need for alias with that ^^^
# - allows for command line args # - allows for command line args
shell_cmd = "bash -c -i 'history -r; history -p \!\!'" shell_cmd = "bash -c -i 'history -r; history -p \!\!'"
event = Popen(shell_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT) event = Popen(shell_cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
output = event.communicate() output = event.communicate()
args = output.split() args = output.strip()
if six.PY2: # if six.PY2:
script = ' '.join(arg.decode('utf-8') for arg in args[1:]) # script = ' '.join(arg.decode('utf-8') for arg in args[1:])
else: # else:
script = ' '.join(args[1:]) # script = ' '.join(args[1:])
script = args
if not script: if not script:
return return