mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Add 't' command to sort output by entry's mtime
This commit is contained in:
parent
6735c1f979
commit
a63aac0b11
|
@ -47,4 +47,5 @@ struct key bindings[] = {
|
||||||
{ '!', SEL_SH },
|
{ '!', SEL_SH },
|
||||||
/* Change dir */
|
/* Change dir */
|
||||||
{ 'c', SEL_CD },
|
{ 'c', SEL_CD },
|
||||||
|
{ 't', SEL_MTIME },
|
||||||
};
|
};
|
||||||
|
|
2
noice.1
2
noice.1
|
@ -47,6 +47,8 @@ Change filter (see below for more information).
|
||||||
Enter filter-as-you-type mode.
|
Enter filter-as-you-type mode.
|
||||||
.It Ic c
|
.It Ic c
|
||||||
Change into the given directory.
|
Change into the given directory.
|
||||||
|
.It Ic t
|
||||||
|
Sort by time modified.
|
||||||
.It Ic !
|
.It Ic !
|
||||||
Spawn shell in current directory.
|
Spawn shell in current directory.
|
||||||
.It Ic q
|
.It Ic q
|
||||||
|
|
10
noice.c
10
noice.c
|
@ -56,6 +56,7 @@ enum action {
|
||||||
SEL_PGUP,
|
SEL_PGUP,
|
||||||
SEL_SH,
|
SEL_SH,
|
||||||
SEL_CD,
|
SEL_CD,
|
||||||
|
SEL_MTIME,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct key {
|
struct key {
|
||||||
|
@ -68,8 +69,11 @@ struct key {
|
||||||
struct entry {
|
struct entry {
|
||||||
char *name;
|
char *name;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
|
time_t t;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int mtimeorder;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Layout:
|
* Layout:
|
||||||
* .---------
|
* .---------
|
||||||
|
@ -231,6 +235,8 @@ entrycmp(const void *va, const void *vb)
|
||||||
a = (struct entry *)va;
|
a = (struct entry *)va;
|
||||||
b = (struct entry *)vb;
|
b = (struct entry *)vb;
|
||||||
|
|
||||||
|
if (mtimeorder)
|
||||||
|
return b->t - a->t;
|
||||||
return strcmp(a->name, b->name);
|
return strcmp(a->name, b->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,6 +493,7 @@ dentfill(char *path, struct entry **dents,
|
||||||
if (r == -1)
|
if (r == -1)
|
||||||
printerr(1, "lstat");
|
printerr(1, "lstat");
|
||||||
(*dents)[n].mode = sb.st_mode;
|
(*dents)[n].mode = sb.st_mode;
|
||||||
|
(*dents)[n].t = sb.st_mtime;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,6 +816,9 @@ moretyping:
|
||||||
filter = xstrdup(ifilter); /* Reset filter */
|
filter = xstrdup(ifilter); /* Reset filter */
|
||||||
DPRINTF_S(path);
|
DPRINTF_S(path);
|
||||||
goto out;
|
goto out;
|
||||||
|
case SEL_MTIME:
|
||||||
|
mtimeorder = !mtimeorder;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue