diff options
author | Yorhel <git@yorhel.nl> | 2022-11-05 16:43:30 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2022-11-05 16:43:57 +0100 |
commit | b45f8e4c0634ef04b075b559f0025a21bfc8545f (patch) | |
tree | d1767ff1ed0068277aa2b54090dbd39adf30e901 | |
parent | 9670ca66ed8fb2635b7349796486e3c331611456 (diff) |
Backport a bunch of CLI options from 2.x + sync manpage changes
-rw-r--r-- | doc/ncdu.pod | 146 | ||||
-rw-r--r-- | src/browser.c | 2 | ||||
-rw-r--r-- | src/delete.c | 7 | ||||
-rw-r--r-- | src/delete.h | 2 | ||||
-rw-r--r-- | src/global.h | 10 | ||||
-rw-r--r-- | src/main.c | 46 | ||||
-rw-r--r-- | src/util.c | 1 |
7 files changed, 160 insertions, 54 deletions
diff --git a/doc/ncdu.pod b/doc/ncdu.pod index 15736ae..f0c28bd 100644 --- a/doc/ncdu.pod +++ b/doc/ncdu.pod @@ -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,75 +186,69 @@ 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<--confirm-quit>, B<--no-confirm-quit> +=item B<--disk-usage>, B<--apparent-size> -Require a confirmation before quitting ncdu. Very helpful when you accidentally -press 'q' during or after a very long scan. +Select whether to display disk usage (default) or apparent sizes. Can also be +toggled in the browser with the 'a' key. -=item B<--color> I<SCHEME> +=item B<--show-hidden>, B<--hide-hidden> -Select a color scheme. The following schemes are recognized: I<off> to disable -colors, I<dark> for a color scheme intended for dark backgrounds and I<dark-bg> -for a variation of the I<dark> color scheme that also works in terminals with a -light background. +Show (default) or hide "hidden" and excluded files. Can also be toggled in the +browser with the 'e' key. -The default is I<dark-bg> unless the C<NO_COLOR> environment variable is set. +=item B<--show-itemcount>, B<--hide-itemcount> -=back +Show or hide (default) the item counts column. Can also be toggled in the +browser with the 'c' key. -=head2 Scan Options +=item B<--show-mtime>, B<--hide-mtime> -These options affect the scanning progress, and have no effect when importing -directory information from a file. +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>). -=over +=item B<--show-graph>, B<--hide-graph> -=item B<-x>, B<--one-file-system> +Show (default) or hide the relative size bar column. Can also be toggled in the +browser with the 'g' key. -Do not cross filesystem boundaries, i.e. only count files and directories on -the same filesystem as the directory being scanned. +=item B<--show-percent>, B<--hide-percent> -=item B<--cross-file-system> +Show (default) or hide the relative size percent column. Can also be toggled in +the browser with the 'g' key. -Do cross filesystem boundaries. This is the default, but can be specified to -overrule a previously given C<-x>. +=item B<--sort> I<COLUMN> -=item B<--exclude> I<PATTERN> +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>. -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. +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<-X> I<FILE>, B<--exclude-from> I<FILE> +=item B<--group-directories-first>, B<--no-group-directories-first> -Exclude files that match any pattern in I<FILE>. Patterns should be separated -by a newline. +Sort (or not) directories before files. -=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<--confirm-quit>, B<--no-confirm-quit> -=item B<-L>, B<--follow-symlinks>, B<--no-follow-symlinks> +Require a confirmation before quitting ncdu. Very helpful when you accidentally +press 'q' during or after a very long scan. -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<--confirm-delete>, B<--no-confirm-delete> -=item B<--exclude-firmlinks>, B<--follow-firmlinks> +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'. -(MacOS only) Exclude or follow firmlinks. - -=item B<--include-kernfs>, B<--exclude-kernfs> +=item B<--color> I<SCHEME> -(Linux only) Include (default) or exclude Linux pseudo filesystems, e.g. /proc -(procfs), /sys (sysfs). +Select a color scheme. The following schemes are recognized: I<off> to disable +colors, I<dark> for a color scheme intended for dark backgrounds and I<dark-bg> +for a variation of the I<dark> color scheme that also works in terminals with a +light background. -The complete list of currently known pseudo filesystems is: binfmt, bpf, cgroup, -cgroup2, debug, devpts, proc, pstore, security, selinux, sys, trace. +The default is I<dark-bg> unless the C<NO_COLOR> environment variable is set. =back @@ -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. diff --git a/src/browser.c b/src/browser.c index 141d916..91d7757 100644 --- a/src/browser.c +++ b/src/browser.c @@ -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; diff --git a/src/delete.c b/src/delete.c index 859bb54..8fe1dc8 100644 --- a/src/delete.c +++ b/src/delete.c @@ -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; diff --git a/src/delete.h b/src/delete.h index 311a881..527dd9d 100644 --- a/src/delete.h +++ b/src/delete.h @@ -28,6 +28,8 @@ #include "global.h" +extern int delete_confirm; + void delete_process(void); int delete_key(int); void delete_draw(void); diff --git a/src/global.h b/src/global.h index 74e468d..573e685 100644 --- a/src/global.h +++ b/src/global.h @@ -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; |