Skip to content

Instantly share code, notes, and snippets.

@moritztim
Last active February 10, 2024 09:07
Show Gist options
  • Save moritztim/f737e41f23d529cce9fb38fa2dfc3180 to your computer and use it in GitHub Desktop.
Save moritztim/f737e41f23d529cce9fb38fa2dfc3180 to your computer and use it in GitHub Desktop.
ShellGPT Extras
#!/bin/zsh
## Generate code with Shell GPT's code role and watch it being written in VSCode
aicode() {
# Check if input is available from the pipe
if [ -t 0 ]; then
# If no input from pipe, pass only the prompt to the AI
sgpt --code "$@" | codium -
else
# If input is received from pipe, concatenate it with the provided prompt
cat - | sgpt --code "$@" | codium -
fi
}
#!/bin/zsh
## Generate commit messages with Shell GPT 3.5-turbo and the custom commit role
cgpt() {
commit_msg=$(git diff --staged | sgpt --model="gpt-3.5-turbo" --role=commit)
echo -n "Generated Message: \n $commit_msg \n Is this message ok? [Y/n]: "
read confirm
if [[ $confirm == "y" || $confirm == "Y" || $confirm == "" ]]; then
git commit -m "$commit_msg"
command git commit -m "$commit_msg" "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment