Token map
--token-map prints a directory tree to the terminal with a token weight on
every file and folder, so instead of guessing what's bloating a 291k-token run
you can see it:
gnaw . --token-mapโโโ src/
โโโ components/ 180,000 tokens
โโโ lib.rs 4,200 tokens
โโโ main.rs 900 tokens
The weight on a directory is the sum of its contents, so the heavy subtrees are
obvious at a glance โ and that's usually your cue for what to --exclude or
compress next.
Tuning the output
| Flag | Effect |
|---|---|
--token-map | Enable the token-weighted tree |
--token-map-lines <N> | Cap the tree at roughly N lines |
--token-map-min-percent <P> | Hide entries below P percent of the total |
# Top of the tree only, hiding anything under 1% of the total
gnaw . --token-map --token-map-lines 40 --token-map-min-percent 1
--token-map-min-percent is the quickest way to cut noise: set it to 1 and the
map collapses to just the files and folders actually worth your attention.