Skip to content

Instantly share code, notes, and snippets.

@jacmkno
Last active November 14, 2025 10:10
Show Gist options
  • Select an option

  • Save jacmkno/bfaa8a9c0a648e54421987bab1270d9f to your computer and use it in GitHub Desktop.

Select an option

Save jacmkno/bfaa8a9c0a648e54421987bab1270d9f to your computer and use it in GitHub Desktop.
pcat() {
local module_path
module_path="$(pwd)"
local allowed_extensions=(
php module inc install profile theme engine py yml yaml twig html.twig js json css scss sass html ts sh mjs md Dockerfile dockerfile-dev code-workspace prettierrc
)
local exclude_list=(".git/" "node_modules/" "dist/" "build/")
if [ ! -d "$module_path" ]; then
echo "Error: Not a directory: $module_path" >&2
return 1
fi
local regex_part=""
local sep=""
for ext in "${allowed_extensions[@]}"; do
ext="${ext//./\\.}"
regex_part="${regex_part}${sep}${ext}"
sep="|"
done
local regex="\.($regex_part)$"
find "$module_path" -type f -print0 2>/dev/null | while IFS= read -r -d '' file; do
local relpath="${file#$module_path/}"
for excl in "${exclude_list[@]}"; do
case "$relpath" in
*"$excl"*) continue 2 ;;
esac
done
if printf '%s\n' "$relpath" | grep -E "$regex" >/dev/null 2>&1; then
echo
echo "--- File: $relpath ---"
cat "$file"
echo
else
local size
size=$(du -h "$file" 2>/dev/null | awk '{print $1}')
echo
echo "--- File: $relpath (${size:-?}, ASSET/EXCLUDED) ---"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment