1
1

Backport a bunch of CLI options from 2.x + sync manpage changes

Этот коммит содержится в:
Yorhel 2022-11-05 16:43:30 +01:00
родитель 9670ca66ed
Коммит b45f8e4c06
7 изменённых файлов: 170 добавлений и 64 удалений

Просмотреть файл

@ -72,6 +72,62 @@ using 'm' and 'M', respectively.
=back
=head2 Scan Options
These options affect the scanning progress, and have no effect when importing
directory information from a file.
=over
=item B<-x>, B<--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 B<--cross-file-system>
Do cross filesystem boundaries. This is the default, but can be specified to
overrule a previously given C<-x>.
=item B<--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 B<-X> I<FILE>, B<--exclude-from> I<FILE>
Exclude files that match any pattern in I<FILE>. Patterns should be separated
by a newline.
=item B<--include-caches>, B<--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 B<-L>, B<--follow-symlinks>, B<--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 B<--exclude-firmlinks>, B<--follow-firmlinks>
(MacOS only) Exclude or follow firmlinks.
=item B<--include-kernfs>, B<--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
=over
@ -130,11 +186,61 @@ 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
prefixes, that is, powers of 1024 (KiB, MiB, etc).
=item B<--disk-usage>, B<--apparent-size>
Select whether to display disk usage (default) or apparent sizes. Can also be
toggled in the browser with the 'a' key.
=item B<--show-hidden>, B<--hide-hidden>
Show (default) or hide "hidden" and excluded files. Can also be toggled in the
browser with the 'e' key.
=item B<--show-itemcount>, B<--hide-itemcount>
Show or hide (default) the item counts column. Can also be toggled in the
browser with the 'c' key.
=item B<--show-mtime>, B<--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 B<--show-graph>, B<--hide-graph>
Show (default) or hide the relative size bar column. Can also be toggled in the
browser with the 'g' key.
=item B<--show-percent>, B<--hide-percent>
Show (default) or hide the relative size percent column. Can also be toggled in
the browser with the 'g' key.
=item B<--sort> I<COLUMN>
Change the default column to sort on. Accepted values are I<disk-usage> (the
default), I<name>, I<apparent-size>, I<itemcount> or I<mtime>. The latter only
makes sense in extended mode, see C<-e>.
The column can be suffixed with I<-asc> or I<-desc> to set the order to
ascending or descending, respectively. e.g. C<--sort=name-desc> will sort by
name in descending order.
=item B<--group-directories-first>, B<--no-group-directories-first>
Sort (or not) directories before files.
=item B<--confirm-quit>, B<--no-confirm-quit>
Require a confirmation before quitting ncdu. Very helpful when you accidentally
press 'q' during or after a very long scan.
=item B<--confirm-delete>, B<--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 B<--color> I<SCHEME>
Select a color scheme. The following schemes are recognized: I<off> to disable
@ -146,62 +252,6 @@ The default is I<dark-bg> unless the C<NO_COLOR> environment variable is set.
=back
=head2 Scan Options
These options affect the scanning progress, and have no effect when importing
directory information from a file.
=over
=item B<-x>, B<--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 B<--cross-file-system>
Do cross filesystem boundaries. This is the default, but can be specified to
overrule a previously given C<-x>.
=item B<--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 B<-X> I<FILE>, B<--exclude-from> I<FILE>
Exclude files that match any pattern in I<FILE>. Patterns should be separated
by a newline.
=item B<--include-caches>, B<--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 B<-L>, B<--follow-symlinks>, B<--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 B<--exclude-firmlinks>, B<--follow-firmlinks>
(MacOS only) Exclude or follow firmlinks.
=item B<--include-kernfs>, B<--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
@ -219,7 +269,7 @@ Cycle through the items
Open selected directory
=item B<left>, B<<>, B<h>
=item B<left>, B<< < >>, B<h>
Go to parent directory
@ -326,7 +376,7 @@ An error occurred while reading this directory.
An error occurred while reading a subdirectory, so the indicated size may not be
correct.
=item B<<>
=item B<< < >>
File or directory is excluded from the statistics by using exclude patterns.

Просмотреть файл

@ -31,7 +31,7 @@
#include <time.h>
static int graph = 1, show_as = 0, info_show = 0, info_page = 0, info_start = 0, show_items = 0, show_mtime = 0;
static int info_show = 0, info_page = 0, info_start = 0;
static const char *message = NULL;

Просмотреть файл

