Created
June 24, 2025 22:39
-
-
Save sks/f0e0eba02b84c857fc348dc3b69f1c64 to your computer and use it in GitHub Desktop.
Creative commit Message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function creative_commit_msg() { | |
if [[ -z "$1" ]]; then # Check for the first argument directly | |
echo "Usage: creative_commit_msg <mood_phrase>" | |
echo "Example: creative_commit_msg 'happy and productive'" | |
return 1 | |
fi | |
local mood_raw="$*" | |
local mood=$(echo "$mood_raw" | tr '[:upper:]' '[:lower:]') | |
mood=$(echo "$mood" | sed 's/[^a-z0-9 ]//g' | xargs) | |
if [[ -z "$mood" ]]; then | |
echo "Invalid mood provided after cleanup. Please use alphanumeric characters and spaces." | |
return 1 | |
fi | |
echo "Generating commit message for mood: '$mood'" | |
local ollama_response=$(curl -s http://localhost:11434/api/generate -d "{ | |
\"model\": \"llama3.2:latest\", | |
\"prompt\": \"Generate a creative and concise Git commit message for a project based on the following mood: ${mood}. Do not include any preambles or conversational text, just the commit message itself. Keep it under 100 characters.\", | |
\"stream\": false | |
}") | |
local commit_msg=$(echo "$ollama_response" | jq -r ".response") | |
echo "---" | |
echo "Commit message generated:" | |
echo "$commit_msg" | |
git commit -m "$commit_msg" | |
echo "---" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment