j178 / chatgpt

An elegant interactive CLI for ChatGPT
693 stars 52 forks source link

Request: input from stdin but also interactive #90

Open tennox opened 3 months ago

tennox commented 3 months ago

I'd love to

tail some.log | chatgpt 

and be dropped into an interactive window (maybe flag -i)

I've tried a script with read and:

tail some.log | chatgpt -p $prompt

but then I can only ask one question, not interactively.

j178 commented 3 months ago

I believe this may not be workable. Using tail some.log | chatgpt would redirect the input to chatgpt from a pipe rather than a terminal. However, an interactive session requires a terminal to function. This is similar to what happens with echo xxx | vim:

❯ echo hello | vi
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
j178 commented 3 months ago

Actually in vim we can do this echo hello | vim -, so this could be feasible.