-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Windows] Do not maximize console window by default * [Windows] Fix maximize console bug * [Windows] Detect that program is launched by powershell.exe or explorer.exe * [UNIX] Reformat information about used inodes and partitions * [JSON] Fix bug in Ncdu export when filename contains double quotes * Show 8 biggest files by default (customizable) * Display sizes in human readable format by default (customizable) * Add Go module support
- Loading branch information
1 parent
c50db70
commit 3703ded
Showing
13 changed files
with
589 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.TH TDU 1 "2020-06-10" "1.34" "Top Disk Usage manual" | ||
.TH TDU 1 "2021-06-24" "1.36" "Top Disk Usage manual" | ||
|
||
.SH NAME | ||
tdu \- get information about largest files and directories | ||
|
@@ -22,9 +22,7 @@ or at current directory by default. | |
.br | ||
* Counts empty directories, denied accesses, errors. | ||
.br | ||
* Shows deepest directory path. | ||
.br | ||
* Shows longest file path. | ||
* Shows deepest directory path and longest file path. | ||
.br | ||
* Displays information about the filesystem (type, mount options, size, inodes). | ||
|
||
|
@@ -55,13 +53,18 @@ Number of sockets and named pipes shown (default 0) | |
Number of file status errors shown (default 0) | ||
.TP | ||
.BR \-\-human | ||
Print sizes in human readable format (default Kb only) | ||
Print sizes in human readable format (default). | ||
.br | ||
Use \-\-human=false to print sizes in kilobytes. | ||
.TP | ||
.BI \-o \ file | ||
Export result to Ncdu JSON format | ||
.br | ||
(https://dev.yorhel.nl/ncdu/jsonfmt) | ||
.TP | ||
.BR \-\-consolemax | ||
Maximizes console window (Windows only, default no) | ||
.TP | ||
.BR \-\-version | ||
Program info and usage | ||
.TP | ||
|
@@ -76,14 +79,13 @@ Does not cross filesystem boundaries. It behaves like | |
.B du \-skx | ||
|
||
.SH COPYRIGHT | ||
Copyright \(co 2019,2020 Joseph Paul <[email protected]>. | ||
Copyright \(co 2019-2021 Joseph Paul <[email protected]>. | ||
.br | ||
License GPLv2+: GNU GPL version 2 or later. | ||
|
||
.SH WEBSITE | ||
https://bitbucket.org/josephpaul0/tdu | ||
https://github.com/josephpaul0/tdu | ||
|
||
.SH "SEE ALSO" | ||
.BR du (1), | ||
.BR ncdu (1) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/josephpaul0/tdu | ||
|
||
go 1.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* Top Disk Usage. | ||
* Copyright (C) 2019 Joseph Paul <[email protected]> | ||
* https://bitbucket.org/josephpaul0/tdu | ||
* Copyright (C) 2019-2021 Joseph Paul <[email protected]> | ||
* https://github.com/josephpaul0/tdu | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -38,14 +38,14 @@ import ( | |
) | ||
|
||
const ( | ||
prg_VERSION = "1.34" | ||
prg_VERSION = "1.36" | ||
dft_MAXSHOWNLINES = 15 | ||
dft_MAXEMPTYDIRS = 0 | ||
dft_MAXDENIEDDIRS = 0 | ||
dft_MAXSTATERROR = 0 | ||
dft_MAXSTREAMS = 0 | ||
dft_MAXDEVICES = 0 | ||
dft_MAXBIGFILES = 7 | ||
dft_MAXBIGFILES = 8 | ||
cst_ENDPROGRESS = "###" | ||
cst_PROGRESSBEAT = 80 // ms | ||
) | ||
|
@@ -108,6 +108,7 @@ type s_scan struct { // Global variables | |
export bool // export result to Ncdu's JSON format | ||
tty bool // stdout is on a TTY | ||
humanReadable bool // print sizes in human readable format | ||
consoleMax bool // maximize size of console window (on Windows only) | ||
exportPath string // path to exported file | ||
exportFile *os.File // exported file | ||
deepestPath string // deepest subdirectory reached | ||
|
@@ -337,13 +338,15 @@ func printFileTypes(sc *s_scan) { // Summary of file types with non-zero counter | |
fmt.Printf(", Symlink: %d", sc.nSymlinks) | ||
} | ||
if sc.nHardlinks > 0 { | ||
fmt.Printf(", Hardlink: %d", sc.nHardlinks) | ||
fmt.Printf(",\n Hardlink: %d", sc.nHardlinks) | ||
} | ||
if sc.nSockets > 0 { | ||
fmt.Printf(", Socket: %d", sc.nSockets) | ||
} | ||
if sc.nDenied > 0 { | ||
fmt.Printf(", Denied: %d", sc.nDenied) | ||
fmt.Printf(", ") | ||
msg := fmt.Sprintf("Denied: %d", sc.nDenied) | ||
printAlert(sc, msg) | ||
} | ||
if sc.nErrors > 0 { | ||
fmt.Printf(", Error: %d", sc.nErrors) | ||
|
@@ -609,7 +612,7 @@ func show(sc *s_scan, fi []file, total *file) { | |
nf := fmt.Sprintf("%%%ds", fmtNameLen+1) | ||
cf := fmt.Sprintf("%%%ds", countDigits(total.diskUsage)+1) | ||
mf := fmt.Sprintf("%%%dd", countDigits(sc.nItems)+1) | ||
var strfmt = "%3d." + nf + "|" + cf + "|%6.2f%%" | ||
var strfmt = "%3d." + nf + "|" + cf + "|%6.2f%%|" | ||
i = 0 | ||
for _, f := range fi { | ||
if !f.isDir && sc.nFiles == 0 { // ignore special files | ||
|
@@ -629,7 +632,7 @@ func show(sc *s_scan, fi []file, total *file) { | |
} | ||
fmt.Printf(strfmt, i, f.name, fmtSz(sc, f.diskUsage), p) | ||
if f.isDir { | ||
fmt.Printf("|"+mf+" items", f.items) | ||
fmt.Printf(mf+" items", f.items) | ||
} | ||
fmt.Println() | ||
} | ||
|
@@ -640,8 +643,8 @@ func show(sc *s_scan, fi []file, total *file) { | |
fmt.Printf(s, "REMAINING", fmtSz(sc, rDiskUsage), p, rItems) | ||
} | ||
strfmt += "\n" | ||
fmt.Printf(strfmt, "TOTAL", fmtSz(sc, total.diskUsage)) | ||
fmt.Printf(strfmt, "Apparent size", fmtSz(sc, total.size)) | ||
fmt.Printf(strfmt, "DISK SPACE", fmtSz(sc, total.diskUsage)) | ||
fmt.Printf(strfmt, "TOTAL SIZE", fmtSz(sc, total.size)) | ||
fmt.Println() | ||
printFileTypes(sc) | ||
} | ||
|
@@ -669,8 +672,8 @@ func changeDir(args []string) (string, error) { | |
func usage(sc *s_scan) []string { | ||
flag.Usage = func() { | ||
showTitle() | ||
fmt.Println(" Copyright (c) 2020 Joseph Paul <[email protected]>") | ||
fmt.Println(" https://bitbucket.org/josephpaul0/tdu") | ||
fmt.Println(" Copyright (c) 2019-2021 Joseph Paul <[email protected]>") | ||
fmt.Println(" https://github.com/josephpaul0/tdu") | ||
fmt.Println() | ||
fmt.Printf(" Usage: %s [options] [directory]\n", os.Args[0]) | ||
fmt.Println() | ||
|
@@ -691,7 +694,8 @@ func usage(sc *s_scan) []string { | |
nm := flag.Bool("max", false, "Show deepest and longest paths") | ||
vs := flag.Bool("version", false, "Program info and usage") | ||
sl := flag.Bool("license", false, "Show the GNU General Public License V2") | ||
hu := flag.Bool("human", false, "Print sizes in human readable format") | ||
hu := flag.Bool("human", true, "Print sizes in human readable format.\nUse --human=false to print in kilobytes instead.") | ||
cm := flag.Bool("consolemax", false, "Maximize console window (on Windows only)") | ||
flag.Parse() // NArg (int) | ||
if *sl { | ||
showLicense() | ||
|
@@ -736,6 +740,7 @@ func usage(sc *s_scan) []string { | |
} | ||
sc.showMax = *nm | ||
sc.humanReadable = *hu | ||
sc.consoleMax = *cm | ||
if *ex != "" { | ||
sc.export = true | ||
sc.exportPath = *ex | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
/* Top Disk Usage. | ||
* Copyright (C) 2019 Joseph Paul <[email protected]> | ||
* https://bitbucket.org/josephpaul0/tdu | ||
* https://github.com/josephpaul0/tdu | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* Top Disk Usage. | ||
* Copyright (C) 2019 Joseph Paul <[email protected]> | ||
* https://bitbucket.org/josephpaul0/tdu | ||
* https://github.com/josephpaul0/tdu | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -79,7 +79,7 @@ func cleanName(s string) string { | |
rs := []rune(s) | ||
rd := make([]rune, 0, len(s)) | ||
for i := 0; i < len(rs); i++ { | ||
if rs[i] <= 31 || rs[i] == 127 { | ||
if rs[i] <= 31 || rs[i] == 34 || rs[i] == 127 { | ||
u := []rune(fmt.Sprintf("\\u00%02X", rs[i])) | ||
rd = append(rd, u...) | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
/* Top Disk Usage. | ||
* Copyright (C) 2019 Joseph Paul <[email protected]> | ||
* https://bitbucket.org/josephpaul0/tdu | ||
* https://github.com/josephpaul0/tdu | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -34,6 +34,10 @@ func getTtyWidth() int { | |
|
||
func initTty(sc *sc_scan) {} // OS Specific | ||
|
||
func printAlert(sc *s_scan, msg string) { | ||
fmt.Printf(msg) | ||
} | ||
|
||
func printProgress(sc *s_scan) { | ||
n := sc.nErrors + sc.nItems | ||
fmt.Printf(" [.... scanning... %6d ....]\r", n) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* Top Disk Usage. | ||
* Copyright (C) 2019 Joseph Paul <[email protected]> | ||
* https://bitbucket.org/josephpaul0/tdu | ||
* https://github.com/josephpaul0/tdu | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
/* Top Disk Usage. | ||
* Copyright (C) 2019 Joseph Paul <[email protected]> | ||
* https://bitbucket.org/josephpaul0/tdu | ||
* https://github.com/josephpaul0/tdu | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
/* Top Disk Usage. | ||
* Copyright (C) 2019 Joseph Paul <[email protected]> | ||
* https://bitbucket.org/josephpaul0/tdu | ||
* https://github.com/josephpaul0/tdu | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -222,6 +222,16 @@ func colorCyan() { fmt.Printf(color_CYAN) } | |
func colorMagenta() { fmt.Printf(color_MAGENTA) } | ||
func colorAlert() { fmt.Printf(color_ALERT) } | ||
|
||
func printAlert(sc *s_scan, msg string) { | ||
if sc.tty { | ||
colorRed() | ||
} | ||
fmt.Printf(msg) | ||
if sc.tty { | ||
colorDefault() | ||
} | ||
} | ||
|
||
func printProgress(sc *s_scan) { | ||
if !sc.tty { | ||
return | ||
|
@@ -360,10 +370,8 @@ func partInfo(sc *s_scan) { | |
if total > 0 { | ||
avail = uint64(statfs.Ffree) | ||
used = total - avail | ||
fmt.Printf(" Inodes :%11d ", total) | ||
fmt.Printf("Avail:%10d ", avail) | ||
fmt.Printf("Used:%10d (%d%%)", used, used*100/total) | ||
fmt.Println() | ||
fmt.Printf(" Inodes :%10d used (%2d%%) of %10d. Avail:%10d\n", | ||
used, used*100/total, total, avail) | ||
} | ||
total = statfs.Blocks * uint64(statfs.Bsize) | ||
if total > 0 { | ||
|
@@ -373,13 +381,12 @@ func partInfo(sc *s_scan) { | |
total /= 1024 | ||
avail /= 1024 | ||
used /= 1024 | ||
fmt.Printf(" Size(kb):%11d ", total) | ||
fmt.Printf("Avail:%10d ", avail) | ||
fmt.Printf("Used:%10d (%d%%)\n", used, used*100/total) | ||
fmt.Printf(" Size(kb):%10d used (%2d%%) of %10d. Avail:%10d\n", | ||
used, used*100/total, int64(total), int64(avail)) | ||
} else { | ||
fmt.Printf(" Size :%11s ", fmtSz(sc, int64(total))) | ||
fmt.Printf("Avail:%10s ", fmtSz(sc, int64(avail))) | ||
fmt.Printf("Used:%10s (%d%%)\n", fmtSz(sc, int64(used)), used*100/total) | ||
fmt.Printf(" Size :%10s used (%2d%%) of %10s. Avail:%10s\n", | ||
fmtSz(sc, int64(used)), used*100/total, | ||
fmtSz(sc, int64(total)), fmtSz(sc, int64(avail))) | ||
} | ||
} | ||
fmt.Println() | ||
|
Oops, something went wrong.