Option -B to use bsdtar as archive tool

This commit is contained in:
Arun Prakash Jana 2022-07-29 22:35:43 +05:30
parent 49a0d9d02c
commit e73b57c78a
No known key found for this signature in database
GPG Key ID: A75979F35C080412
5 changed files with 15 additions and 4 deletions

View File

@ -15,6 +15,7 @@ _nnn ()
-a
-A
-b
-B
-c
-C
-d

View 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'

View 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]'

3
nnn.1
View File

@ -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

View File

@ -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;