Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ Wildcards inside quotes work:

duf --only-mp '/sys/*,/dev/*'

By default, duf renders a separate table per device group (local, network,
fuse, ...). Combine them into a single table with:

duf --combine

### Display options

Sort the output:
Expand Down
3 changes: 3 additions & 0 deletions duf.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ include pseudo, duplicate, inaccessible file systems
\fB--avail-threshold\fP
specifies the coloring threshold (yellow, red) of the avail column, must be integer with optional SI prefixes
.TP
\fB--combine\fP
combine all device groups into a single table
.TP
\fB--hide\fP
hide specific devices, separated with commas: local, network, fuse, special, loops, binds
.TP
Expand Down
26 changes: 20 additions & 6 deletions groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ func renderTables(m []Mount, filters FilterOptions, opts TableOptions) {
deviceMounts[t] = append(deviceMounts[t], v)
}

// print tables
for _, devType := range groups {
mounts := deviceMounts[devType]

// determine which groups should be printed
shouldPrintGroup := func(devType string) bool {
shouldPrint := *all
if !shouldPrint {
switch devType {
Expand All @@ -122,9 +120,25 @@ func renderTables(m []Mount, filters FilterOptions, opts TableOptions) {
shouldPrint = (hasOnlyDevices && onlySpecial) || (!hasOnlyDevices && !hideSpecial)
}
}
return shouldPrint
}

// combine all visible groups into a single table
if opts.Combine {
var combined []Mount
for _, devType := range groups {
if shouldPrintGroup(devType) {
combined = append(combined, deviceMounts[devType]...)
}
}
printTable("", combined, opts)
return
}

if shouldPrint {
printTable(devType, mounts, opts)
// print tables
for _, devType := range groups {
if shouldPrintGroup(devType) {
printTable(devType, deviceMounts[devType], opts)
}
}
}
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (
onlyFs = flag.String("only-fs", "", "only specific filesystems, separated with commas")
onlyMp = flag.String("only-mp", "", "only specific mount points, separated with commas (supports wildcards)")

combine = flag.Bool("combine", false, "combine all device groups into a single table")
output = flag.String("output", "", "output fields: "+strings.Join(columnIDs(), ", "))
sortBy = flag.String("sort", "mountpoint", "sort output by: "+strings.Join(columnIDs(), ", "))
width = flag.Uint("width", 0, "max output width")
Expand Down Expand Up @@ -358,5 +359,6 @@ func main() {
SortBy: sortCol,
Style: style,
StyleName: *styleOpt,
Combine: *combine,
})
}
7 changes: 6 additions & 1 deletion table.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type TableOptions struct {
SortBy int
Style table.Style
StyleName string
Combine bool
}

// Column defines a column.
Expand Down Expand Up @@ -428,7 +429,11 @@ func printTable(title string, m []Mount, opts TableOptions) {
if tab.Length() > 1 {
suffix = "devices"
}
tab.SetTitle("%d %s %s", tab.Length(), title, suffix)
if title == "" {
tab.SetTitle("%d %s", tab.Length(), suffix)
} else {
tab.SetTitle("%d %s %s", tab.Length(), title, suffix)
}

// tab.AppendFooter(table.Row{fmt.Sprintf("%d %s", tab.Length(), title)})
sortMode := table.Asc
Expand Down