ChatGPT and ZSH: How I Learned to Stop Worrying and Love the AI

ChatGPT and ZSH: How I Learned to Stop Worrying and Love the AI

ChatGPT struck the world on November 30th, 2022 and was an eye opener. It is a stunning… tool? thing? I don’t know, I’m pretty much in awe of what it does at this point and watching the tech community poke and prod it has been pretty enlightening. Where I got REALLY curious was as I noticed people requesting that ChatGPT reverse engineer code, develop malware, and what really struck a nerve with me, generate CloudFormation and Terraform code. I finally really started digging around and discovered there are some amazing productivity gains to be had, especially with looking up commands and parsing json.

first stop lazyshell

This was the first tool I started playing around with. lazyshell basically queries ChatGPT for commands. It is an insanely good command lookup tool. Think of all the silly little commands you muck up (find!!!!! I always forget find syntax. Or JSON parsing using jq!). It has some really neat features, such as being able to include the existing command into your ChatGPT query.

Install and setup is simple:

git clone https://github.com/not-poma/lazyshell.git ~/.zsh/plugins/lazyshell

Then edit your ~/.zshrc:

# chatgpt
export OPENAI_API_KEY=YOURMAGICKEYHERE
source ~/.zsh/plugins/lazyshell/lazyshell.zsh

Notice that you will need to register and generate an API key on the OpenAI site. Be advised, it requires a credit card and ou may incur charges.

After that, reload your ZSH config and enjoy. Here’s an example of it in action….

zsh and chatgpt - lazyshell

I mean… that’s slick. Shout out to https://github.com/not-poma/lazyshell.

another one - sgpt

This one is also pretty dang interesting, as it allows for interaction with ChatGPT on the terminal, but can provide more than just shell commands. So not only can you get commands, you can get information, including code blocks or example code. Observe:

zsh and chatgpt - shell-gpt

Easy to install, only a pip install shell-gpt away.

Great googly moogly that’s cool. Shout out to https://github.com/TheR1D/shell_gpt.

summary

Uh, yeah. This is just ridiculously good. It is incredibly powerful and speeds me up even more when working. And this is in a good way; the most annoying thing I can do during the day is take my hands off the keys and put it on the mouse to dig around on Stack Overflow, trying to find an obscure flag for the find command or parse some nested field in a JSON document, selecting a specific key/value pair. This is turbo mode. It eliminates the painful part of my day, and keeps me close to the fun stuff.

Having these tools ready and being able to use them just speeds up the ability to do work. And not just “do work faster”. The ability to get rid of the frustrating and mundane. Looking up some silly basic thing (we all do it) when you’re trying to create some very large intricate system is just painfully frustrating. Just think of how many times you’ve had to look up some trivial thing in the midst of solving a really cool project. This shortens that.

Didn’t even talk about how ridiculously powerful GitHub CoPilot is. Another AI tool I freaking love. Looking forward to the next tool.

bonus

I had to include this, when ChatGPT describes itself (this was coupled with asking it about integrating into a shell), it just kind of blows my mind…

ChatGPT is a powerful language model that can be used for a wide range of applications, from generating natural language text to answering questions and performing complex calculations. However, accessing its full potential can sometimes be challenging, especially for those who are not familiar with the command-line interface.

I don’t know, this is some coooooooool stuff.

That “language model” is such a good concept (and execution). The fact that I can kind of know and just vaguely search and have some THING figure it out for me is really the science fiction I thought of as a kid. It’s literally Star Trek TNG, where I can just say something and ChatGPT (or whatever AI) just parses it for me. That language parsing ability is the game changer. How Siri, OK Google, and Alexa missed on this is a mystery.

What will the future hold here? I wonder if we’ll see AI within individual systems? Will everyone run their own, like some Elasticsearch cluster? Will there be AWS Serverless ChatGPT? Will there be an “on-prem” version? How can we keep the data up to date? How do we easily ingest new data (or different format)? How do we deal with AI hallucinations (which are a real thing)?