Last active
September 7, 2024 04:49
-
-
Save ugurcanlacin/392aff451776be75b7cc14c30752f581 to your computer and use it in GitHub Desktop.
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
# A function that generates one line commit message by using Llama3.1 and copies it to clipboard on MacOS. | |
##################################################################################### | |
### HOW TO USE? ### | |
### Just copy and paste the following function to your .zshrc or .bashrc ### | |
### Run `source .zshrc` or `source .bashrc` after you updated your file. ### | |
##################################################################################### | |
# Requirement: | |
# It needs ollama installed. | |
# If you don't have it installed, do following: | |
# - Run `brew install ollama` on MacOS. | |
# - Run `brew services start ollama` to start ollama | |
# - Run `ollama run llama3.1` to install llama3.1 8B model | |
# This will take awhile, however, you will have llama3.1 8B model in your local for future usages. | |
# Missing part: | |
# - The script only gets modified file changes. Not untracked(new) files. | |
glm() { | |
# Function to generate commit message | |
generate_commit_message() { | |
git diff | ollama run llama3.1 "Below is a diff of all changes, coming from the command:\`\`\`git diff\`\`\`Please generate a concise, one-line commit message for these changes. Output only the commit message, without quotes or any other text" | |
} | |
# Main script | |
commit_message=$(generate_commit_message) | |
# Copy the commit message to clipboard using pbcopy | |
echo -n "$commit_message" | pbcopy | |
echo -e "Generated commit message (copied to clipboard):" | |
echo "$commit_message" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment