unalias gcm 2>/dev/null
gcm() {
generate_commit_message() {
git diff --cached | llm -m gemini-1.5-flash-latest "
Below is a diff of all staged changes, coming from the command: ``` git diff --cached ``` Please generate a concise, one-line commit message for these changes."
}
read_input() {
if [ -n "$ZSH_VERSION" ]; then
echo -n "$1"
read -r REPLY
else
read -p "$1" -r REPLY
fi
}
echo "Generating AI-powered commit message using gemini..."
commit_message=$(generate_commit_message)
while true; do
echo -e "\nProposed commit message:"
echo "$commit_message"
read_input "Do you want to (a)ccept, (e)dit, (r)egenerate, or (c)ancel? "
choice=$REPLY
case "$choice" in
a|A )
if git commit -m "$commit_message"; then
echo "Changes committed successfully!"
return 0
else
echo "Commit failed. Please check your changes and try again."
return 1
fi
;;
e|E )
read_input "Enter your commit message: "
commit_message=$REPLY
if [ -n "$commit_message" ] && git commit -m "$commit_message"; then
echo "Changes committed successfully with your message!"
return 0
else
echo "Commit failed. Please check your message and try again."
return 1
fi
;;
r|R )
echo "Regenerating commit message using gemini..."
commit_message=$(generate_commit_message)
;;
c|C )
echo "Commit cancelled."
return 1
;;
* )
echo "Invalid choice. Please try again."
;;
esac
done
}
source & further reading
gist.github.com — original article
OpenCode AI config to deny read access to .env, node_modules, build artifacts, cache dirs and ask before bash execution
Download CapCut Pro 2026 for Mac
For Agentic Coding