@ -35,9 +35,10 @@
#define DS_PROGRESS 1
#define DS_FAILED 2
int delete_confirm = 1;
static struct dir *root, *nextsel, *curdir;
static char noconfirm = 0, ignoreerr = 0, state;
static char ignoreerr = 0, state;
static signed char seloption;
static int lasterrno;
@ -126,7 +127,7 @@ int delete_key(int ch) {
if(seloption == 1)
return 1;
if(seloption == 2)
noconfirm++;
delete_confirm = 0;
state = DS_PROGRESS;
break;
case 'q':
@ -216,7 +217,7 @@ void delete_process(void) {
/* confirm */
seloption = 1;
while(state == DS_CONFIRM && !noconfirm)
while(state == DS_CONFIRM && delete_confirm)
if(input_handle(0)) {
browse_init(root->parent);
return;

Просмотреть файл

@ -28,6 +28,8 @@
#include "global.h"
extern int delete_confirm;
void delete_process(void);
int delete_key(int);
void delete_draw(void);

Просмотреть файл

@ -109,6 +109,16 @@ extern int extended_info;
extern int follow_symlinks;
/* flag whether we want to follow firmlinks */
extern int follow_firmlinks;
/* display SI units */
extern int si;
/* show apparent sizes */
extern int show_as;
/* graph display setting */
extern int graph;
/* column visibility */
extern int show_items;
extern int show_mtime;
/* handle input from keyboard and update display */
int input_handle(int);

Просмотреть файл

@ -42,6 +42,11 @@ int extended_info = 0;
int follow_symlinks = 0;
int follow_firmlinks = 1;
int confirm_quit = 0;
int si = 0;
int show_as = 0;
int graph = 1;
int show_items = 0;
int show_mtime = 0;
static int min_rows = 17, min_cols = 60;
static int ncurses_init = 0;
@ -185,7 +190,7 @@ static char *argparser_arg(struct argparser *p) {
#define ARG (argparser_arg(&argparser_state))
static int arg_option(void) {
char *arg;
char *arg, *tmp;
if(OPT("-q") || OPT("--slow-ui-updates")) update_delay = 2000;
else if(OPT("--fast-ui-updates")) update_delay = 100;
else if(OPT("-x") || OPT("--one-file-system")) dir_scan_smfs = 1;
@ -193,6 +198,43 @@ static int arg_option(void) {
else if(OPT("-e") || OPT("--extended")) extended_info = 1;
else if(OPT("--no-extended")) extended_info = 0;
else if(OPT("-r")) read_only++;
else if(OPT("--show-hidden")) dirlist_hidden = 0;
else if(OPT("--hide-hidden")) dirlist_hidden = 1;
else if(OPT("--show-itemcount")) show_items = 1;
else if(OPT("--hide-itemcount")) show_items = 0;
else if(OPT("--show-mtime")) show_mtime = 1;
else if(OPT("--hide-mtime")) show_mtime = 0;
else if(OPT("--show-graph")) graph |= 1;
else if(OPT("--hide-graph")) graph &= 2;
else if(OPT("--show-percent")) graph |= 2;
else if(OPT("--hide-percent")) graph &= 1;
else if(OPT("--group-directories-first")) dirlist_sort_df = 1;
else if(OPT("--no-group-directories-first")) dirlist_sort_df = 0;
else if(OPT("--sort")) {
arg = ARG;
tmp = strrchr(arg, '-');
if(tmp && (strcmp(tmp, "-asc") == 0 || strcmp(tmp, "-desc") == 0)) *tmp = 0;
if(strcmp(arg, "name") == 0) {
dirlist_sort_col = DL_COL_NAME;
dirlist_sort_desc = 0;
} else if(strcmp(arg, "disk-usage") == 0) {
dirlist_sort_col = DL_COL_SIZE;
dirlist_sort_desc = 1;
} else if(strcmp(arg, "apparent-size") == 0) {
dirlist_sort_col = DL_COL_ASIZE;
dirlist_sort_desc = 1;
} else if(strcmp(arg, "itemcount") == 0) {
dirlist_sort_col = DL_COL_ITEMS;
dirlist_sort_desc = 1;
} else if(strcmp(arg, "mtime") == 0) {
dirlist_sort_col = DL_COL_MTIME;
dirlist_sort_desc = 0;
} else die("Invalid argument to --sort: '%s'.\n", arg);
if(tmp && !*tmp) dirlist_sort_desc = tmp[1] == 'd';
} else if(OPT("--apparent-size")) show_as = 1;
else if(OPT("--disk-usage")) show_as = 0;
else if(OPT("-0")) dir_ui = 0;
else if(OPT("-1")) dir_ui = 1;
else if(OPT("-2")) dir_ui = 2;
@ -212,6 +254,8 @@ static int arg_option(void) {
else if(OPT("--exclude-firmlinks")) follow_firmlinks = 0;
else if(OPT("--confirm-quit")) confirm_quit = 1;
else if(OPT("--no-confirm-quit")) confirm_quit = 0;
else if(OPT("--confirm-delete")) delete_confirm = 1;
else if(OPT("--no-confirm-delete")) delete_confirm = 0;
else if(OPT("--color")) {
arg = ARG;
if(strcmp(arg, "off") == 0) uic_theme = 0;

Просмотреть файл

@ -37,7 +37,6 @@
int uic_theme;
int winrows, wincols;
int subwinr, subwinc;
int si;
static char thou_sep;