]> Sergey Matveev's repositories - nnn.git/commitdiff
Config NNN_HELP to show output of a program on top of help page
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 12 Jun 2021 19:52:36 +0000 (01:22 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 12 Jun 2021 19:52:36 +0000 (01:22 +0530)
nnn.1
src/nnn.c

diff --git a/nnn.1 b/nnn.1
index d90164967f0f6c8d43534a1d9270d3fec0cc1d61..78968a5aaab9db0ce58cf69088fa2e7b3939acc4 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -6,7 +6,7 @@
 .Nd The unorthodox terminal file manager.
 .Sh SYNOPSIS
 .Nm
-.Op Ar -aAcCdDeEfFgHJKlnQrRSuUVwxh
+.Op Ar -aAcCdDeEfgHJKlnQrRSuUVwxh
 .Op Ar -b key
 .Op Ar -p file
 .Op Ar -P key
@@ -72,9 +72,6 @@ supports the following options:
 .Fl f
         use readline history file
 .Pp
-.Fl F
-        show fortune in help and settings screen
-.Pp
 .Fl g
         use regex filters instead of substring match
 .Pp
@@ -526,6 +523,12 @@ separated by \fI;\fR:
     export NNN_LOCKER='cmatrix'
 .Ed
 .Pp
+\fBNNN_HELP:\fR run a program and show the output on top of the program help page.
+.Bd -literal
+    export NNN_HELP='fortune'
+    export NNN_HELP='pwy paris'
+.Ed
+.Pp
 \fBNNN_MCLICK:\fR key emulated by a middle mouse click.
 .Bd -literal
     export NNN_MCLICK='^R'
index d6ff427bc11862e28d0833d6fc03c93aac0ced2c..fde166cf7c8612a418e9896d2fe1b89d2e58d714 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -324,7 +324,6 @@ typedef struct {
        uint_t rangesel   : 1;  /* Range selection on */
        uint_t move       : 1;  /* Move operation */
        uint_t autonext   : 1;  /* Auto-proceed on open */
-       uint_t fortune    : 1;  /* Show fortune messages in help */
        uint_t trash      : 2;  /* Use trash to delete files 1: trash-cli, 2: gio trash */
        uint_t forcequit  : 1;  /* Do not prompt on quit */
        uint_t autofifo   : 1;  /* Auto-create NNN_FIFO */
@@ -341,7 +340,7 @@ typedef struct {
        uint_t uidgid     : 1;  /* Show owner and group info */
        uint_t prstssn    : 1;  /* Persistent session */
        uint_t duinit     : 1;  /* Initialize disk usage */
-       uint_t reserved   : 7;  /* Adjust when adding/removing a field */
+       uint_t reserved   : 8;  /* Adjust when adding/removing a field */
 } runstate;
 
 /* Contexts or workspaces */
@@ -651,8 +650,9 @@ static const char * const messages[] = {
 #define NNN_PIPE 6
 #define NNN_MCLICK 7
 #define NNN_SEL 8
-#define NNN_ARCHIVE 9 /* strings end here */
-#define NNN_TRASH 10 /* flags begin here */
+#define NNN_ARCHIVE 9
+#define NNN_HELP 10 /* strings end here */
+#define NNN_TRASH 11 /* flags begin here */
 
 static const char * const env_cfg[] = {
        "NNN_OPTS",
@@ -665,6 +665,7 @@ static const char * const env_cfg[] = {
        "NNN_MCLICK",
        "NNN_SEL",
        "NNN_ARCHIVE",
+       "NNN_HELP",
        "NNN_TRASH",
 };
 
@@ -4636,12 +4637,10 @@ static void show_help(const char *path)
                return;
        }
 
-       if (g_state.fortune && getutil("fortune"))
-#ifndef __HAIKU__
-               get_output("fortune", "-s", NULL, fp, FALSE, FALSE);
-#else
-               get_output("fortune", NULL, NULL, fp, FALSE, FALSE);
-#endif
+
+       char *prog = xgetenv(env_cfg[NNN_HELP], NULL);
+       if (prog)
+               get_output(prog, NULL, NULL, fp, TRUE, FALSE);
 
        start = end = helpstr;
        while (*end) {
@@ -7594,7 +7593,6 @@ static void usage(void)
 #ifndef NORL
                " -f      use readline history file\n"
 #endif
-               " -F      show fortune\n"
                " -g      regex filters\n"
                " -H      show hidden files\n"
                " -J      no auto-proceed on select\n"
@@ -7778,7 +7776,7 @@ int main(int argc, char *argv[])
 
        while ((opt = (env_opts_id > 0
                       ? env_opts[--env_opts_id]
-                      : getopt(argc, argv, "aAb:cCdDeEfFgHJKl:nop:P:QrRs:St:T:uUVwxh"))) != -1) {
+                      : getopt(argc, argv, "aAb:cCdDeEfgHJKl:nop:P:QrRs:St:T:uUVwxh"))) != -1) {
                switch (opt) {
 #ifndef NOFIFO
                case 'a':
@@ -7815,9 +7813,6 @@ int main(int argc, char *argv[])
                        rlhist = TRUE;
 #endif
                        break;
-               case 'F':
-                       g_state.fortune = 1;
-                       break;
                case 'g':
                        cfg.regex = 1;
                        filterfn = &visible_re;