Files
tree-generator/Releases/v1.0.0/docs/QUICKSTART.md
2026-05-16 17:34:32 +08:00

1.6 KiB
Raw Blame History

tree.sh 快速入门

版本 1.0.0 | 纯 Bash 目录树生成工具

1 分钟上手

安装

# 下载脚本
chmod +x tree.sh

# 可选:安装到系统 PATH
sudo cp tree.sh /usr/local/bin/tree.sh

基本使用

# 生成当前目录的树
./tree.sh

# 生成指定目录的树
./tree.sh -p /path/to/project

# 生成树 + 文件列表
./tree.sh -p . -f

# 限制深度为 2 层
./tree.sh -p . -d 2

# 保存到指定文件
./tree.sh -p . -o my-tree.md

输出示例

my-project/
├── src/
│   ├── main.sh
│   └── utils/
│       └── helpers.sh
├── tests/
│   └── test_main.sh
├── README.md
└── tree_output.md

Statistics:
  Directories: 4
  Files:       5
  Total size:  8.42 KB

常用场景

场景 命令
查看项目结构 ./tree.sh -p ./project
生成文档用树 ./tree.sh -p . -f -o README-tree.md
只看前 2 层 ./tree.sh -p . -d 2
排除日志文件 创建 .treeignore,写入 *.log

自定义忽略规则

在目标目录创建 .treeignore

# .treeignore
*.log
tmp
coverage
*.bak

命令行选项速查

选项 说明
-p <路径> 目标目录
-o <文件> 输出 Markdown 文件
-d <N> 最大深度
-f 包含文件列表
-s 不显示统计
-h 帮助
-v 版本

退出码

含义
0 成功
1 参数错误
2 路径无效
3 写入失败

详细文档请查看 README.md