mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 09:39:01 +00:00
changing from alias to fc -ln -1...
in get_command()
This commit is contained in:
parent
397187f2af
commit
cf53571c83
@ -91,13 +91,24 @@ def check_args(settings, args, cmd):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_command(settings, args):
|
def get_command(settings):
|
||||||
"""Creates command from `args` and executes it."""
|
"""Creates command from `args` and executes it."""
|
||||||
|
|
||||||
|
# trying to use...
|
||||||
|
# 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 ^^^
|
||||||
|
# - allows for command line args
|
||||||
|
|
||||||
|
last_cmd = subprocess.check_output("bash fc -ln -1; history -r", shell=True)
|
||||||
|
|
||||||
|
args = last_cmd.split()
|
||||||
|
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
script = ' '.join(args[1:])
|
script = ' '.join(args)
|
||||||
|
|
||||||
if not script:
|
if not script:
|
||||||
return
|
return
|
||||||
@ -149,7 +160,7 @@ def main():
|
|||||||
colorama.init()
|
colorama.init()
|
||||||
user_dir = setup_user_dir()
|
user_dir = setup_user_dir()
|
||||||
settings = conf.get_settings(user_dir)
|
settings = conf.get_settings(user_dir)
|
||||||
command = get_command(settings, sys.argv)
|
command = get_command(settings)
|
||||||
|
|
||||||
if check_args(settings, sys.argv[1:], command):
|
if check_args(settings, sys.argv[1:], command):
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user