aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--src/nnn.c16
-rw-r--r--src/nnn.h4
3 files changed, 16 insertions, 5 deletions
diff --git a/README.md b/README.md
index a2cc923..a7072ce 100644
--- a/README.md
+++ b/README.md
@@ -37,6 +37,7 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/embed/AbaauM7gUJw)
<details><summary><i><b>Expand</b></i> for some nnn magic! :dark_sunglasses:</summary><br><ul>
<li>Instantly load, sort, filter thousands of files</li>
<li>Type to navigate with automatic dir selection</li>
+ <li>List input stream and pick entries to stdout or file</li>
<li>find/fd/grep/ripgrep/fzf from nnn and list in nnn</li>
<li> Never lose context - start where you quit</li>
<li>Mount any cloud storage service in a few keypresses</li>
diff --git a/src/nnn.c b/src/nnn.c
index 78c9546..466acaf 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4602,6 +4602,7 @@ static void show_help(const char *path)
"aEsc Send to FIFO%-11c^L Redraw\n"
"c? Help, conf%-13c^G QuitCD\n"
"cq Quit context%-6c^Q 2Esc Quit\n"
+ "cQ Pick sel/err & quit\n"
"1FILTER & PROMPT\n"
"c/ Filter%-12cAlt+Esc Clear filter & redraw\n"
"aEsc Exit prompt%-12c^L Clear prompt/last filter\n"
@@ -7036,7 +7037,7 @@ nochange:
case SEL_QUITCTX: // fallthrough
case SEL_QUITCD: // fallthrough
case SEL_QUIT:
- case SEL_QUITFAIL:
+ case SEL_QUITERR:
if (sel == SEL_QUITCTX) {
int ctx = cfg.curctx;
for (r = (ctx + 1) & ~CTX_MAX;
@@ -7086,7 +7087,16 @@ nochange:
if (g_state.picker)
selbufpos = 0;
}
- return sel == SEL_QUITFAIL ? EXIT_FAILURE : EXIT_SUCCESS;
+
+ if (sel != SEL_QUITERR)
+ return EXIT_SUCCESS;
+
+ if (selbufpos && !g_state.picker) {
+ g_state.pickraw = 1;
+ return EXIT_SUCCESS;
+ }
+
+ return EXIT_FAILURE;
default:
if (xlines != LINES || xcols != COLS)
continue;
@@ -7926,7 +7936,7 @@ int main(int argc, char *argv[])
if (g_state.pickraw || g_state.picker) {
if (selbufpos) {
- fd = g_state.pickraw ? 1 : open(selpath, O_WRONLY | O_CREAT, 0600);
+ fd = g_state.pickraw ? STDOUT_FILENO : open(selpath, O_WRONLY | O_CREAT, 0600);
if ((fd == -1) || (seltofile(fd, NULL) != (size_t)(selbufpos)))
xerror();
diff --git a/src/nnn.h b/src/nnn.h
index 55ceacf..222d1a9 100644
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -111,7 +111,7 @@ enum action {
SEL_QUITCTX,
SEL_QUITCD,
SEL_QUIT,
- SEL_QUITFAIL,
+ SEL_QUITERR,
#ifndef NOMOUSE
SEL_CLICK,
#endif
@@ -270,7 +270,7 @@ static struct key bindings[] = {
/* Quit */
{ CONTROL('Q'), SEL_QUIT },
/* Quit with an error code */
- { 'Q', SEL_QUITFAIL },
+ { 'Q', SEL_QUITERR },
#ifndef NOMOUSE
{ KEY_MOUSE, SEL_CLICK },
#endif