This script generates a file tree of the current directory and outputs it to a markdown file. The script is designed for zsh
but works on bash
as well.
Clone the repository using the following command:
git clone https://github.com/EastTexasElectronics/FileTreeGenerator.git
Change directory to the cloned repository:
cd FileTreeGenerator
Make the script executable by running:
chmod +x ftg.sh
To make the script easier to use, add an alias to your shell configuration file.
Feel free to add any flags or options you want to the alias such as -i
for interactive mode.
alias ftg="~/path/to/FileTreeGenerator/ftg.sh"
You will need to replace ~/path/to/FileTreeGenerator
with the actual path to the cloned repository.
After adding the alias, reload your shell configuration with the following command:
source ~/.zshrc # For zsh
source ~/.bashrc # For bash
Run the script using the alias:
ftg [options]
Option | Alias | Description |
---|---|---|
-e , --exclude |
Exclude directories or files (comma-separated). Example: -e .git,node_modules |
|
-o , --output |
Specify a different output location for the generated file tree. | |
-i , --interactive |
Interactive mode for excluding directories or files. | |
-h , --help |
Show help message and exit. | |
-v , --version |
Show version information and exit. |
-
Exclude specific directories (please note that the
.git
andnode_modules
directories are already excluded by default):ftg -e [package1],[directory],[.dotfile],[file]
-
Specify a different output location:
ftg -o /path/to/output/file_tree.md
-
Interactive mode for excluding directories or files:
ftg -i
-
Show help message:
ftg -h
-
Show version information:
ftg -v
To add or remove exclude patterns, modify the exclude_patterns
array in the script:
exclude_patterns+=(node_modules .next .vscode .idea .git .DS_Store)
Add or remove entries as needed. For example, to exclude a directory named logs
, add logs
to the array:
exclude_patterns+=(logs)
By default, the script generates the output file in the current directory with a timestamped name. To change the default output location, use the -o
option when running the script:
ftg -o /desired/path/to/output/file_tree.md
Alternatively, you can modify the script directly by setting the output_location
variable to your desired path:
output_location="/desired/path/to/output/file_tree.md"
Default output while using the base create t3 app template:
├── [File]
├── [File] .env
├── [File] .env.example
├── [File] .eslintrc.cjs
├── [File] .gitignore
├── [File] README.md
├── [File] bun.lockb
├── [File] file_tree_21-54-30.md
├── [File] next-env.d.ts
├── [File] next.config.js
├── [File] package.json
├── [File] postcss.config.cjs
├── [File] prettier.config.js
├── [Directory] prisma
│ └── [File]
├── [Directory] public
│ └── [File]
├── [Directory] src
│ ├── [File]
│ ├── [Directory] app
│ │ ├── [File]
│ │ ├── [Directory] _components
│ │ │ └── [File]
│ │ ├── [Directory] api
│ │ │ ├── [File]
│ │ │ └── [Directory] auth
│ │ │ └── [File]
│ │ └── [File] layout.tsx
│ ├── [File] env.js
│ ├── [Directory] server
│ │ ├── [File]
│ │ ├── [Directory] api
│ │ │ ├── [File]
│ │ │ ├── [File] root.ts
│ │ │ └── [Directory] routers
│ │ │ └── [File]
│ │ └── [File] auth.ts
│ └── [Directory] styles
│ └── [File]
└── [File] tailwind.config.ts
This script was created by easttexaselectronics. Contributions and feedback are welcome!
This project is licensed under the GNU Affero General Public License v3.0. For more information, see the LICENSE file.