mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-12 17:08:39 -09:00
Add CLI options for all UI settings
+ reorder manpage a bit, since the scan options tend to be more relevant than all those UI options. Again, these are mainly useful with a config file.
This commit is contained in:
parent
d005e7c685
commit
900d31f6fd
3 changed files with 130 additions and 68 deletions
147
ncdu.pod
147
ncdu.pod
|
|
@ -75,6 +75,58 @@ using 'm' and 'M', respectively.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
=head2 Scan Options
|
||||||
|
|
||||||
|
These options affect the scanning progress, and have no effect when importing
|
||||||
|
directory information from a file.
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item -x, --one-file-system
|
||||||
|
|
||||||
|
Do not cross filesystem boundaries, i.e. only count files and directories on
|
||||||
|
the same filesystem as the directory being scanned.
|
||||||
|
|
||||||
|
=item --cross-file-system
|
||||||
|
|
||||||
|
Do cross filesystem boundaries. This is the default, but can be specified to
|
||||||
|
overrule a previously given C<-x>.
|
||||||
|
|
||||||
|
=item --exclude I<PATTERN>
|
||||||
|
|
||||||
|
Exclude files that match I<PATTERN>. The files will still be displayed by
|
||||||
|
default, but are not counted towards the disk usage statistics. This argument
|
||||||
|
can be added multiple times to add more patterns.
|
||||||
|
|
||||||
|
=item -X I<FILE>, --exclude-from I<FILE>
|
||||||
|
|
||||||
|
Exclude files that match any pattern in I<FILE>. Patterns should be separated
|
||||||
|
by a newline.
|
||||||
|
|
||||||
|
=item --include-caches, --exclude-caches
|
||||||
|
|
||||||
|
Include (default) or exclude directories containing CACHEDIR.TAG. The
|
||||||
|
directories will still be displayed, but their contents will not be scanned or
|
||||||
|
counted towards the disk usage statistics.
|
||||||
|
L<http://www.brynosaurus.com/cachedir/>
|
||||||
|
|
||||||
|
=item -L, --follow-symlinks, --no-follow-symlinks
|
||||||
|
|
||||||
|
Follow (or not) symlinks and count the size of the file they point to. As of
|
||||||
|
ncdu 1.14, this option will not follow symlinks to directories and will count
|
||||||
|
each symlinked file as a unique file (i.e. unlike how hard links are handled).
|
||||||
|
This is subject to change in later versions.
|
||||||
|
|
||||||
|
=item --include-kernfs, --exclude-kernfs
|
||||||
|
|
||||||
|
(Linux only) Include (default) or exclude Linux pseudo filesystems, e.g. /proc
|
||||||
|
(procfs), /sys (sysfs).
|
||||||
|
|
||||||
|
The complete list of currently known pseudo filesystems is: binfmt, bpf, cgroup,
|
||||||
|
cgroup2, debug, devpts, proc, pstore, security, selinux, sys, trace.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=head2 Interface options
|
=head2 Interface options
|
||||||
|
|
||||||
=over
|
=over
|
||||||
|
|
@ -140,11 +192,54 @@ List sizes using base 10 prefixes, that is, powers of 1000 (KB, MB, etc), as
|
||||||
defined in the International System of Units (SI), instead of the usual base 2
|
defined in the International System of Units (SI), instead of the usual base 2
|
||||||
prefixes, that is, powers of 1024 (KiB, MiB, etc).
|
prefixes, that is, powers of 1024 (KiB, MiB, etc).
|
||||||
|
|
||||||
|
=item --disk-usage, --apparent-size
|
||||||
|
|
||||||
|
Select whether to display disk usage (default) or apparent sizes. Can also be
|
||||||
|
toggled in the browser with the 'a' key.
|
||||||
|
|
||||||
|
=item --show-hidden, --hide-hidden
|
||||||
|
|
||||||
|
Show (default) or hide "hidden" and excluded files. Can also be toggled in the
|
||||||
|
browser with the 'e' key.
|
||||||
|
|
||||||
|
=item --show-itemcount, --hide-itemcount
|
||||||
|
|
||||||
|
Show or hide (default) the item counts column. Can also be toggled in the
|
||||||
|
browser with the 'c' key.
|
||||||
|
|
||||||
|
=item --show-mtime, --hide-mtime
|
||||||
|
|
||||||
|
Show or hide (default) the last modification time column. Can also be toggled
|
||||||
|
in the browser with the 'm' key. This option is ignored when not in extended
|
||||||
|
mode (see C<-e>).
|
||||||
|
|
||||||
|
=item --show-graph, --hide-graph
|
||||||
|
|
||||||
|
Show (default) or hide the relative size bar column. Can also be toggled in the
|
||||||
|
browser with the 'g' key.
|
||||||
|
|
||||||
|
=item --show-percent, --hide-percent
|
||||||
|
|
||||||
|
Show (default) or hide the relative size percent column. Can also be toggled in
|
||||||
|
the browser with the 'g' key.
|
||||||
|
|
||||||
|
=item --shared-column I<OPTION>
|
||||||
|
|
||||||
|
Set to I<off> to disable the shared size column for directories, I<shared>
|
||||||
|
(default) to display shared directory sizes as a separate column or I<unique>
|
||||||
|
to display unique directory sizes as a separate column. These options can also
|
||||||
|
be cycled through in the browser with the 'u' key.
|
||||||
|
|
||||||
=item --confirm-quit, --no-confirm-quit
|
=item --confirm-quit, --no-confirm-quit
|
||||||
|
|
||||||
Require a confirmation before quitting ncdu. Very helpful when you accidentally
|
Require a confirmation before quitting ncdu. Very helpful when you accidentally
|
||||||
press 'q' during or after a very long scan.
|
press 'q' during or after a very long scan.
|
||||||
|
|
||||||
|
=item --confirm-delete, --no-confirm-delete
|
||||||
|
|
||||||
|
Require a confirmation before deleting a file or directory. Enabled by default,
|
||||||
|
but can be disabled if you're absolutely sure you won't accidentally press 'd'.
|
||||||
|
|
||||||
=item --color I<SCHEME>
|
=item --color I<SCHEME>
|
||||||
|
|
||||||
Select a color scheme. The following schemes are recognized: I<off> to disable
|
Select a color scheme. The following schemes are recognized: I<off> to disable
|
||||||
|
|
@ -156,58 +251,6 @@ The default is I<dark-bg> unless the C<NO_COLOR> environment variable is set.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head2 Scan Options
|
|
||||||
|
|
||||||
These options affect the scanning progress, and have no effect when importing
|
|
||||||
directory information from a file.
|
|
||||||
|
|
||||||
=over
|
|
||||||
|
|
||||||
=item -x, --one-file-system
|
|
||||||
|
|
||||||
Do not cross filesystem boundaries, i.e. only count files and directories on
|
|
||||||
the same filesystem as the directory being scanned.
|
|
||||||
|
|
||||||
=item --cross-file-system
|
|
||||||
|
|
||||||
Do cross filesystem boundaries. This is the default, but can be specified to
|
|
||||||
overrule a previously given C<-x>.
|
|
||||||
|
|
||||||
=item --exclude I<PATTERN>
|
|
||||||
|
|
||||||
Exclude files that match I<PATTERN>. The files will still be displayed by
|
|
||||||
default, but are not counted towards the disk usage statistics. This argument
|
|
||||||
can be added multiple times to add more patterns.
|
|
||||||
|
|
||||||
=item -X I<FILE>, --exclude-from I<FILE>
|
|
||||||
|
|
||||||
Exclude files that match any pattern in I<FILE>. Patterns should be separated
|
|
||||||
by a newline.
|
|
||||||
|
|
||||||
=item --include-caches, --exclude-caches
|
|
||||||
|
|
||||||
Include (default) or exclude directories containing CACHEDIR.TAG. The
|
|
||||||
directories will still be displayed, but their contents will not be scanned or
|
|
||||||
counted towards the disk usage statistics.
|
|
||||||
L<http://www.brynosaurus.com/cachedir/>
|
|
||||||
|
|
||||||
=item -L, --follow-symlinks, --no-follow-symlinks
|
|
||||||
|
|
||||||
Follow (or not) symlinks and count the size of the file they point to. As of
|
|
||||||
ncdu 1.14, this option will not follow symlinks to directories and will count
|
|
||||||
each symlinked file as a unique file (i.e. unlike how hard links are handled).
|
|
||||||
This is subject to change in later versions.
|
|
||||||
|
|
||||||
=item --include-kernfs, --exclude-kernfs
|
|
||||||
|
|
||||||
(Linux only) Include (default) or exclude Linux pseudo filesystems, e.g. /proc
|
|
||||||
(procfs), /sys (sysfs).
|
|
||||||
|
|
||||||
The complete list of currently known pseudo filesystems is: binfmt, bpf, cgroup,
|
|
||||||
cgroup2, debug, devpts, proc, pstore, security, selinux, sys, trace.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
|
|
||||||
=head1 KEYS
|
=head1 KEYS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -202,21 +202,19 @@ const Row = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn graph(self: *Self) void {
|
fn graph(self: *Self) void {
|
||||||
if (main.config.show_graph == .off or self.col + 20 > ui.cols) return;
|
if ((!main.config.show_graph and !main.config.show_percent) or self.col + 20 > ui.cols) return;
|
||||||
|
|
||||||
const bar_size = std.math.max(ui.cols/7, 10);
|
const bar_size = std.math.max(ui.cols/7, 10);
|
||||||
defer self.col += switch (main.config.show_graph) {
|
defer self.col += 3
|
||||||
.off => unreachable,
|
+ (if (main.config.show_graph) bar_size else 0)
|
||||||
.graph => bar_size + 3,
|
+ (if (main.config.show_percent) @as(u32, 6) else 0)
|
||||||
.percent => 9,
|
+ (if (main.config.show_graph and main.config.show_percent) @as(u32, 1) else 0);
|
||||||
.both => bar_size + 10,
|
|
||||||
};
|
|
||||||
const item = self.item orelse return;
|
const item = self.item orelse return;
|
||||||
|
|
||||||
ui.move(self.row, self.col);
|
ui.move(self.row, self.col);
|
||||||
self.bg.fg(.default);
|
self.bg.fg(.default);
|
||||||
ui.addch('[');
|
ui.addch('[');
|
||||||
if (main.config.show_graph == .both or main.config.show_graph == .percent) {
|
if (main.config.show_percent) {
|
||||||
self.bg.fg(.num);
|
self.bg.fg(.num);
|
||||||
ui.addprint("{d:>5.1}", .{ 100*
|
ui.addprint("{d:>5.1}", .{ 100*
|
||||||
if (main.config.show_blocks) @intToFloat(f32, item.blocks) / @intToFloat(f32, std.math.max(1, dir_parent.entry.blocks))
|
if (main.config.show_blocks) @intToFloat(f32, item.blocks) / @intToFloat(f32, std.math.max(1, dir_parent.entry.blocks))
|
||||||
|
|
@ -225,8 +223,8 @@ const Row = struct {
|
||||||
self.bg.fg(.default);
|
self.bg.fg(.default);
|
||||||
ui.addch('%');
|
ui.addch('%');
|
||||||
}
|
}
|
||||||
if (main.config.show_graph == .both) ui.addch(' ');
|
if (main.config.show_graph and main.config.show_percent) ui.addch(' ');
|
||||||
if (main.config.show_graph == .both or main.config.show_graph == .graph) {
|
if (main.config.show_graph) {
|
||||||
const perblock = std.math.divFloor(u64, if (main.config.show_blocks) dir_max_blocks else dir_max_size, bar_size) catch unreachable;
|
const perblock = std.math.divFloor(u64, if (main.config.show_blocks) dir_max_blocks else dir_max_size, bar_size) catch unreachable;
|
||||||
const num = if (main.config.show_blocks) item.blocks else item.size;
|
const num = if (main.config.show_blocks) item.blocks else item.size;
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
|
|
@ -920,11 +918,11 @@ pub fn keyInput(ch: i32) void {
|
||||||
// Display settings
|
// Display settings
|
||||||
'c' => main.config.show_items = !main.config.show_items,
|
'c' => main.config.show_items = !main.config.show_items,
|
||||||
'm' => if (main.config.extended) { main.config.show_mtime = !main.config.show_mtime; },
|
'm' => if (main.config.extended) { main.config.show_mtime = !main.config.show_mtime; },
|
||||||
'g' => main.config.show_graph = switch (main.config.show_graph) {
|
'g' => {
|
||||||
.off => .graph,
|
if (!main.config.show_graph and !main.config.show_percent) { main.config.show_graph = true; main.config.show_percent = false; }
|
||||||
.graph => .percent,
|
else if ( main.config.show_graph and !main.config.show_percent) { main.config.show_graph = false; main.config.show_percent = true; }
|
||||||
.percent => .both,
|
else if (!main.config.show_graph and main.config.show_percent) { main.config.show_graph = true; main.config.show_percent = true; }
|
||||||
.both => .off,
|
else if ( main.config.show_graph and main.config.show_percent) { main.config.show_graph = false; main.config.show_percent = false; }
|
||||||
},
|
},
|
||||||
'u' => main.config.show_shared = switch (main.config.show_shared) {
|
'u' => main.config.show_shared = switch (main.config.show_shared) {
|
||||||
.off => .shared,
|
.off => .shared,
|
||||||
|
|
|
||||||
23
src/main.zig
23
src/main.zig
|
|
@ -60,7 +60,8 @@ pub const config = struct {
|
||||||
pub var show_shared: enum { off, shared, unique } = .shared;
|
pub var show_shared: enum { off, shared, unique } = .shared;
|
||||||
pub var show_items: bool = false;
|
pub var show_items: bool = false;
|
||||||
pub var show_mtime: bool = false;
|
pub var show_mtime: bool = false;
|
||||||
pub var show_graph: enum { off, graph, percent, both } = .graph;
|
pub var show_graph: bool = true;
|
||||||
|
pub var show_percent: bool = false;
|
||||||
pub var sort_col: SortCol = .blocks;
|
pub var sort_col: SortCol = .blocks;
|
||||||
pub var sort_order: SortOrder = .desc;
|
pub var sort_order: SortOrder = .desc;
|
||||||
pub var sort_dirsfirst: bool = false;
|
pub var sort_dirsfirst: bool = false;
|
||||||
|
|
@ -294,6 +295,24 @@ pub fn main() void {
|
||||||
else if(opt.is("--disable-delete")) { has_can_delete = true; config.can_delete = false; }
|
else if(opt.is("--disable-delete")) { has_can_delete = true; config.can_delete = false; }
|
||||||
else if(opt.is("--enable-refresh")) { has_can_refresh = true; config.can_refresh = true; }
|
else if(opt.is("--enable-refresh")) { has_can_refresh = true; config.can_refresh = true; }
|
||||||
else if(opt.is("--disable-refresh")) { has_can_refresh = true; config.can_refresh = false; }
|
else if(opt.is("--disable-refresh")) { has_can_refresh = true; config.can_refresh = false; }
|
||||||
|
else if(opt.is("--show-hidden")) config.show_hidden = true
|
||||||
|
else if(opt.is("--hide-hidden")) config.show_hidden = false
|
||||||
|
else if(opt.is("--show-itemcount")) config.show_items = true
|
||||||
|
else if(opt.is("--hide-itemcount")) config.show_items = false
|
||||||
|
else if(opt.is("--show-mtime")) config.show_mtime = true
|
||||||
|
else if(opt.is("--hide-mtime")) config.show_mtime = false
|
||||||
|
else if(opt.is("--show-graph")) config.show_graph = true
|
||||||
|
else if(opt.is("--hide-graph")) config.show_graph = false
|
||||||
|
else if(opt.is("--show-percent")) config.show_percent = true
|
||||||
|
else if(opt.is("--hide-percent")) config.show_percent = false
|
||||||
|
else if(opt.is("--shared-column")) {
|
||||||
|
const val = args.arg();
|
||||||
|
if (std.mem.eql(u8, val, "off")) config.show_shared = .off
|
||||||
|
else if (std.mem.eql(u8, val, "shared")) config.show_shared = .shared
|
||||||
|
else if (std.mem.eql(u8, val, "unique")) config.show_shared = .unique
|
||||||
|
else ui.die("Unknown --shared-column option: {s}.\n", .{val});
|
||||||
|
} else if(opt.is("--apparent-size")) config.show_blocks = false
|
||||||
|
else if(opt.is("--disk-usage")) config.show_blocks = true
|
||||||
else if(opt.is("-0")) { has_scan_ui = true; config.scan_ui = .none; }
|
else if(opt.is("-0")) { has_scan_ui = true; config.scan_ui = .none; }
|
||||||
else if(opt.is("-1")) { has_scan_ui = true; config.scan_ui = .line; }
|
else if(opt.is("-1")) { has_scan_ui = true; config.scan_ui = .line; }
|
||||||
else if(opt.is("-2")) { has_scan_ui = true; config.scan_ui = .full; }
|
else if(opt.is("-2")) { has_scan_ui = true; config.scan_ui = .full; }
|
||||||
|
|
@ -315,6 +334,8 @@ pub fn main() void {
|
||||||
else if(opt.is("--include-kernfs")) config.exclude_kernfs = false
|
else if(opt.is("--include-kernfs")) config.exclude_kernfs = false
|
||||||
else if(opt.is("--confirm-quit")) config.confirm_quit = true
|
else if(opt.is("--confirm-quit")) config.confirm_quit = true
|
||||||
else if(opt.is("--no-confirm-quit")) config.confirm_quit = false
|
else if(opt.is("--no-confirm-quit")) config.confirm_quit = false
|
||||||
|
else if(opt.is("--confirm-delete")) config.confirm_delete = true
|
||||||
|
else if(opt.is("--no-confirm-delete")) config.confirm_delete = false
|
||||||
else if(opt.is("--color")) {
|
else if(opt.is("--color")) {
|
||||||
const val = args.arg();
|
const val = args.arg();
|
||||||
if (std.mem.eql(u8, val, "off")) config.ui_color = .off
|
if (std.mem.eql(u8, val, "off")) config.ui_color = .off
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue