Skip to content

Instantly share code, notes, and snippets.

@DanKaplanSES
Created August 23, 2023 02:29
Show Gist options
  • Save DanKaplanSES/e25ba527d894e00ef719391fa6c99722 to your computer and use it in GitHub Desktop.
Save DanKaplanSES/e25ba527d894e00ef719391fa6c99722 to your computer and use it in GitHub Desktop.
A script to convert your current project into a stack overflow post
#! /usr/bin/bash
set -e
TREE_IGNORE_PATTERN='node_modules|tscbuild|package-lock.json|.gitignore|.git'
echo '### Project Structure'
echo '```'
tree --noreport -F -a -I $TREE_IGNORE_PATTERN | tr -d '*'
echo '```'
echo ""
PROJECT_FILES=$(mktemp)
tree --noreport -nFif -I $TREE_IGNORE_PATTERN | awk '$0 !~ /\/$/ && $0 !~ /^\.$/' | tr -d '*' | awk '{print "" ; print "### " $0 ; print "```" ; system("cat " $0 ) ; print "" ; print "```" ; print "" }'
@DanKaplanSES
Copy link
Author

DanKaplanSES commented Aug 23, 2023

I was wasting a lot of time and manual effort copying my project files between Visual Studio Code and stackoverflow, so this bash script prints everything in one step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment