diff --git a/README.md b/README.md index 22e28bc4..55e910db 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Have fun with it! Missing a feature? Want to contribute? Head to the rolling [To - Desktop search (gnome-search-tool, catfish) integration - Mimes - Open with desktop opener (default) or specify a custom app - - List and extract archives (needs atool) + - Create, list and extract archives (needs atool) - Optionally open text files in EDITOR (fallback vi) - Customizable bash script [nlay](https://github.com/jarun/nnn/wiki/all-about-nlay) to handle actions - Information @@ -237,6 +237,7 @@ optional arguments: e | Edit entry in EDITOR o | Open DE filemanager p | Open entry in PAGER + f | Archive entry F | List archive ^F | Extract archive ^K | Copy file path @@ -291,7 +292,7 @@ The following abbreviations are used in the detail view: | xdg-open (Linux), open(1) (OS X) | desktop opener | | mediainfo, exiftool | multimedia file details | | gnome-search-tool, catfish | desktop search utility | -| atool | list and extract archives | +| atool | create, list and extract archives | | vidir from moreutils | batch rename, move, delete dir entries | | vlock (Linux) | terminal locker | | $EDITOR ($VISUAL, if defined) | edit files (fallback vi) | diff --git a/nnn.1 b/nnn.1 index 4e303154..cb69dbb5 100644 --- a/nnn.1 +++ b/nnn.1 @@ -100,6 +100,8 @@ Open current entry in EDITOR (fallback vi) Open directory in NNN_DE_FILE_MANAGER .It Ic p Open current entry in PAGER (fallback less) +.It Ic f +Archive current entry .It Ic F List files in archive .It Ic ^F diff --git a/nnn.c b/nnn.c index 5c8caf7b..35df7b0e 100644 --- a/nnn.c +++ b/nnn.c @@ -273,7 +273,8 @@ static struct timespec gtimeout; #define OPENER 2 #define NLAY 3 #define ATOOL 4 -#define VIDIR 5 +#define APACK 5 +#define VIDIR 6 /* Utilities to open files, run actions */ static char * const utils[] = { @@ -286,6 +287,7 @@ static char * const utils[] = { #endif "nlay", "atool", + "apack", "vidir" }; @@ -1966,6 +1968,7 @@ show_help(char *path) "ee | Edit entry in EDITOR\n" "eo | Open DE filemanager\n" "ep | Open entry in PAGER\n" + "ef | Archive entry\n" "eF | List archive\n" "d^F | Extract archive\n" "d^K | Copy file path\n" @@ -3068,8 +3071,9 @@ nochange: goto nochange; case SEL_OPEN: printprompt("open with: "); // fallthrough + case SEL_ARCHIVE: // fallthrough case SEL_NEW: - if (sel == SEL_NEW) + if (sel != SEL_OPEN) printprompt("name: "); tmp = xreadline(NULL); @@ -3095,7 +3099,15 @@ nochange: mkpath(path, dents[cur].name, newpath, PATH_MAX); spawn(tmp, newpath, NULL, path, r); + continue; + } else if (sel == SEL_ARCHIVE) { + /* newpath is used as temporary buffer */ + if (!get_output(newpath, PATH_MAX, "which", utils[APACK], NULL, 0)) { + printmsg("apack missing"); + continue; + } + spawn(utils[APACK], tmp, dents[cur].name, path, F_NORMAL); continue; } diff --git a/nnn.h b/nnn.h index fa925233..f021567c 100644 --- a/nnn.h +++ b/nnn.h @@ -27,6 +27,7 @@ enum action { SEL_MEDIA, SEL_FMEDIA, SEL_DFB, + SEL_ARCHIVE, SEL_LIST, SEL_EXTRACT, SEL_FSIZE, @@ -137,6 +138,8 @@ static struct key bindings[] = { { 'M', SEL_FMEDIA, "-f", "" }, /* Open dir in desktop file manager */ { 'o', SEL_DFB, "", "" }, + /* Create archive */ + { 'f', SEL_ARCHIVE, "", "" }, /* List archive */ { 'F', SEL_LIST, "-l", "" }, /* Extract archive */