]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix #402
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 14 Dec 2019 17:58:13 +0000 (23:28 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 14 Dec 2019 17:58:13 +0000 (23:28 +0530)
misc/auto-completion/bash/nnn-completion.bash
misc/auto-completion/fish/nnn.fish
misc/auto-completion/zsh/_nnn
nnn.1
src/nnn.c

index e9061c7bea841589a8225a1ae881cd74870ade05..11b8ef26fcd557b2b3a119115ae53ecc06505dcf 100644 (file)
@@ -25,6 +25,7 @@ _nnn ()
         -n
         -o
         -p
+        -Q
         -r
         -R
         -S
index e459aa3d1788585b3d86f67ccc8bc84eb71afb0b..0c10f93ca47bb854be8ec21bf4e14e6e0b113634 100644 (file)
@@ -24,6 +24,7 @@ complete -c nnn -s K    -d 'detect key collision'
 complete -c nnn -s n    -d 'use version compare to sort files'
 complete -c nnn -s o    -d 'open files only on Enter'
 complete -c nnn -s p -r -d 'copy selection to file' -a '-\tstdout'
+complete -c nnn -s Q    -d 'disable quit confirmation'
 complete -c nnn -s r    -d 'show cp, mv progress (Linux-only)'
 complete -c nnn -s R    -d 'disable rollover at edges'
 complete -c nnn -s S    -d 'start in disk usage analyzer mode'
index 777894f5cdca329a252c8357c3736640f9be9f7b..6e94a0eed91568533aa12a04f3e7484d3f25d130 100644 (file)
@@ -22,6 +22,7 @@ args=(
     '(-n)-n[use version compare to sort files]'
     '(-o)-o[open files only on Enter]'
     '(-p)-p[copy selection to file]:file name'
+    '(-Q)-Q[disable quit confirmation]'
     '(-r)-r[show cp, mv progress (Linux-only)]'
     '(-R)-R[disable rollover at edges]'
     '(-S)-S[start in disk usage analyzer mode]'
diff --git a/nnn.1 b/nnn.1
index fcb8f2d8cce8aa60345f2c0ffe4fbb8268cff88a..89daf5d35847e08298535665c2361d153cb240d5 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -18,6 +18,7 @@
 .Op Ar -K
 .Op Ar -n
 .Op Ar -p file
+.Op Ar -Q
 .Op Ar -r
 .Op Ar -R
 .Op Ar -S
@@ -82,6 +83,9 @@ supports the following options:
 .Fl "p file"
         copy (or \fIpick\fR) selection to file, or stdout if file='-'
 .Pp
+.Fl Q
+        disable confirmation when quitting program with multiple active contexts
+.Pp
 .Fl r
         show cp, mv progress (Linux-only, needs advcpmv; '^T' shows the progress on BSD/macOS)
 .Pp
index 883ee9d84bb4e9871a94a11746ef6176aacec8f9..a9fb120e4e0ac88a6bf943073cfc93f3988d38d0 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -227,8 +227,9 @@ typedef struct {
        uint selmode    : 1;  /* Set when selecting files */
        uint showdetail : 1;  /* Clear to show fewer file info */
        uint ctxactive  : 1;  /* Context active or not */
-       uint reserved   : 3;
+       uint reserved   : 2;
        /* The following settings are global */
+       uint forcequit  : 1;  /* Do not confirm when quitting program */
        uint curctx     : 2;  /* Current context number */
        uint dircolor   : 1;  /* Current status of dir color */
        uint picker     : 1;  /* Write selection to user-specified file */
@@ -281,6 +282,7 @@ static settings cfg = {
        0, /* showdetail */
        1, /* ctxactive */
        0, /* reserved */
+       0, /* forcequit */
        0, /* curctx */
        0, /* dircolor */
        0, /* picker */
@@ -5348,7 +5350,7 @@ nochange:
                                        setdirwatch();
                                        goto begin;
                                }
-                       } else {
+                       } else if (!cfg.forcequit) {
                                for (r = 0; r < CTX_MAX; ++r)
                                        if (r != cfg.curctx && g_ctx[r].c_cfg.ctxactive) {
                                                r = get_input(messages[MSG_QUIT_ALL]);
@@ -5430,10 +5432,11 @@ static void usage(void)
                " -n      version sort\n"
                " -o      open files on Enter\n"
                " -p file selection file [stdout if '-']\n"
+               " -Q      no quit confirmation\n"
                " -r      use advcpmv patched cp, mv\n"
-               " -R      disable rollover at edges\n"
+               " -R      no rollover at edges\n"
                " -S      du mode\n"
-               " -t      disable dir auto-select\n"
+               " -t      no dir auto-select\n"
                " -v      show version\n"
                " -x      notis, sel to system clipboard\n"
                " -h      show help\n\n"
@@ -5578,7 +5581,7 @@ int main(int argc, char *argv[])
        bool progress = FALSE;
 #endif
 
-       while ((opt = getopt(argc, argv, "HSKiab:cde:Egnop:rRtvxh")) != -1) {
+       while ((opt = getopt(argc, argv, "HSKiab:cde:Egnop:QrRtvxh")) != -1) {
                switch (opt) {
                case 'S':
                        cfg.blkorder = 1;
@@ -5636,6 +5639,9 @@ int main(int argc, char *argv[])
                                unlink(g_selpath);
                        }
                        break;
+               case 'Q':
+                       cfg.forcequit = 1;
+                       break;
                case 'r':
 #ifdef __linux__
                        progress = TRUE;