2 min read

Never write a Bash command again (with the help of GPT-3)

Use `gpt-do` to have GPT-3 write all your bash commands for you!

I was inspired after seeing @NaderLikeLadder's post "Using ChatGPT to make Bash palatable". He correctly pointed out that AI is finally the tool we need to win the fight against bash (or fish, or zsh...) once and for all.

While the interactive scripting experience with ChatGPT is pretty sweet, my qualms normally come from the day-to-day "how do I do that again??". Whether its rebasing while deferring to local changes, or figuring out which process is locking up my TPU, far too much time is spent diving into man pages.

Enter: gpt-do! With this handy-dandy command, I never have to grep through docs again. I simply call do whatever I cant to get done in my shell, and the commands magically appear.

$ do kill the process which is locking up my GPU
This command will kill the process which is locking up your GPU.
kill -9 $(lsof -t /dev/nvidia0)
Do you want to continue? [y/N]: 
💡
do is a reserved keyword in bash and zsh so you'll have to use ddo instead.

Well, maybe not so magically. I figured if ChatGPT could do fully-interactive sessions, GPT-3 should be able to handle one-offs no problem. And it looks like I was right!

Check out this awesome demo I threw together:

Sometimes, GPT-3 doesn't quite get it right.

$ do kill the orphaned python process
These commands will list all processes and kill the orphaned python process.
ps -A | grep python
kill -9 <PID>
Do you want to continue? [y/N]: N
$

So I added the ability to query a different model:

$ do kill the orphaned python process --model=codex
This command will kill the orphaned python process.
kill -9 $(ps aux | grep python | grep -v grep | awk '{print $2}')
Do you want to continue? [y/N]:

That did it!

With a little Python magic, you can do too. Just brew install yasyf/do/do (or pipx install gpt-do), and check out the repo for more details. You'll need an OpenAI API key (the default model is GPT-3), and remember to use ddo if you're on bash or zsh!