diff --git a/README.md b/README.md index 90a2d60..964f30c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,12 @@ chmod +x yolo.py alias yolo=$(pwd)/yolo.py ``` -## OpenAI API Key configuration +# Windows + +You can use: `pyinstaller yolo.py --onefile` to get a single `yolo.exe` to run. +Windows is less tested, but it does work. + +# OpenAI API Key configuration There are two ways to configure the key: - You can either `export OPENAI_API_KEY=` @@ -16,7 +21,9 @@ There are two ways to configure the key: # Using yolo -Here are a couple of examples. By default the command that comes back from GPT-3 will be immediatly executed (yolo!). +Here are a couple of examples on how this utility can be used. + +**WARNING**: By default the command that comes back from GPT-3 will be immediatly executed (yolo!). If you want to inspect the command that is executed, add the `-a` argument, e.g `yolo -a delete the file test.txt`. diff --git a/yolo.py b/yolo.py index 0e8ca1b..0a94c1e 100755 --- a/yolo.py +++ b/yolo.py @@ -42,12 +42,8 @@ if user_prompt == "": # Get shell info for a better prompt -# Unix based Shell? -shell = os.environ["SHELL"] - -# Note: Have never tested this on Windows much -if shell == None: - shell = "powershell.exe" +# Unix based SHELL (/bin/bash, /bin/zsh), otherwise assuming it's Windows +shell = os.environ.get("SHELL", "powershell.exe") # Construct the prompt pre_prompt = "Translate the following question into a {} command. ".format(shell) @@ -66,7 +62,6 @@ prompt = pre_prompt + user_prompt if prompt[-1:] != "?": prompt+="?" - #print ("The prompt is: "+prompt) response = openai.Completion.create( model="text-davinci-003", @@ -87,7 +82,7 @@ if resulting_command.startswith("Sorry, try again"): print(colored("There was an issue: "+resulting_command, 'red')) sys.exit(-1) -print("Command: " + colored(resulting_command, 'cyan')) +print("Command: " + colored(resulting_command, 'blue')) if ask == True: print("Execute the command? Y/n ==> ", end = '') yolo = input() @@ -96,6 +91,7 @@ if ask == True: if yolo == "Y" or yolo == "": if shell == "powershell.exe": subprocess.run([shell, "/c", resulting_command], shell=False) - else: #Unix based - /bin/bash, /bin/zsh: uses -c both Ubuntu and macOS should work, others might not + else: + # Unix: /bin/bash /bin/zsh: uses -c both Ubuntu and macOS should work, others might not subprocess.run([shell, "-c", resulting_command], shell=False)