]> Sergey Matveev's repositories - nnn.git/commitdiff
Support archiving files in selection
authorArun Prakash Jana <engineerarun@gmail.com>
Thu, 31 Jan 2019 01:29:57 +0000 (06:59 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Thu, 31 Jan 2019 01:57:08 +0000 (07:27 +0530)
README.md
nnn.1
src/nnn.c

index a8451a7aaebc80e240169a96883ded5e528f21a0..527f10ba4a57295c46a49ce4a068247a7d239e66 100644 (file)
--- a/README.md
+++ b/README.md
@@ -236,7 +236,7 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
             Y  Select all
             P  Copy selection     X  Delete selection
             V  Move selection    ^X  Delete entry
-            f  Archive entry      F  List archive
+            f  Archive files      F  List archive
            ^F  Extract archive  m M  Brief/full media info
             e  Edit in EDITOR     p  Open in PAGER
  ORDER TOGGLES
diff --git a/nnn.1 b/nnn.1
index 8f239296e236535d64ec342648274c8746b8cd89..f7db4d2422d079169ecd4bbe910a65d5af6eec06 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -113,7 +113,7 @@ Delete files from selection
 .It Ic ^X
 Delete entry
 .It Ic f
-Archive entry
+Archive files
 .It Ic F
 List files in archive
 .It Ic ^F
index c6b26c0aeb5d507d93593ff1914bdf9138116e85..9e6c7ac75f06d9d50b90fa03655eaabe13eee5f1 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2300,7 +2300,7 @@ static bool show_help(char *path)
              "cY  Select all\n"
              "cP  Copy selection     X  Delete selection\n"
              "cV  Move selection    ^X  Delete entry\n"
-             "cf  Archive entry      F  List archive\n"
+             "cf  Archive files      F  List archive\n"
             "b^F  Extract archive  m M  Brief/full media info\n"
              "ce  Edit in EDITOR     p  Open in PAGER\n"
 "1ORDER TOGGLES\n"
@@ -3512,7 +3512,7 @@ nochange:
                {
                        switch (sel) {
                        case SEL_ARCHIVE:
-                               tmp = xreadline(dents[cur].name, "name: ");
+                               tmp = xreadline(NULL, "archive name: ");
                                break;
                        case SEL_OPENWITH:
                                tmp = xreadline(NULL, "open with: ");
@@ -3545,10 +3545,24 @@ nochange:
                                /* newpath is used as temporary buffer */
                                if (!getutil(utils[APACK])) {
                                        printmsg("utility missing");
-                                       continue;
+                                       goto nochange;
                                }
 
-                               spawn(utils[APACK], tmp, dents[cur].name, path, F_NORMAL);
+                               r = get_input("archive selection (else current)? [s]");
+                               if (r == 's') {
+                                       if (!cpsafe())
+                                               goto nochange;
+
+                                       snprintf(g_buf, CMD_LEN_MAX,
+#ifdef __linux__
+                                                "xargs -0 -a %s %s %s",
+#else
+                                                "cat %s | xargs -0 -o %s %s",
+#endif
+                                                g_cppath, utils[APACK], tmp);
+                                       spawn("sh", "-c", g_buf, path, F_NORMAL | F_SIGINT);
+                               } else
+                                       spawn(utils[APACK], tmp, dents[cur].name, path, F_NORMAL);
                                break;
                        case SEL_OPENWITH:
                                dir = NULL;