Skip to content

Instantly share code, notes, and snippets.

@florianpasteur
Created October 20, 2022 09:44
Show Gist options
  • Save florianpasteur/fa1d93a02b07afa31e76bea72d7f8d61 to your computer and use it in GitHub Desktop.
Save florianpasteur/fa1d93a02b07afa31e76bea72d7f8d61 to your computer and use it in GitHub Desktop.
Extract commit diff as markdown
printCodeFileAsMarkdown() { for filepath in "$@"; do
filename=$(basename -- "$filepath")
dir=$(dirname -- "$filepath")
extension="${filename##*.}"
if [ -f "$filepath" ]; then
echo "\`$filename\` under \`$dir\`:"
echo ""
echo "\`\`\`$extension"
cat "$filepath"
echo "\`\`\`"
echo ""
else echo "Delete $filepath"; fi
done; }
printCodeFileAsMarkdown $(git diff --name-only @~1 | grep -v playwright | grep -v tests | grep -v package.json) | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment