Skip to content

Instantly share code, notes, and snippets.

@vimota
Last active July 18, 2024 05:20
Show Gist options
  • Save vimota/6a4ed159c57d288c3d6778287fe6e29f to your computer and use it in GitHub Desktop.
Save vimota/6a4ed159c57d288c3d6778287fe6e29f to your computer and use it in GitHub Desktop.
Shell command to get a txt dump of your NextJS codebase for prompting
bash -c '
print_directory_content() {
local dir="$1"
local prefix="$2"
echo "${prefix}${dir##*/}/"
for item in "$dir"/*; do
base_name=$(basename "$item")
if [[ "$base_name" == ".next" ||
"$base_name" == "node_modules" ||
"$base_name" == "data" ||
"$base_name" == "yarn.lock" ||
"$base_name" == "next-env.d.ts" ||
"$base_name" == "package-lock.json" ]]; then
echo "${prefix} ${base_name} (skipped)"
continue
fi
if [ -d "$item" ]; then
print_directory_content "$item" "$prefix "
elif [ -f "$item" ]; then
echo "${prefix} ${item##*/}"
echo "${prefix} ------------------------"
cat "$item" | sed "s/^/${prefix} /"
echo "${prefix} ------------------------"
echo
fi
done
}
print_directory_content "." ""
' > /tmp/codebase.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment