-
-
Save aculich/66a863e8fdfcafd61777a64bd44b41d6 to your computer and use it in GitHub Desktop.
Revisions
-
aculich revised this gist
Aug 26, 2024 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ # ----------------------------------------------------------------------------- # AI-powered Git Commit Function # Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcom` command. # or add it to ~/.oh-my-zsh/custom/plugins # # 1) gets the current staged changed diff # 2) sends them to an LLM to write the git commit message # 3) allows you to easily accept, edit, regenerate, cancel -
aculich revised this gist
Aug 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ gcom() { # Function to generate commit message generate_commit_message() { git diff --cached | llm -m 4o " Below is a diff of all staged changes, coming from the command: \`\`\` -
aculich revised this gist
Aug 26, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
Empty file. -
aculich renamed this gist
Aug 26, 2024 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ # ----------------------------------------------------------------------------- # AI-powered Git Commit Function # Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcom` command. It: # 1) gets the current staged changed diff # 2) sends them to an LLM to write the git commit message # 3) allows you to easily accept, edit, regenerate, cancel # But - just read and edit the code however you like # the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/ gcom() { # Function to generate commit message generate_commit_message() { git diff --cached | llm " @@ -75,4 +75,4 @@ Please generate a concise, one-line commit message for these changes." ;; esac done } -
karpathy created this gist
Aug 25, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ # ----------------------------------------------------------------------------- # AI-powered Git Commit Function # Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It: # 1) gets the current staged changed diff # 2) sends them to an LLM to write the git commit message # 3) allows you to easily accept, edit, regenerate, cancel # But - just read and edit the code however you like # the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/ gcm() { # Function to generate commit message generate_commit_message() { git diff --cached | llm " 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." } # Function to read user input compatibly with both Bash and Zsh read_input() { if [ -n "$ZSH_VERSION" ]; then echo -n "$1" read -r REPLY else read -p "$1" -r REPLY fi } # Main script echo "Generating AI-powered commit message..." 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..." commit_message=$(generate_commit_message) ;; c|C ) echo "Commit cancelled." return 1 ;; * ) echo "Invalid choice. Please try again." ;; esac done }