mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 21:36:42 +00:00
Show total size of non-filtered selected files in a directory.
This commit is contained in:
parent
4f95796ede
commit
33827109d5
5
nnn.1
5
nnn.1
|
@ -317,6 +317,11 @@ To edit the selection use the _edit selection_ key. Editing doesn't end the
|
||||||
selection mode. You can add more files to the selection and edit the list
|
selection mode. You can add more files to the selection and edit the list
|
||||||
again. If no file is selected in the current session, this option attempts
|
again. If no file is selected in the current session, this option attempts
|
||||||
to list the selection file.
|
to list the selection file.
|
||||||
|
.Pp
|
||||||
|
.Nm
|
||||||
|
can show the total size of non-filtered selected files listed in a
|
||||||
|
directory. For directories, only the size of the directory is added by
|
||||||
|
default. To add the size of the contents of a directory, switch to du mode.
|
||||||
.Sh FIND AND LIST
|
.Sh FIND AND LIST
|
||||||
There are two ways to search and list:
|
There are two ways to search and list:
|
||||||
.Pp
|
.Pp
|
||||||
|
|
19
src/nnn.c
19
src/nnn.c
|
@ -5076,7 +5076,8 @@ static void show_help(const char *path)
|
||||||
"ca Select all%-14cA Invert sel\n"
|
"ca Select all%-14cA Invert sel\n"
|
||||||
"9p ^P Copy here%-12cw ^W Cp/mv sel as\n"
|
"9p ^P Copy here%-12cw ^W Cp/mv sel as\n"
|
||||||
"9v ^V Move here%-15cE Edit sel list\n"
|
"9v ^V Move here%-15cE Edit sel list\n"
|
||||||
"9x ^X Delete%-16cEsc Send to FIFO\n"
|
"9x ^X Delete%-18cS Listed sel size\n"
|
||||||
|
"aEsc Send to FIFO\n"
|
||||||
"0\n"
|
"0\n"
|
||||||
"1MISC\n"
|
"1MISC\n"
|
||||||
"8Alt ; Select plugin%-11c= Launch app\n"
|
"8Alt ; Select plugin%-11c= Launch app\n"
|
||||||
|
@ -6633,6 +6634,19 @@ static bool cdprep(char *lastdir, char *lastname, char *path, char *newpath)
|
||||||
return cfg.filtermode;
|
return cfg.filtermode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void showselsize(const char *path)
|
||||||
|
{
|
||||||
|
off_t sz = 0;
|
||||||
|
int len = scanselforpath(path, FALSE);
|
||||||
|
|
||||||
|
for (int r = 0; r < ndents; ++r)
|
||||||
|
if (findinsel(findselpos,
|
||||||
|
len + xstrsncpy(g_sel + len, pdents[r].name, pdents[r].nlen)))
|
||||||
|
sz += cfg.blkorder ? pdents[r].blocks : pdents[r].size;
|
||||||
|
|
||||||
|
printmsg(coolsize(cfg.blkorder ? sz << blk_shift : sz));
|
||||||
|
}
|
||||||
|
|
||||||
static bool browse(char *ipath, const char *session, int pkey)
|
static bool browse(char *ipath, const char *session, int pkey)
|
||||||
{
|
{
|
||||||
alignas(max_align_t) char newpath[PATH_MAX];
|
alignas(max_align_t) char newpath[PATH_MAX];
|
||||||
|
@ -7843,6 +7857,9 @@ nochange:
|
||||||
if (g_state.runplugin == 1) /* Allow filtering in plugins directory */
|
if (g_state.runplugin == 1) /* Allow filtering in plugins directory */
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
goto begin;
|
goto begin;
|
||||||
|
case SEL_SELSIZE:
|
||||||
|
showselsize(path);
|
||||||
|
goto nochange;
|
||||||
case SEL_SHELL: // fallthrough
|
case SEL_SHELL: // fallthrough
|
||||||
case SEL_LAUNCH: // fallthrough
|
case SEL_LAUNCH: // fallthrough
|
||||||
case SEL_PROMPT:
|
case SEL_PROMPT:
|
||||||
|
|
|
@ -105,6 +105,7 @@ enum action {
|
||||||
SEL_AUTONEXT,
|
SEL_AUTONEXT,
|
||||||
SEL_EDIT,
|
SEL_EDIT,
|
||||||
SEL_PLUGIN,
|
SEL_PLUGIN,
|
||||||
|
SEL_SELSIZE,
|
||||||
SEL_SHELL,
|
SEL_SHELL,
|
||||||
SEL_LAUNCH,
|
SEL_LAUNCH,
|
||||||
SEL_PROMPT,
|
SEL_PROMPT,
|
||||||
|
@ -257,6 +258,8 @@ static struct key bindings[] = {
|
||||||
{ 'e', SEL_EDIT },
|
{ 'e', SEL_EDIT },
|
||||||
/* Run a plugin */
|
/* Run a plugin */
|
||||||
{ ';', SEL_PLUGIN },
|
{ ';', SEL_PLUGIN },
|
||||||
|
/* Show total size of listed selection */
|
||||||
|
{ 'S', SEL_SELSIZE },
|
||||||
/* Run command */
|
/* Run command */
|
||||||
{ '!', SEL_SHELL },
|
{ '!', SEL_SHELL },
|
||||||
{ CONTROL(']'), SEL_SHELL },
|
{ CONTROL(']'), SEL_SHELL },
|
||||||
|
|
Loading…
Reference in a new issue