Script Name: repo-file.sh
Description:
This Bash script combines your project's folder structure and file contents (filtered by file extensions and exclusion lists) into a single timestamped text file. It is particularly useful when you want to share or inspect your entire codebase in one file—minus large auto-generated folders (e.g., node_modules) and config files you don't want to include (e.g., .env).
- Recursively generates a "tree" representation of your directories.
- Excludes specified directories (e.g.,
node_modules,.git) from both the tree and the final output. - Excludes certain files (e.g.,
.env) from the final output. - Allows inclusion of only specific file extensions (e.g.,
js,ts,md) or exact file names (likeDockerfile). - Produces a single comprehensive file, timestamped to avoid overwriting previous runs.
- Bash shell (Generally available on macOS, Linux, and WSL on Windows).
- File permissions: Ensure the script has execution rights if running on Unix-like systems (
chmod +x).
- Clone or download this repository.
- Place
repo-file.shin your project's root directory (or wherever you want to run it). - (Optional) If the script is not executable, grant permissions:
chmod +x repo-file.sh
-
Open your terminal or command prompt.
-
Navigate to the root directory of your project:
cd /path/to/your/project -
Run the script:
./repo-file.sh
On Windows (with Git Bash or WSL), the same command should work.
-
After it completes, the script will display where the output file is located.
Look for a file namedcombined_YYYYMMDD_HHMMSS.txt.
- The script creates a file named
combined_YYYYMMDD_HHMMSS.txt(whereYYYYMMDD_HHMMSSis the timestamp). - This file contains:
- CODEBASE FOLDER STRUCTURE: A tree-like visualization of your folders.
- CODEBASE FILES WITH THEIR RESPECTIVE PATHS: A concatenation of all the allowed files' contents, prefixed by a header indicating each file's relative path.
- Excluded Directories: Edit the array named
excluded_dirsinsiderepo-file.shto add or remove directories you don't want to include in the final output. - Excluded Files: Update
excluded_fileswith any filenames you wish to skip. - Allowed Extensions: Modify the
allowed_extensionsarray to include or exclude particular file types (e.g.,js,jsx,ts,tsx, etc.). - Dockerfile Inclusion: The script explicitly checks for files named
Dockerfileand includes them; remove this check if you don't need it.
- Fork this repository.
- Create a Feature Branch:
git checkout -b feature/YourFeature
- Commit Changes:
git commit -m "Add your feature" - Push to Branch:
git push origin feature/YourFeature
- Open a Pull Request on GitHub (or your chosen git platform). We welcome all improvements, bug fixes, and suggestions.