mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Option -a to use file access time
This commit is contained in:
parent
3f40980dd0
commit
ec873ab4fa
|
@ -74,7 +74,7 @@ Visit the **[Wiki](https://github.com/jarun/nnn/wiki)** for operational concepts
|
|||
- Sorting
|
||||
- Ordered pure numeric names by default (visit _/proc_)
|
||||
- Case-insensitive version (_aka_ natural) sort
|
||||
- Sort by file name, modification time, size, file extension
|
||||
- By file name, modification/access time, size, extension
|
||||
- Search
|
||||
- Instant filtering with *search-as-you-type*
|
||||
- Regex and substring match
|
||||
|
@ -202,8 +202,8 @@ Option completion scripts for Bash, Fish and Zsh can be found in respective subd
|
|||
#### Cmdline options
|
||||
|
||||
```
|
||||
usage: nnn [-b key] [-d] [-H] [-i] [-n] [-o] [-p file]
|
||||
[-r] [-s] [-S] [-t] [-v] [-h] [PATH]
|
||||
usage: nnn [-a] [-b key] [-d] [-H] [-i] [-n] [-o]
|
||||
[-p file] [-r] [-s] [-S] [-t] [-v] [-h] [PATH]
|
||||
|
||||
The missing terminal file manager for X.
|
||||
|
||||
|
@ -211,6 +211,7 @@ positional args:
|
|||
PATH start dir [default: current dir]
|
||||
|
||||
optional args:
|
||||
-a use access time
|
||||
-b key open bookmark key
|
||||
-d detail mode
|
||||
-H show hidden files
|
||||
|
|
|
@ -11,6 +11,7 @@ _nnn () {
|
|||
local cur=$2 prev=$3
|
||||
local -a opts
|
||||
opts=(
|
||||
-a
|
||||
-b
|
||||
-d
|
||||
-H
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# Arun Prakash Jana <engineerarun@gmail.com>
|
||||
#
|
||||
|
||||
complete -c nnn -s a -d 'use access time'
|
||||
complete -c nnn -s b -r -d 'bookmark key to open'
|
||||
complete -c nnn -s d -d 'start in detail mode'
|
||||
complete -c nnn -s H -d 'show hidden files'
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
setopt localoptions noshwordsplit noksharrays
|
||||
local -a args
|
||||
args=(
|
||||
'(-a)-a[use access time]'
|
||||
'(-b)-b[bookmark key to open]:key char'
|
||||
'(-d)-d[start in detail mode]'
|
||||
'(-H)-H[show hidden files]'
|
||||
|
|
4
nnn.1
4
nnn.1
|
@ -6,6 +6,7 @@
|
|||
.Nd the missing terminal file manager for X
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Ar -a
|
||||
.Op Ar -b key
|
||||
.Op Ar -d
|
||||
.Op Ar -H
|
||||
|
@ -36,6 +37,9 @@ to see the list of keybinds.
|
|||
.Nm
|
||||
supports the following options:
|
||||
.Pp
|
||||
.Fl a
|
||||
use access time for all operations (default: modification time)
|
||||
.Pp
|
||||
.Fl "b key"
|
||||
specify bookmark key to open
|
||||
.Pp
|
||||
|
|
18
src/nnn.c
18
src/nnn.c
|
@ -215,7 +215,7 @@ typedef struct {
|
|||
uint copymode : 1; /* Set when copying files */
|
||||
uint showdetail : 1; /* Clear to show fewer file info */
|
||||
uint ctxactive : 1; /* Context active or not */
|
||||
uint reserved : 8;
|
||||
uint reserved : 7;
|
||||
/* The following settings are global */
|
||||
uint curctx : 2; /* Current context number */
|
||||
uint dircolor : 1; /* Current status of dir color */
|
||||
|
@ -229,6 +229,7 @@ typedef struct {
|
|||
uint runctx : 2; /* The context in which plugin is to be run */
|
||||
uint filter_re : 1; /* Use regex filters */
|
||||
uint trash : 1; /* Move removed files to trash */
|
||||
uint mtime : 1; /* Use modification time (else access time) */
|
||||
} settings;
|
||||
|
||||
/* Contexts or workspaces */
|
||||
|
@ -268,6 +269,7 @@ static settings cfg = {
|
|||
0, /* runctx */
|
||||
1, /* filter_re */
|
||||
0, /* trash */
|
||||
1, /* mtime */
|
||||
};
|
||||
|
||||
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
|
||||
|
@ -3056,7 +3058,7 @@ static int dentfill(char *path, struct entry **dents)
|
|||
off += dentp->nlen;
|
||||
|
||||
/* Copy other fields */
|
||||
dentp->t = sb.st_mtime;
|
||||
dentp->t = cfg.mtime ? sb.st_mtime : sb.st_atime;
|
||||
if (dp->d_type == DT_LNK && !flags) { /* Do not add sizes for links */
|
||||
dentp->mode = (sb.st_mode & ~S_IFMT) | S_IFLNK;
|
||||
dentp->size = 0;
|
||||
|
@ -3283,7 +3285,7 @@ static void redraw(char *path)
|
|||
char sort[] = "\0 ";
|
||||
|
||||
if (cfg.mtimeorder)
|
||||
sort[0] = 'T';
|
||||
sort[0] = cfg.mtime ? 'T' : 'A';
|
||||
else if (cfg.sizeorder)
|
||||
sort[0] = 'S';
|
||||
else if (cfg.extnorder)
|
||||
|
@ -4536,12 +4538,13 @@ nochange:
|
|||
static void usage(void)
|
||||
{
|
||||
fprintf(stdout,
|
||||
"%s: nnn [-b key] [-d] [-H] [-i] [-n] [-o] [-p file]\n"
|
||||
" [-r] [-s] [-S] [-t] [-v] [-h] [PATH]\n\n"
|
||||
"%s: nnn [-a] [-b key] [-d] [-H] [-i] [-n] [-o]\n"
|
||||
" [-p file] [-r] [-s] [-S] [-t] [-v] [-h] [PATH]\n\n"
|
||||
"The missing terminal file manager for X.\n\n"
|
||||
"positional args:\n"
|
||||
" PATH start dir [default: current dir]\n\n"
|
||||
"optional args:\n"
|
||||
" -a use access time\n"
|
||||
" -b key open bookmark key\n"
|
||||
" -d detail mode\n"
|
||||
" -H show hidden files\n"
|
||||
|
@ -4688,7 +4691,7 @@ int main(int argc, char *argv[])
|
|||
bool progress = FALSE;
|
||||
#endif
|
||||
|
||||
while ((opt = getopt(argc, argv, "HSib:dnop:rstvh")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "HSiab:dnop:rstvh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'S':
|
||||
cfg.blkorder = 1;
|
||||
|
@ -4701,6 +4704,9 @@ int main(int argc, char *argv[])
|
|||
case 'i':
|
||||
cfg.filtermode = 1;
|
||||
break;
|
||||
case 'a':
|
||||
cfg.mtime = 0;
|
||||
break;
|
||||
case 'b':
|
||||
arg = optarg;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue