mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Keybind v for version sort
This commit is contained in:
parent
d13fea6fa2
commit
e3e6e1671a
|
@ -28,7 +28,7 @@ complete -c nnn -s R -d 'disable rollover at edges'
|
||||||
complete -c nnn -s s -r -d 'load session by name' -x -a '@\t"last session" (ls $sessions_dir)'
|
complete -c nnn -s s -r -d 'load session by name' -x -a '@\t"last session" (ls $sessions_dir)'
|
||||||
complete -c nnn -s S -d 'start in disk usage analyzer mode'
|
complete -c nnn -s S -d 'start in disk usage analyzer mode'
|
||||||
complete -c nnn -s t -d 'disable dir auto-select'
|
complete -c nnn -s t -d 'disable dir auto-select'
|
||||||
complete -c nnn -s v -d 'show program version and exit'
|
complete -c nnn -s v -d 'use version compare to sort files'
|
||||||
complete -c nnn -s V -d 'use version compare to sort files'
|
complete -c nnn -s V -d 'show program version and exit'
|
||||||
complete -c nnn -s x -d 'notis, sel to system clipboard'
|
complete -c nnn -s x -d 'notis, sel to system clipboard'
|
||||||
complete -c nnn -s h -d 'show program help'
|
complete -c nnn -s h -d 'show program help'
|
||||||
|
|
|
@ -26,8 +26,8 @@ args=(
|
||||||
'(-s)-s[load session]:session name'
|
'(-s)-s[load session]:session name'
|
||||||
'(-S)-S[start in disk usage analyzer mode]'
|
'(-S)-S[start in disk usage analyzer mode]'
|
||||||
'(-t)-t[disable dir auto-select]'
|
'(-t)-t[disable dir auto-select]'
|
||||||
'(-v)-v[show program version and exit]'
|
'(-v)-v[use version compare to sort files]'
|
||||||
'(-V)-V[use version compare to sort files]'
|
'(-V)-V[show program version and exit]'
|
||||||
'(-x)-x[notis, sel to system clipboard]'
|
'(-x)-x[notis, sel to system clipboard]'
|
||||||
'(-h)-h[show program help]'
|
'(-h)-h[show program help]'
|
||||||
'*:filename:_files'
|
'*:filename:_files'
|
||||||
|
|
4
nnn.1
4
nnn.1
|
@ -96,10 +96,10 @@ supports the following options:
|
||||||
disable directory auto-select in navigate-as-you-type mode
|
disable directory auto-select in navigate-as-you-type mode
|
||||||
.Pp
|
.Pp
|
||||||
.Fl v
|
.Fl v
|
||||||
show version and exit
|
use case-insensitive version compare to sort files
|
||||||
.Pp
|
.Pp
|
||||||
.Fl V
|
.Fl V
|
||||||
use case-insensitive version compare to sort files
|
show version and exit
|
||||||
.Pp
|
.Pp
|
||||||
.Fl x
|
.Fl x
|
||||||
show notis on selection cp, mv, rm completion; copy path to system clipboard on select
|
show notis on selection cp, mv, rm completion; copy path to system clipboard on select
|
||||||
|
|
31
src/nnn.c
31
src/nnn.c
|
@ -3517,8 +3517,8 @@ static void show_help(const char *path)
|
||||||
"1FILES\n"
|
"1FILES\n"
|
||||||
"b^O Open with...%-12cn Create new/link\n"
|
"b^O Open with...%-12cn Create new/link\n"
|
||||||
"cD File details%-12cd Detail view toggle\n"
|
"cD File details%-12cd Detail view toggle\n"
|
||||||
"ca Sel all%-13c^R F2 Rename/duplicate\n"
|
"cr Batch rename%-8c^R F2 Rename/duplicate\n"
|
||||||
"5Space ^J Sel toggle%-14cr Batch rename\n"
|
"5Space ^J Sel toggle%-14ca Sel all\n"
|
||||||
"9m ^K Sel range, clear%-8cM List sel\n"
|
"9m ^K Sel range, clear%-8cM List sel\n"
|
||||||
"cP Copy sel here%-11cK Edit sel\n"
|
"cP Copy sel here%-11cK Edit sel\n"
|
||||||
"cV Move sel here%-11cw Copy/move sel as\n"
|
"cV Move sel here%-11cw Copy/move sel as\n"
|
||||||
|
@ -3526,9 +3526,9 @@ static void show_help(const char *path)
|
||||||
"cf Archive%-14co ^F Archive ops\n"
|
"cf Archive%-14co ^F Archive ops\n"
|
||||||
"ce Edit in EDITOR%-10cp Open in PAGER\n"
|
"ce Edit in EDITOR%-10cp Open in PAGER\n"
|
||||||
"1ORDER TOGGLES\n"
|
"1ORDER TOGGLES\n"
|
||||||
"cA Apparent du%-13cS du\n"
|
"cS Disk usage%-14cA Apparent du\n"
|
||||||
"cz Size%-20ct Time\n"
|
"cz Size%-20ct Time\n"
|
||||||
"cE Extension%-1c\n"
|
"cv version%-17cE Extension\n"
|
||||||
"1MISC\n"
|
"1MISC\n"
|
||||||
"9! ^] Shell%-17c; x Plugin key\n"
|
"9! ^] Shell%-17c; x Plugin key\n"
|
||||||
"cC Execute file%-9ci ^V Pick plugin\n"
|
"cC Execute file%-9ci ^V Pick plugin\n"
|
||||||
|
@ -4237,7 +4237,7 @@ static void redraw(char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ndents) {
|
if (ndents) {
|
||||||
char sort[] = "\0 ";
|
char sort[] = "\0 \0";
|
||||||
pEntry pent = &dents[cur];
|
pEntry pent = &dents[cur];
|
||||||
|
|
||||||
if (cfg.mtimeorder)
|
if (cfg.mtimeorder)
|
||||||
|
@ -4247,6 +4247,9 @@ static void redraw(char *path)
|
||||||
else if (cfg.extnorder)
|
else if (cfg.extnorder)
|
||||||
sort[0] = 'E';
|
sort[0] = 'E';
|
||||||
|
|
||||||
|
if (cmpfn == &xstrverscasecmp)
|
||||||
|
sort[0] ? (sort[1] = 'V', sort[2] = ' ') : (sort[0] = 'V');
|
||||||
|
|
||||||
/* Get the file extension for regular files */
|
/* Get the file extension for regular files */
|
||||||
if (S_ISREG(pent->mode)) {
|
if (S_ISREG(pent->mode)) {
|
||||||
i = (int)strlen(pent->name);
|
i = (int)strlen(pent->name);
|
||||||
|
@ -4782,7 +4785,8 @@ nochange:
|
||||||
case SEL_ASIZE: // fallthrough
|
case SEL_ASIZE: // fallthrough
|
||||||
case SEL_BSIZE: // fallthrough
|
case SEL_BSIZE: // fallthrough
|
||||||
case SEL_EXTN: // fallthrough
|
case SEL_EXTN: // fallthrough
|
||||||
case SEL_MTIME:
|
case SEL_MTIME: // fallthrough
|
||||||
|
case SEL_VERSION:
|
||||||
switch (sel) {
|
switch (sel) {
|
||||||
case SEL_MFLTR:
|
case SEL_MFLTR:
|
||||||
cfg.filtermode ^= 1;
|
cfg.filtermode ^= 1;
|
||||||
|
@ -4844,13 +4848,16 @@ nochange:
|
||||||
cfg.apparentsz = 0;
|
cfg.apparentsz = 0;
|
||||||
cfg.blkorder = 0;
|
cfg.blkorder = 0;
|
||||||
break;
|
break;
|
||||||
default: /* SEL_MTIME */
|
case SEL_MTIME:
|
||||||
cfg.mtimeorder ^= 1;
|
cfg.mtimeorder ^= 1;
|
||||||
cfg.sizeorder = 0;
|
cfg.sizeorder = 0;
|
||||||
cfg.apparentsz = 0;
|
cfg.apparentsz = 0;
|
||||||
cfg.blkorder = 0;
|
cfg.blkorder = 0;
|
||||||
cfg.extnorder = 0;
|
cfg.extnorder = 0;
|
||||||
break;
|
break;
|
||||||
|
default: /* SEL_VERSION */
|
||||||
|
cmpfn = (cmpfn == &xstrverscasecmp) ? &xstricmp : &xstrverscasecmp;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearfilter();
|
clearfilter();
|
||||||
|
@ -5540,8 +5547,8 @@ static void usage(void)
|
||||||
" -s name load session by name\n"
|
" -s name load session by name\n"
|
||||||
" -S du mode\n"
|
" -S du mode\n"
|
||||||
" -t no dir auto-select\n"
|
" -t no dir auto-select\n"
|
||||||
" -v show version\n"
|
" -v version sort\n"
|
||||||
" -V version sort\n"
|
" -V show version\n"
|
||||||
" -x notis, sel to system clipboard\n"
|
" -x notis, sel to system clipboard\n"
|
||||||
" -h show help\n\n"
|
" -h show help\n\n"
|
||||||
"v%s\n%s\n", __func__, VERSION, GENERAL_INFO);
|
"v%s\n%s\n", __func__, VERSION, GENERAL_INFO);
|
||||||
|
@ -5758,11 +5765,11 @@ int main(int argc, char *argv[])
|
||||||
check_key_collision();
|
check_key_collision();
|
||||||
return _SUCCESS;
|
return _SUCCESS;
|
||||||
case 'v':
|
case 'v':
|
||||||
fprintf(stdout, "%s\n", VERSION);
|
|
||||||
return _SUCCESS;
|
|
||||||
case 'V':
|
|
||||||
cmpfn = &xstrverscasecmp;
|
cmpfn = &xstrverscasecmp;
|
||||||
break;
|
break;
|
||||||
|
case 'V':
|
||||||
|
fprintf(stdout, "%s\n", VERSION);
|
||||||
|
return _SUCCESS;
|
||||||
case 'x':
|
case 'x':
|
||||||
cfg.x11 = 1;
|
cfg.x11 = 1;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -72,6 +72,7 @@ enum action {
|
||||||
SEL_BSIZE, /* block size */
|
SEL_BSIZE, /* block size */
|
||||||
SEL_EXTN, /* order by extension */
|
SEL_EXTN, /* order by extension */
|
||||||
SEL_MTIME,
|
SEL_MTIME,
|
||||||
|
SEL_VERSION,
|
||||||
SEL_REDRAW,
|
SEL_REDRAW,
|
||||||
SEL_SEL,
|
SEL_SEL,
|
||||||
SEL_SELMUL,
|
SEL_SELMUL,
|
||||||
|
@ -194,6 +195,8 @@ static struct key bindings[] = {
|
||||||
{ 'E', SEL_EXTN },
|
{ 'E', SEL_EXTN },
|
||||||
/* Toggle sort by time */
|
/* Toggle sort by time */
|
||||||
{ 't', SEL_MTIME },
|
{ 't', SEL_MTIME },
|
||||||
|
/* Toggle version sort */
|
||||||
|
{ 'v', SEL_VERSION },
|
||||||
/* Redraw window */
|
/* Redraw window */
|
||||||
{ CONTROL('L'), SEL_REDRAW },
|
{ CONTROL('L'), SEL_REDRAW },
|
||||||
{ KEY_F(5), SEL_REDRAW },
|
{ KEY_F(5), SEL_REDRAW },
|
||||||
|
|
Loading…
Reference in a new issue