- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
duatui
A disk usage analyzer for the terminal. It walks the tree on every core at once and shows you a foldable, size-ordered tree you can delete from.
╭ /home/anon 366.8 GiB ───────────────────────────────────────────────────╮
│ 366.8 GiB ██████████ 100% ▾ anon/ 3.5M items │
│ 89.0 GiB ██░░░░░░░░ 24% ▸ .local/ 472.8k items │
│ 63.8 GiB ██░░░░░░░░ 17% ▸ Src/ 624.2k items │
│ 44.1 GiB █░░░░░░░░░ 12% ▾ .config/ 238.2k items │
│ 4.7 GiB █░░░░░░░░░ 11% ▸ PCSX2/ 48 items │
╰──────────────────────────✓ 1.20s 460.1k dirs · 3.0M files · 4 unreadable ╯
j/k move space fold h/l out/in d delete r rescan ? keys q quit
Build
cargo build --release
./target/release/duatui [PATH]
PATH defaults to the current directory.
Keys
| key | does |
|---|---|
j / k, ↓ / ↑ |
move down / up |
space |
mark or unmark for deletion |
l, →, enter |
unfold it, or step into it |
h, ← |
fold it, or step out to the parent |
g / G |
jump to top / bottom |
ctrl-d / ctrl-u |
half page down / up |
/ |
list the directory you are in, fuzzy-filtered |
s |
search the whole tree |
n / N |
next / previous match |
d, del |
delete what is marked, else the row (asks first) |
c |
copy the selection's absolute path |
r |
rescan from disk |
? |
key list |
esc |
drop the marks, then the filter, then quit |
q |
quit |
Deleting several things
hjkl already folds and unfolds, so space marks instead: it flags the row
and steps down, which makes marking a run of directories a few taps. Marked
rows carry a ● in the left gutter and the title keeps a running total of what
they would free.
d then asks about the whole marked set, listing it with its total; with
nothing marked it asks about the row under the cursor as before. Marking
something inside something else already marked is harmless — the totals count
the outer one only once, and the inner one is skipped at deletion rather than
failing after its parent took it. The scan root itself cannot be marked.
esc drops the marks. Marks survive filtering, so /, enter, then a few
spaces is a quick way to clear out one directory — though inside the filter
box itself space types a space, since names contain them.
Finding things
Two different questions deserve two different answers.
/ — what is in here? Lists the directory the cursor is in, flat and
biggest first, and narrows it as you type. The match is fuzzy: nmd finds
node_modules, and the characters it used are picked out in the name.
What you get is always the parent of the row you are on, so a row is listed
among its own neighbours — the row you came from stays under the cursor until
you type. Only the root stands for itself, having nothing above it. The listing
covers that one directory and nothing below it, and it stays open until esc,
so with the box empty you simply get everything there. l steps into a
subdirectory and h steps back out, which makes it a quick way to walk down a
heavy branch.
s — where is this? Searches every name in the tree by substring and
shows the matches in place, keeping the directories above each one so you can
see where it lives. The fold arrows follow what is on screen, so a match inside
a directory you never unfolded still shows up. A directory that matches is a
destination rather than a signpost, so its contents are not filtered:
unfold it and everything inside is there. n and N walk between matches,
skipping the directories that are only there as context.
Either way, enter keeps the filter and hands the cursor back to hjkl, and
esc goes back to the tree — unfolding whatever leads to the row you were on,
so the thing you just found is still under the cursor.
Searching the tree walks every name in it, which is memory-bound pointer chasing, so the top two levels are spread across the thread pool: around 75ms over a 2.9M-entry home directory, against 250ms for the same walk on one thread. It works mid-scan too — the counts simply grow as the walk fills in.
c copies through wl-copy, xclip or xsel when one is available, and
falls back to handing the path to the terminal itself with OSC 52 — which is
what makes it work over ssh. The helper is detached into its own process group,
so on X11 the path stays on the clipboard after duatui exits or the terminal
window closes.
Children are always ordered biggest first, at every level, including while the scan is still running. The percentage and bar show each entry's share of its parent.
Flags
| flag | effect |
|---|---|
-a, --apparent-size |
count the bytes files claim, not the blocks they occupy |
-x, --cross-filesystems |
descend past mount points |
-j N, --threads N |
worker threads (default: one per core) |
How sizes are counted
- Blocks, not bytes. By default a file weighs what it occupies on disk
(
st_blocks × 512), which is what you actually get back by deleting it. A sparse or compressed file can therefore read smaller than its length. Use--apparent-sizefor the other number. - Hardlinks are counted once, charged to whichever path the scan reached
first; the other names show
0 B ⇔ hardlink. Deleting one of them frees nothing until the last name is gone — pressrto recount. - Symlinks are never followed; a link weighs only itself.
- Mount points are skipped unless you pass
-x, so scanning/does not wander into/proc,/sysor a network mount. - Directories you cannot read are marked
⨯and counted as 0; the footer keeps a tally of them.
Totals match du byte for byte (du -sB1, or du -sb with
--apparent-size).
macOS
Builds and runs the same way; c copies through pbcopy. Two things differ:
- Scanning
/will look far too small./Userslives on a separate APFS volume reached by a firmlink, so staying on one filesystem leaves it out — the footer says how many mounts it skipped. Scan~for your own files, orduatui -x /for everything. - Sizes come from
st_blocks, so an APFS clone (a copy made by Finder orcp -c) weighs only the blocks it does not share with its original.
Windows
Builds and runs; c copies through the built-in clip.exe. Sizes are real
occupancy, not file lengths:
- A file costs whole clusters, read from the volume with
GetDiskFreeSpaceW— so a one-byte file on a default NTFS volume weighs 4 KiB, the way it does in Explorer's "size on disk". - A compressed or sparse file is asked about individually with
GetCompressedFileSizeW, since it occupies less than its clusters suggest. The attribute arrives free with the directory listing, so that call is made only for the rare file that needs it and a normal scan pays nothing for it. --apparent-sizegives the plain length instead, as on unix.
Two things are still unavailable there: -x has nothing to compare, and no
hardlink is discounted — both want st_dev/st_nlink, which Windows only
offers per open handle. A mounted volume or junction is a reparse point, which
is not reported as a directory, so the walk stops at one rather than looping.
Paths are shown and copied without the \\?\ prefix that canonicalize
adds, while the calls above are made with it, so neither readability nor long
paths is given up.
Speed
Scanning /usr — 771k entries, 25.6 GiB — on a 16-core machine, warm cache:
| threads | time |
|---|---|
du -sB1 (single-threaded) |
1.72s |
duatui -j1 |
1.83s |
duatui -j4 |
0.54s |
duatui -j8 |
0.30s |
duatui (16) |
0.23s |
A 367 GiB home directory of 3.45M files scans in 1.2s warm, 3.8s cold. The tree is usable from the first frame: sizes grow and reorder underneath you while the walk is still running, and the cursor stays on whatever row you put it on.