mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Resurrect default sort
This commit is contained in:
parent
1388b9ea71
commit
aa840a7f65
|
@ -79,6 +79,7 @@ Demo videos: i. [`nnn` on Termux (Android)](https://www.youtube.com/watch?v=Abaa
|
||||||
- Bookmarks; pin and visit a directory
|
- Bookmarks; pin and visit a directory
|
||||||
- Familiar, easy shortcuts (arrows, <kbd>~</kbd>, <kbd>-</kbd>, <kbd>@</kbd>)
|
- Familiar, easy shortcuts (arrows, <kbd>~</kbd>, <kbd>-</kbd>, <kbd>@</kbd>)
|
||||||
- Sorting
|
- Sorting
|
||||||
|
- Ordered pure numeric names by default (visit _/proc_)
|
||||||
- Case-insensitive version (_aka_ natural) sort
|
- Case-insensitive version (_aka_ natural) sort
|
||||||
- Sort by file name, modification time, size
|
- Sort by file name, modification time, size
|
||||||
- Search
|
- Search
|
||||||
|
@ -198,8 +199,8 @@ Option completion scripts for Bash, Fish and Zsh can be found in respective subd
|
||||||
#### Cmdline options
|
#### Cmdline options
|
||||||
|
|
||||||
```
|
```
|
||||||
usage: nnn [-b key] [-d] [-e] [-i] [-l] [-p file]
|
usage: nnn [-b key] [-d] [-e] [-i] [-l] [-n]
|
||||||
[-s] [-S] [-v] [-w] [-h] [PATH]
|
[-p file] [-s] [-S] [-v] [-w] [-h] [PATH]
|
||||||
|
|
||||||
The missing terminal file manager for X.
|
The missing terminal file manager for X.
|
||||||
|
|
||||||
|
@ -212,6 +213,7 @@ optional args:
|
||||||
-e use exiftool for media info
|
-e use exiftool for media info
|
||||||
-i nav-as-you-type mode
|
-i nav-as-you-type mode
|
||||||
-l light mode
|
-l light mode
|
||||||
|
-n version sort
|
||||||
-p file selection file (stdout if '-')
|
-p file selection file (stdout if '-')
|
||||||
-s string filters [default: regex]
|
-s string filters [default: regex]
|
||||||
-S du mode
|
-S du mode
|
||||||
|
|
|
@ -17,6 +17,7 @@ _nnn () {
|
||||||
-h
|
-h
|
||||||
-i
|
-i
|
||||||
-l
|
-l
|
||||||
|
-n
|
||||||
-p
|
-p
|
||||||
-s
|
-s
|
||||||
-S
|
-S
|
||||||
|
|
|
@ -11,6 +11,7 @@ complete -c nnn -s e -d 'use exiftool instead of mediainfo'
|
||||||
complete -c nnn -s h -d 'show this help and exit'
|
complete -c nnn -s h -d 'show this help and exit'
|
||||||
complete -c nnn -s i -d 'start in navigate-as-you-type mode'
|
complete -c nnn -s i -d 'start in navigate-as-you-type mode'
|
||||||
complete -c nnn -s l -d 'start in light mode (fewer details)'
|
complete -c nnn -s l -d 'start in light mode (fewer details)'
|
||||||
|
complete -c nnn -s n -d 'use version compare to sort files'
|
||||||
complete -c nnn -s p -r -d 'copy selection to file'
|
complete -c nnn -s p -r -d 'copy selection to file'
|
||||||
complete -c nnn -s s -d 'use substring match for filters'
|
complete -c nnn -s s -d 'use substring match for filters'
|
||||||
complete -c nnn -s S -d 'start in disk usage analyzer mode'
|
complete -c nnn -s S -d 'start in disk usage analyzer mode'
|
||||||
|
|
|
@ -15,6 +15,7 @@ args=(
|
||||||
'(-h)-h[show this help and exit]'
|
'(-h)-h[show this help and exit]'
|
||||||
'(-i)-i[start in navigate-as-you-type mode]'
|
'(-i)-i[start in navigate-as-you-type mode]'
|
||||||
'(-l)-l[start in light mode (fewer details)]'
|
'(-l)-l[start in light mode (fewer details)]'
|
||||||
|
'(-n)-n[use version compare to sort files]'
|
||||||
'(-p)-p[copy selection to file]:file name'
|
'(-p)-p[copy selection to file]:file name'
|
||||||
'(-s)-s[use substring match for filters]'
|
'(-s)-s[use substring match for filters]'
|
||||||
'(-S)-S[start in disk usage analyzer mode]'
|
'(-S)-S[start in disk usage analyzer mode]'
|
||||||
|
|
4
nnn.1
4
nnn.1
|
@ -11,6 +11,7 @@
|
||||||
.Op Ar -e
|
.Op Ar -e
|
||||||
.Op Ar -i
|
.Op Ar -i
|
||||||
.Op Ar -l
|
.Op Ar -l
|
||||||
|
.Op Ar -n
|
||||||
.Op Ar -p file
|
.Op Ar -p file
|
||||||
.Op Ar -s
|
.Op Ar -s
|
||||||
.Op Ar -S
|
.Op Ar -S
|
||||||
|
@ -51,6 +52,9 @@ supports the following options:
|
||||||
.Fl l
|
.Fl l
|
||||||
start in light mode (fewer details)
|
start in light mode (fewer details)
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl n
|
||||||
|
use case-insensitive version compare to sort files
|
||||||
|
.Pp
|
||||||
.Fl "p file"
|
.Fl "p file"
|
||||||
copy (or \fIpick\fR) selection to file, or stdout if file='-'
|
copy (or \fIpick\fR) selection to file, or stdout if file='-'
|
||||||
.Pp
|
.Pp
|
||||||
|
|
16
src/nnn.c
16
src/nnn.c
|
@ -1274,7 +1274,6 @@ static bool write_lastdir(const char *curpath)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static int digit_compare(const char *a, const char *b)
|
static int digit_compare(const char *a, const char *b)
|
||||||
{
|
{
|
||||||
while (*a && *b && *a == *b)
|
while (*a && *b && *a == *b)
|
||||||
|
@ -1362,7 +1361,6 @@ static int xstricmp(const char * const s1, const char * const s2)
|
||||||
|
|
||||||
return strcoll(s1, s2);
|
return strcoll(s1, s2);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Version comparison
|
* Version comparison
|
||||||
|
@ -1445,6 +1443,8 @@ static int xstrverscasecmp(const char * const s1, const char * const s2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int (*cmpfn)(const char * const s1, const char * const s2) = &xstricmp;
|
||||||
|
|
||||||
/* Return the integer value of a char representing HEX */
|
/* Return the integer value of a char representing HEX */
|
||||||
static char xchartohex(char c)
|
static char xchartohex(char c)
|
||||||
{
|
{
|
||||||
|
@ -1509,7 +1509,7 @@ static int entrycmp(const void *va, const void *vb)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xstrverscasecmp(pa->name, pb->name);
|
return cmpfn(pa->name, pb->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4401,8 +4401,8 @@ nochange:
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
"%s: nnn [-b key] [-d] [-e] [-i] [-l] [-p file]\n"
|
"%s: nnn [-b key] [-d] [-e] [-i] [-l] [-n]\n"
|
||||||
" [-s] [-S] [-v] [-w] [-h] [PATH]\n\n"
|
" [-p file] [-s] [-S] [-v] [-w] [-h] [PATH]\n\n"
|
||||||
"The missing terminal file manager for X.\n\n"
|
"The missing terminal file manager for X.\n\n"
|
||||||
"positional args:\n"
|
"positional args:\n"
|
||||||
" PATH start dir [default: current dir]\n\n"
|
" PATH start dir [default: current dir]\n\n"
|
||||||
|
@ -4412,6 +4412,7 @@ static void usage(void)
|
||||||
" -e use exiftool for media info\n"
|
" -e use exiftool for media info\n"
|
||||||
" -i nav-as-you-type mode\n"
|
" -i nav-as-you-type mode\n"
|
||||||
" -l light mode\n"
|
" -l light mode\n"
|
||||||
|
" -n version sort\n"
|
||||||
" -p file selection file (stdout if '-')\n"
|
" -p file selection file (stdout if '-')\n"
|
||||||
" -s string filters [default: regex]\n"
|
" -s string filters [default: regex]\n"
|
||||||
" -S du mode\n"
|
" -S du mode\n"
|
||||||
|
@ -4545,7 +4546,7 @@ int main(int argc, char *argv[])
|
||||||
char *arg = NULL;
|
char *arg = NULL;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "Slib:dep:svwh")) != -1) {
|
while ((opt = getopt(argc, argv, "Slib:denp:svwh")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'S':
|
case 'S':
|
||||||
cfg.blkorder = 1;
|
cfg.blkorder = 1;
|
||||||
|
@ -4568,6 +4569,9 @@ int main(int argc, char *argv[])
|
||||||
case 'e':
|
case 'e':
|
||||||
cfg.metaviewer = EXIFTOOL;
|
cfg.metaviewer = EXIFTOOL;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
cmpfn = &xstrverscasecmp;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
cfg.picker = 1;
|
cfg.picker = 1;
|
||||||
if (optarg[0] == '-' && optarg[1] == '\0')
|
if (optarg[0] == '-' && optarg[1] == '\0')
|
||||||
|
|
Loading…
Reference in a new issue