You will need llm installed to run the function bellow.
Add it to your rc file (.bashrc, zshrc, ...)
gcllm() {
# generate commit message
local msg
msg=$(
echo "Generate a conventional commit message for <diff>$(git diff --staged)</diff>. The output will be passed directly to git commit -F -" \
| llm \
| sed '/```/d'
)
# print message
printf "\nProposed commit message:\n---\n%s\n---\n" "$msg"
# ask if we want to proceed
printf "Proceed with commit? [y/N] "
read -r answer
# move on
if [[ $answer =~ ^[Yy]$ ]]; then
# use a here-doc so newlines are preserved
git commit -F <(printf "%s\n" "$msg")
else
echo "Commit aborted."
fi
}