I found this tool which lets you use Chat GPT from the terminal: https://github.com/TheR1D/shell_gpt
Maybe you're thinking, "haha, funny trick, but why would I want to do that, are you trying to prove something?"
But I promise you, if you give this a try, you won't be disappointed.
You can read all about the functionality and configuration in the readme, but here are just some examples:
Basic query:
sgpt "hello chatgpt"
The output is Markdown formatted, so you can pipe it to pandoc:
sgpt "hello chatgpt" | pandoc -t plain
As with a session on chat.openai.com, you can use named sessions so that it remembers the context of your chats (by default, it starts a new chat for every query)
sgpt --chat my_chat_name "hello chatgpt"
Using the -s
option, it will ensure that a shell command is output, and will give you keyboard shortcuts E (execute), D (describe), or A (abort).
sgpt -s "generate me a 500x500 image of random colors. Use low frequency for the noise so there are larger features. Make sure the output is colored and not black and white"
Which outputs:
convert -size 500x500 xc: +noise Random -virtual-pixel tile -blur 0x10 -auto-level -separate -combine output.png [E]xecute, [D]escribe, [A]bort: e
And, upon executing, produces the image:
<img src='https://i.imgur.com/Aol3fNJ.png' width='200' height='200'>
You can also pipe command output into sgpt:
cat test.rb
class Foo
def bar
puts "ok"
end
end
cat test.rb | cgpt -s convert this to javascript