mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
List from selection file if nothing selected
This commit is contained in:
parent
7bcf19189a
commit
69efec865a
4
nnn.1
4
nnn.1
|
@ -176,11 +176,11 @@ There are 3 groups of keybinds to add files to selection:
|
||||||
.br
|
.br
|
||||||
(3) add all files in the current directory to selection
|
(3) add all files in the current directory to selection
|
||||||
.Pp
|
.Pp
|
||||||
A selection can be listed, edited, copied, moved, removed, archived or linked.
|
A selection can be edited, copied, moved, removed, archived or linked.
|
||||||
.Pp
|
.Pp
|
||||||
Absolute paths of the selected files are copied to \fB.selection\fR file in the config directory.
|
Absolute paths of the selected files are copied to \fB.selection\fR file in the config directory.
|
||||||
.Pp
|
.Pp
|
||||||
To edit the selection use the _edit selection_ key. Use this key to remove a file from selection after you navigate away from its directory. Editing doesn't end the selection mode. You can add more files to the selection and edit the list again.
|
To edit the selection use the _edit selection_ key. Use this key to remove a file from selection after you navigate away from its directory. Editing doesn't end the 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 to list the selection file.
|
||||||
.Sh FILE SIZE
|
.Sh FILE SIZE
|
||||||
The minimum file size unit is byte (B). The rest are K, M, G, T, P, E, Z, Y (powers of 1024), same as the default units in \fIls\fR.
|
The minimum file size unit is byte (B). The rest are K, M, G, T, P, E, Z, Y (powers of 1024), same as the default units in \fIls\fR.
|
||||||
.Sh ENVIRONMENT
|
.Sh ENVIRONMENT
|
||||||
|
|
19
src/nnn.c
19
src/nnn.c
|
@ -474,6 +474,7 @@ static char * const utils[] = {
|
||||||
#define MSG_BOOKMARK_KEYS 36
|
#define MSG_BOOKMARK_KEYS 36
|
||||||
#define MSG_INVALID_REG 37
|
#define MSG_INVALID_REG 37
|
||||||
#define MSG_ORDER 38
|
#define MSG_ORDER 38
|
||||||
|
#define MSG_LIST_SEL 39
|
||||||
|
|
||||||
static const char * const messages[] = {
|
static const char * const messages[] = {
|
||||||
"no traversal",
|
"no traversal",
|
||||||
|
@ -515,6 +516,7 @@ static const char * const messages[] = {
|
||||||
"bookmark keys:",
|
"bookmark keys:",
|
||||||
"invalid regex",
|
"invalid regex",
|
||||||
"toggle 'a'u / 'd'u / 'e'xtn / 'r'everse / 's'ize / 't'ime / 'v'ersion?",
|
"toggle 'a'u / 'd'u / 'e'xtn / 'r'everse / 's'ize / 't'ime / 'v'ersion?",
|
||||||
|
"0 selected, list selection file?"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Supported configuration environment variables */
|
/* Supported configuration environment variables */
|
||||||
|
@ -1019,6 +1021,7 @@ static bool listselbuf()
|
||||||
selbufpos = oldpos;
|
selbufpos = oldpos;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* List selection from selection file (another instance) */
|
/* List selection from selection file (another instance) */
|
||||||
static bool listselfile(void)
|
static bool listselfile(void)
|
||||||
|
@ -1037,7 +1040,6 @@ static bool listselfile(void)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Reset selection indicators */
|
/* Reset selection indicators */
|
||||||
static void resetselind(void)
|
static void resetselind(void)
|
||||||
|
@ -1099,11 +1101,14 @@ static int editselection(void)
|
||||||
int fd, lines = 0;
|
int fd, lines = 0;
|
||||||
ssize_t count;
|
ssize_t count;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct timespec mtime;
|
time_t mtime;
|
||||||
|
|
||||||
if (!selbufpos) {
|
if (!selbufpos) {
|
||||||
DPRINTF_S("empty selection");
|
fd = get_input(messages[MSG_LIST_SEL]);
|
||||||
return 0;
|
if ((fd == 'y' || fd == 'Y') && !listselfile())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = create_tmp_file();
|
fd = create_tmp_file();
|
||||||
|
@ -1121,7 +1126,7 @@ static int editselection(void)
|
||||||
unlink(g_tmpfpath);
|
unlink(g_tmpfpath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mtime = sb.st_mtim;
|
mtime = sb.st_mtime;
|
||||||
|
|
||||||
spawn((cfg.waitedit ? enveditor : editor), g_tmpfpath, NULL, NULL, F_CLI);
|
spawn((cfg.waitedit ? enveditor : editor), g_tmpfpath, NULL, NULL, F_CLI);
|
||||||
|
|
||||||
|
@ -1134,7 +1139,7 @@ static int editselection(void)
|
||||||
|
|
||||||
fstat(fd, &sb);
|
fstat(fd, &sb);
|
||||||
|
|
||||||
if (mtime.tv_sec == sb.st_mtim.tv_sec) {
|
if (mtime == sb.st_mtime) {
|
||||||
DPRINTF_S("selection is not modified");
|
DPRINTF_S("selection is not modified");
|
||||||
unlink(g_tmpfpath);
|
unlink(g_tmpfpath);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -3627,7 +3632,7 @@ static void show_help(const char *path)
|
||||||
"cP Copy sel here%-11ca Select all\n"
|
"cP Copy sel here%-11ca Select all\n"
|
||||||
"cV Move sel here%-10c^V Copy/move sel as\n"
|
"cV Move sel here%-10c^V Copy/move sel as\n"
|
||||||
"cX Delete sel%-13c^X Delete entry\n"
|
"cX Delete sel%-13c^X Delete entry\n"
|
||||||
"9o ^T Order toggle%-11c^Y Edit sel\n"
|
"9o ^T Order toggle%-11c^W Edit sel\n"
|
||||||
"1MISC\n"
|
"1MISC\n"
|
||||||
"9; ^P Plugin%-18c= Launch app\n"
|
"9; ^P Plugin%-18c= Launch app\n"
|
||||||
"9! ^] Shell%-19c] Cmd prompt\n"
|
"9! ^] Shell%-19c] Cmd prompt\n"
|
||||||
|
|
|
@ -189,7 +189,7 @@ static struct key bindings[] = {
|
||||||
/* Select all files in current dir */
|
/* Select all files in current dir */
|
||||||
{ 'a', SEL_SELALL },
|
{ 'a', SEL_SELALL },
|
||||||
/* List, edit selection */
|
/* List, edit selection */
|
||||||
{ CONTROL('Y'), SEL_SELEDIT },
|
{ CONTROL('W'), SEL_SELEDIT },
|
||||||
/* Copy from selection buffer */
|
/* Copy from selection buffer */
|
||||||
{ 'P', SEL_CP },
|
{ 'P', SEL_CP },
|
||||||
/* Move from selection buffer */
|
/* Move from selection buffer */
|
||||||
|
|
Loading…
Reference in a new issue