Imagine a world in which you don’t have to memorize an arcane Linux command to be able to confirm that you’ve actually pushed your current branch to a git remote?
That world is here!

^ this should be a text block!
I’m always looking for ways to make my workflow more efficient, and shell_gpt has been a huge win. It’s transformed how I interact with my terminal—amplifying what I can do by using my experience with Linux rather than relying on rote memorization of commands.
shell_gpt is a command-line tool that integrates OpenAI’s API directly into your terminal. It allows me to ask questions, generate scripts, or troubleshoot issues without ever leaving my shell. The best part? It eliminates the need to copy-paste between my terminal and browser, and has built in ways of explaining what it’s doing. I’ve started reaching for shell_gpt even for simple queries that I would have previously thrown into ChatGPT. It’s that seamless.
Despite the additional (minimal) cost of API calls going beyond what I already pay for ChatGPT Plus, I’ve found it invaluable. It’s become a natural part of my daily workflow. I’m no longer pausing to check syntax or googling niche commands — I just ask shell_gpt using natural language and keep moving.

Functions I’ve Built
I’ve written a couple of custom shell functions in bash to make this integration even smoother. These all live in my .bashrc file.
gpt()
This function wraps shell_gpt to streamline my command queries and handle API key integration.
gpt() {
# Check if the OPENAI_API_KEY is set
if [ -z "$OPENAI_API_KEY" ]; then
echo "⚠️ OPENAI_API_KEY is not set. Please add it to your .env file in ~/code/de/secrets."
return 1
fi
# Prompt for a command description if none is provided
if [ -z "$1" ]; then
read -p "Enter the command description: " user_input
else
user_input="$*"
fi
# Run ShellGPT in interactive shell mode
sgpt --shell "$user_input"
}
aicommit()
I also use shell_gpt to generate commit messages based on my Git diffs. It’s an absolute time-saver and keeps my commits concise and meaningful.
aicommit() {
# Check if the current directory is a Git repository
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
echo "Error: This is not a Git repository."
return 1
fi
# Check if there are staged changes
if ! git diff --cached --quiet; then
echo "No staged changes to commit."
return 0
fi
# Use shell_gpt to generate a commit message based on the staged changes
commit_message=$(sgpt "Generate a concise Git commit message based on the following diff: $(git diff --cached)")
# Print the generated commit message
printf "\nGenerated Commit Message:\n%s\n\n" "$commit_message"
# Ask the user for confirmation
read -rp "Do you want to commit your changes with this commit message? [y/N] " response
if [[ $response =~ ^[Yy]$ ]]; then
git commit -m "$commit_message"
echo "Changes committed with the above message."
else
echo "Commit cancelled."
fi
}
Why I Love It
What excites me most about shell_gpt is how naturally it fits into my existing workflows. It doesn’t feel like an added tool I have to remember to use—it’s just there, enhancing how I work every day.
It’s a perfect example of leveraging automation to focus on problem-solving, not syntax hunting. I’ve already adopted it into my workflow without a second thought—and I’m thrilled to keep exploring its potential.
The Cost
Although there is a minimal cost associated with usage, I’ve found it very minimal when I stick with OpenAI’s 4o-mini model for most queries. As shown in the scripts above, I’ve setup my scripts to default to 4o-mini, and only escalate to 4o when needed.
