Created
February 16, 2025 21:08
-
-
Save svandragt/99bcab3ab01746d0f1529ae8de8d0964 to your computer and use it in GitHub Desktop.
Git Commit AI logs
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
#!/usr/bin/env bash | |
# filename: ~/bin/git-cai | |
# example: git cai | |
# | |
# Copies an AI-generated summary of a commit to the clipboard before opening the commit dialog. | |
# Requires commitmsg and copy aliases | |
# uvx llm keys set gemini | |
# Detect the OS type | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
CLIP_CMD="pbcopy" # macOS clipboard command | |
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
CLIP_CMD="xsel -ib" # Linux clipboard command | |
else | |
echo "Unsupported OS: $OSTYPE" >&2 | |
exit 1 | |
fi | |
# Generate the commit message and copy it to the clipboard | |
git diff --staged | uvx --with llm-gemini llm -m gemini-2.0-pro-exp-02-05 -s 'Generate a git commit message for these changes. Avoid overly verbose descriptions or unnecessary details. Start with a short sentence in imperative form, no more than 50 characters long. Then leave an empty line and continue with a more detailed explanation. Write only one sentence for the first part, and two or three sentences at most for the detailed explanation.' | $CLIP_CMD | |
git commit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using
uvx
means you don't need to installllm
or python or the model.