#!/bin/bash # llmfeed.sh - Copy repository contents to make them easily digestable for LLMs # # Author: Felix Weiglhofer # License: MIT # # Description: # Flattens the (text) content of a repository into a single string that can be # easily read by LLMs. Inspired by uithub.com. # # Usage: # - Copy to clipboard (Wayland): # ./llmfeed.sh | wl-copy # # - Copy to clipboard (X11): # ./llmfeed.sh | xclip # targetDir=$1 if [[ - z $targetDir ]]; then echo "Error: Target directory missing." echo "" echo "Usage: $0 " exit 1 fi findFlags=( # Exclude directories -path '*/.git' -prune -o -path '*/build' -prune -o -type f -print0 ) is_binary() { if [[ -z $(file -b --mime-type "$1" | grep -v "^text/") ]]; then return 1 else return 0 fi } mapfile -d '' -t listOfFile < <(find $targetDir ${findFlags[@]}) content="" for file in "${listOfFile[@]}" do if is_binary $file; then continue fi content+=">>> $file" content+=$'\n' content+=$(cat $file) content+=$'\n' done echo "$content"