To run ShellGPT you must install it and obtain a ChatGPT API key.
Want to use the ChatGPT in a terminal window on your Ubuntu Linux PC?
ShellGPT lets you use all the features of the famous AI chatbot, on the command line.
Hannah Stryker / How-To Geek
Here’s how to set ShellGPT up and start using it.
What Is ShellGPT?
ShellGPTis a Python program that lets you accessOpenAI’s ChatGPTfrom the command line of a terminal window.
It sends your text prompts and your ChatGPTAPIkey to ChatGPT and prints out ChatGPT’s response.
Just keep in mind that it’s a simulation of a knowledgeable, intelligent person.
It isn’t genuinely intelligent, andit’ll happily make stuff up.
If Python isn’t installed, you’ve got the option to install it using this command.
We also needpip, the python package manager.
It wasn’t installed on our test computer, so we added it usingapt.
We’re going to install ShellGPT in aPython virtual environment.
It’s just a safe precaution.
To do that, we’re going to need to set up the Python virtual environment packages.
Step 2: Prepare a Python Virtual Environment
Create a directory to install ShellGPT into.
We named ours “shellgpt”, just to keep things obvious.
Change into your new directory when it’s been created.
We created one called “shellgpt.”
This gives us a private, virtual environment called “shellgpt”, inside our “shellgpt” directory.
To activate it we need to run a script called “activate.”
This is located in the “bin” directory of our virtual environment.
Note the “(shellgpt)” in front of the command prompt.
On the API keys web page, smack the “Create New Secret Key” button.
Your new key is displayed to you.You only get to see your key this one time.
Step 4: Export the API Key
We need to make the key available to ShellGPT.
The easiest way is to export it as an environment variable.
store your changes and terminate the editor.
To force your terminal session to reread your “.bashrc” file, use thesourcecommand.
The installation will begin, and a variety of package names will scroll by in your terminal window.
When it’s finished we can, finally, use ShellGPT to access ChatGPT.
Step 6: Use ShellGPT
The ShellGPT command issgpt.
We provide our text prompts to this command, and press “Enter.”
ShellGPT acts as the middleman between us and ChatGPT, and displays the response from ChatGPT.
Related:How to Create Aliases and Shell Functions on Linux
That’s great, it’s all working.
A better way is to create an alias that does all of that for us.
Edit your “.bashrc” file and add this line.
Remember to use the names of the directory and virtual environment that you created.
preserve your changes, and usesourceto read the “.bashrc” file again.
Learning ShellGPT Commands
TheShellGPT GitHub pagehas much more information on using ShellGPT and its command line options.
For example, the–codeoption limits the output of ShellGPT to show program code only.
By adding the–codeoption, the description is suppressed.
This would be handy if you want to redirect the output into a file.
ShellGPT, through ChatGPT, can also generatesyntax-correct Bash commands and shell scripts.
Or at least, that’s what it says.