Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option '--combine' to display all mount points in one table #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ If you want to list everything (including pseudo, duplicate, inaccessible file s

duf --all

If you want to display all mount points in just one table:

duf --combine

### Filtering

You can show and hide specific tables:
Expand Down
2 changes: 2 additions & 0 deletions duf.1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ hide specific mount points, separated with commas (supports wildcards)
.TP
\fB-inodes\fP
list inode information instead of block usage
\fB-combine\fP
Display all mount points in one table
.TP
\fB-json\fP
output all devices in JSON format
Expand Down
27 changes: 17 additions & 10 deletions groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,9 @@ func renderTables(m []Mount, filters FilterOptions, opts TableOptions) {
}

t := deviceType(v)
deviceMounts[t] = append(deviceMounts[t], v)
}

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

shouldPrint := *all
if !shouldPrint {
switch devType {
if !shouldPrint || *all == true {
switch t {
case localDevice:
shouldPrint = (hasOnlyDevices && onlyLocal) || (!hasOnlyDevices && !hideLocal)
case networkDevice:
Expand All @@ -121,9 +114,23 @@ func renderTables(m []Mount, filters FilterOptions, opts TableOptions) {
case specialDevice:
shouldPrint = (hasOnlyDevices && onlySpecial) || (!hasOnlyDevices && !hideSpecial)
}
if shouldPrint {
if *combinedTable {
t = "combined"
}
deviceMounts[t] = append(deviceMounts[t], v)
}
}

if shouldPrint {
}

if *combinedTable {
// print combined table
printTable("total", deviceMounts["combined"], opts)
} else {
// print tables
for _, devType := range groups {
mounts := deviceMounts[devType]
printTable(devType, mounts, opts)
}
}
Expand Down
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ var (
themeOpt = flag.String("theme", defaultThemeName(), "color themes: dark, light, ansi")
styleOpt = flag.String("style", defaultStyleName(), "style: unicode, ascii")

combinedTable = flag.Bool("combine", false, "display only one table for all mount points")

availThreshold = flag.String("avail-threshold", "10G,1G", "specifies the coloring threshold (yellow, red) of the avail column, must be integer with optional SI prefixes")
usageThreshold = flag.String("usage-threshold", "0.5,0.9", "specifies the coloring threshold (yellow, red) of the usage bars as a floating point number from 0 to 1")

Expand Down Expand Up @@ -308,8 +310,9 @@ func main() {

// print tables
renderTables(m, filters, TableOptions{
Columns: columns,
SortBy: sortCol,
Style: style,
Columns: columns,
SortBy: sortCol,
Style: style,
combinedTable: *combinedTable,
})
}
4 changes: 4 additions & 0 deletions man.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ List inode information instead of block usage:

$ duf --inodes

Display all mount points in one table:

$ duf --combine

If duf doesn't detect your terminal's colors correctly, you can set a theme:

$ duf --theme light
Expand Down
7 changes: 4 additions & 3 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (

// TableOptions contains all options for the table.
type TableOptions struct {
Columns []int
SortBy int
Style table.Style
Columns []int
SortBy int
Style table.Style
combinedTable bool
}

// Column defines a column.
Expand Down