]> Sergey Matveev's repositories - nnn.git/commitdiff
Option -B to use bsdtar as archive tool
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 29 Jul 2022 17:05:43 +0000 (22:35 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 29 Jul 2022 17:05:43 +0000 (22:35 +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 bd9382ad63573a02b3c48adaf56e8a5eb379f181..e89e7dd0c116e45eb925ced567832d38ef613faf 100644 (file)
@@ -15,6 +15,7 @@ _nnn ()
         -a
         -A
         -b
+        -B
         -c
         -C
         -d
index c3dc6e79bfcd3a1621ca03a3810d6616e7bdce51..d195088eee4bbb4d9c87328e13a76ce63a59eaef 100644 (file)
@@ -14,6 +14,7 @@ end
 complete -c nnn -s a    -d 'auto-create NNN_FIFO'
 complete -c nnn -s A    -d 'disable dir auto-enter'
 complete -c nnn -s b -r -d 'bookmark key to open' -x -a '(echo $NNN_BMS | awk -F: -v RS=\; \'{print $1"\t"$2}\')'
+complete -c nnn -s B    -d 'use bsdtar for archives'
 complete -c nnn -s c    -d 'cli-only opener'
 complete -c nnn -s C    -d 'color by context'
 complete -c nnn -s d    -d 'start in detail mode'
index 293fd4fb16c5061f16a5ed1a13a718157e852cb6..55eadab1cc6d50b0fb7c9d98030e8256a5edad7b 100644 (file)
@@ -12,6 +12,7 @@ args=(
     '(-a)-a[auto-create NNN_FIFO]'
     '(-A)-A[disable dir auto-enter]'
     '(-b)-b[bookmark key to open]:key char'
+    '(-B)-B[use bsdtar for archives]'
     '(-c)-c[cli-only opener]'
     '(-C)-C[color by context]'
     '(-d)-d[start in detail mode]'
diff --git a/nnn.1 b/nnn.1
index f8f4962b651b6607feea17bc386a547e66d7383e..1e998241880b64c5132ee0dd74550d04fd21d3ea 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -53,6 +53,9 @@ supports the following options:
 .Fl "b key"
         specify bookmark key to open
 .Pp
+.Fl B
+        use bsdtar for archives (default: atool)
+.Pp
 .Fl c
         indicates that the opener is a cli-only opener (overrides -e)
 .Pp
index 54e99408b07a8b4e7026d15a3356bebb97a16a6a..b10143a403d06e9e4c037f83f47d54702736c0e4 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -373,7 +373,8 @@ typedef struct {
        uint_t stayonsel  : 1;  /* Disable auto-advance on selection */
        uint_t trash      : 2;  /* Trash method 0: rm -rf, 1: trash-cli, 2: gio trash */
        uint_t uidgid     : 1;  /* Show owner and group info */
-       uint_t reserved   : 6;  /* Adjust when adding/removing a field */
+       uint_t usebsdtar  : 1;  /* Use bsdtar as default archive utility */
+       uint_t reserved   : 5;  /* Adjust when adding/removing a field */
 } runstate;
 
 /* Contexts or workspaces */
@@ -2670,7 +2671,7 @@ static void get_archive_cmd(char *cmd, const char *archive)
 {
        uchar_t i = 3;
 
-       if (getutil(utils[UTIL_ATOOL]))
+       if (!g_state.usebsdtar && getutil(utils[UTIL_ATOOL]))
                i = 0;
        else if (getutil(utils[UTIL_BSDTAR]))
                i = 1;
@@ -4573,7 +4574,7 @@ static bool handle_archive(char *fpath /* in-out param */, char op)
        char arg[] = "-tvf"; /* options for tar/bsdtar to list files */
        char *util, *outdir = NULL;
        bool x_to = FALSE;
-       bool is_atool = getutil(utils[UTIL_ATOOL]);
+       bool is_atool = (!g_state.usebsdtar && getutil(utils[UTIL_ATOOL]));
 
        if (op == 'x') {
                outdir = xreadline(is_atool ? "." : xbasename(fpath), messages[MSG_NEW_PATH]);
@@ -8095,6 +8096,7 @@ static void usage(void)
 #endif
                " -A      no dir auto-enter during filter\n"
                " -b key  open bookmark key (trumps -s/S)\n"
+               " -B      use bsdtar for archives\n"
                " -c      cli-only NNN_OPENER (trumps -e)\n"
                " -C      8-color scheme\n"
                " -d      detail mode\n"
@@ -8290,7 +8292,7 @@ int main(int argc, char *argv[])
 
        while ((opt = (env_opts_id > 0
                       ? env_opts[--env_opts_id]
-                      : getopt(argc, argv, "aAb:cCdDeEfF:gHiJKl:nop:P:QrRs:St:T:uUVxh"))) != -1) {
+                      : getopt(argc, argv, "aAb:BcCdDeEfF:gHiJKl:nop:P:QrRs:St:T:uUVxh"))) != -1) {
                switch (opt) {
 #ifndef NOFIFO
                case 'a':
@@ -8304,6 +8306,9 @@ int main(int argc, char *argv[])
                        if (env_opts_id < 0)
                                arg = optarg;
                        break;
+               case 'B':
+                       g_state.usebsdtar = 1;
+                       break;
                case 'c':
                        cfg.cliopener = 1;
                        break;