0xacx / chatGPT-shell-cli

Simple shell script to use OpenAI's ChatGPT and DALL-E from the terminal. No Python or JS required.
https://gptshell.cc
MIT License
1.05k stars 150 forks source link

Allow input from redirected stdin #42

Closed rxaviers closed 1 year ago

rxaviers commented 1 year ago

This change fixes redirected stdin. For example, consider we have a query file:

How are you doing?

Before:

chatgpt <query 
Welcome to chatgpt. You can quit with 'exit'.

Enter a prompt:
(waits for prompt)

After: (expected)

chatgpt <query 
As an AI language model, I don't have feelings, but I'm functioning well and ready to assist you with any questions or tasks you have.

PS: Pipes still work as expected:

$ echo "How are you doing?" | chatgpt 
As an AI language model, I do not have feelings, but I am functioning properly and ready to assist you with any questions or tasks you may have.

PS2: This empowers use cases such as this:

Screen Recording 2023-03-17 at 07 41 25

Screen Recording 2023-03-17 at 07 43 36

0xacx commented 1 year ago

I am not the vim type 😅 so I haven't thought of that use case, but your example makes it clear it is a very useful one. Thank you very much for this contribution! 🙏