file-mapper is a versatile CLI tool that combines the power of the Linux tree
command (for hierarchical directory listings) and the cat
command (for file content viewing)—all rolled into one convenient package. Recursively map out your project structure, filter files, and optionally display file contents (with features like line numbering). It's ideal for developers who want a comprehensive project overview or need to share both file structure and content with others (e.g., in code reviews or AI tools).
-
Tree or Flat
- By default,
file-mapper
displays a hierarchical tree of your files and directories (liketree
). - Use the
--flat
flag for a flat listing instead.
- By default,
-
Git-Tracked-Only
- Restrict the output to only files that are tracked by Git (
--git
).
- Restrict the output to only files that are tracked by Git (
-
Include / Exclude Patterns
- Filter specific file types (e.g.
--include="*.go,*.md"
) - Exclude directories/files (e.g.
--exclude=".git,node_modules"
).
- Filter specific file types (e.g.
-
Hidden & Binary Skips
- Hidden files/directories (those starting with
.
) are ignored by default. - Uses a naive approach to skip binary files.
- Hidden files/directories (those starting with
-
Content Viewing
- Inline content right below each file (similar to
cat
, but recursive) (--content
). - Or separate: list all files, then dump their contents afterward.
- Enable line numbers (
--line-numbers
) for quick reference. - Show or hide content headers (
----- CONTENT START -----
/----- CONTENT END -----
).
- Inline content right below each file (similar to
-
Output to File
- Save your entire listing and contents to a file (
--output=out.txt
).
- Save your entire listing and contents to a file (
- One-Stop Command: Instead of running
tree
to see the structure and thencat
orless
for file contents,file-mapper
does it all in one go, recursively. - Share With AI or Peers: Perfect for pasting a project’s structure and file contents into ChatGPT or sending it to teammates.
- Saves Time: No manual copy-pasting or multiple commands—filter, track only Git files, and see everything at a glance.
If you’re on macOS, you can install file-mapper via Homebrew:
brew install sky93/file-mapper/file-mapper
You can download a prebuilt binary for your operating system from the GitHub Releases page. Once downloaded, simply place the executable in your PATH
(e.g., /usr/local/bin
on macOS/Linux or somewhere in your PATH
on Windows).
If you have Go installed and prefer installing from source, you can do:
go install github.com/sky93/file-mapper/cmd/file-mapper@latest
This command fetches and installs the latest version of file-mapper from the GitHub repo, placing the binary in your Go
bin
folder (usually~/go/bin
).
Tip: Ensure your
~/go/bin
(or the equivalent on your system) is in your$PATH
so that you can runfile-mapper
from anywhere.
Once installed:
file-mapper [flags...]
Alternatively, if you cloned the repo locally and want to run without installing:
git clone https://github.com/sky93/file-mapper.git
cd file-mapper/cmd/projectMapper
go run main.go [flags...]
Flag | Alias | Default | Description |
---|---|---|---|
--path |
-p |
. |
Root path to scan |
--include |
-i |
Comma-separated file patterns to include (e.g. --include="*.go,*.md" ) |
|
--exclude |
-e |
Comma-separated directories/files to exclude (e.g. --exclude=".git,.idea,.env" ) |
|
--git |
-g |
false |
Only list files tracked by Git |
--content |
-c |
false |
Show file content (for text files) |
--separate-content |
-s |
true |
Print the file listing first, then all file contents afterward (instead of inline) |
--flat |
false |
Show a flat list instead of a tree | |
--output |
-o |
Output file path (if not provided, prints to stdout) | |
--line-numbers |
false |
Show line numbers for file content | |
--header-footer |
true |
Print ----- CONTENT START ----- / ----- CONTENT END ----- around file content |
|
--help |
Show help message | ||
--version |
Print version information and exit |
-
Default Tree
file-mapper
- Displays the folder/file structure in a tree.
- Skips hidden directories and binary files.
-
Display File Contents Inline
file-mapper --content
- Combines tree +
cat
for each file, printing content right below the file.
- Combines tree +
-
Only Git-Tracked Files
file-mapper --git
- Recursively traverses your directories, showing only files tracked by Git.
-
Tree + Separate Content
file-mapper --content --separate-content
- Prints the tree, then appends file contents at the end.
-
Flat Listing
file-mapper --flat
- Shows a simple list of files/directories.
-
Include/Exclude Patterns
file-mapper --include="*.go,*.txt" --exclude=".git,.idea,node_modules"
-
Output to a File
file-mapper --output=map.txt
- Saves the entire listing and optional content to
map.txt
.
- Saves the entire listing and optional content to
-
Line Numbers + Content
file-mapper --content --line-numbers
All contributions are welcome! If you have any feature requests, bug reports, or ideas, feel free to open an issue or submit a pull request.
Please see the LICENSE file for details.
Happy mapping with file-mapper! If you find it useful, give it a star on GitHub.