TheR1D / shell_gpt

A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.
MIT License
9.36k stars 733 forks source link

Accept stdin input #80

Closed Shakahs closed 1 year ago

Shakahs commented 1 year ago

It would be very useful to pipe stdin to sgpt, then ask a question about said input. For example:

cat data.json | sgpt "what is the oldest entry" cat script.py | sgpt "what does this script do?"

etc.

TheR1D commented 1 year ago

But you can do the same thing with command substitution syntax, as it is described in readme:

sgpt "what is the oldest entry: $(cat data.json)"
Shakahs commented 1 year ago

Perhaps, but it is not practical. Pipelining commands is a basic tenet of CLI usage and shell scripting. For SGPT to be the shell's interface to GPT it must support the IO capabilities expected of a shell utility. This is the third issue on the subject (see #35, #86) so clearly it is needed. I have created a pull request implementing it in #93.