mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Support archive creation
This commit is contained in:
parent
28f303699c
commit
c27f58555e
|
@ -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
|
- Desktop search (gnome-search-tool, catfish) integration
|
||||||
- Mimes
|
- Mimes
|
||||||
- Open with desktop opener (default) or specify a custom app
|
- 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)
|
- Optionally open text files in EDITOR (fallback vi)
|
||||||
- Customizable bash script [nlay](https://github.com/jarun/nnn/wiki/all-about-nlay) to handle actions
|
- Customizable bash script [nlay](https://github.com/jarun/nnn/wiki/all-about-nlay) to handle actions
|
||||||
- Information
|
- Information
|
||||||
|
@ -237,6 +237,7 @@ optional arguments:
|
||||||
e | Edit entry in EDITOR
|
e | Edit entry in EDITOR
|
||||||
o | Open DE filemanager
|
o | Open DE filemanager
|
||||||
p | Open entry in PAGER
|
p | Open entry in PAGER
|
||||||
|
f | Archive entry
|
||||||
F | List archive
|
F | List archive
|
||||||
^F | Extract archive
|
^F | Extract archive
|
||||||
^K | Copy file path
|
^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 |
|
| xdg-open (Linux), open(1) (OS X) | desktop opener |
|
||||||
| mediainfo, exiftool | multimedia file details |
|
| mediainfo, exiftool | multimedia file details |
|
||||||
| gnome-search-tool, catfish | desktop search utility |
|
| 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 |
|
| vidir from moreutils | batch rename, move, delete dir entries |
|
||||||
| vlock (Linux) | terminal locker |
|
| vlock (Linux) | terminal locker |
|
||||||
| $EDITOR ($VISUAL, if defined) | edit files (fallback vi) |
|
| $EDITOR ($VISUAL, if defined) | edit files (fallback vi) |
|
||||||
|
|
2
nnn.1
2
nnn.1
|
@ -100,6 +100,8 @@ Open current entry in EDITOR (fallback vi)
|
||||||
Open directory in NNN_DE_FILE_MANAGER
|
Open directory in NNN_DE_FILE_MANAGER
|
||||||
.It Ic p
|
.It Ic p
|
||||||
Open current entry in PAGER (fallback less)
|
Open current entry in PAGER (fallback less)
|
||||||
|
.It Ic f
|
||||||
|
Archive current entry
|
||||||
.It Ic F
|
.It Ic F
|
||||||
List files in archive
|
List files in archive
|
||||||
.It Ic ^F
|
.It Ic ^F
|
||||||
|
|
16
nnn.c
16
nnn.c
|
@ -273,7 +273,8 @@ static struct timespec gtimeout;
|
||||||
#define OPENER 2
|
#define OPENER 2
|
||||||
#define NLAY 3
|
#define NLAY 3
|
||||||
#define ATOOL 4
|
#define ATOOL 4
|
||||||
#define VIDIR 5
|
#define APACK 5
|
||||||
|
#define VIDIR 6
|
||||||
|
|
||||||
/* Utilities to open files, run actions */
|
/* Utilities to open files, run actions */
|
||||||
static char * const utils[] = {
|
static char * const utils[] = {
|
||||||
|
@ -286,6 +287,7 @@ static char * const utils[] = {
|
||||||
#endif
|
#endif
|
||||||
"nlay",
|
"nlay",
|
||||||
"atool",
|
"atool",
|
||||||
|
"apack",
|
||||||
"vidir"
|
"vidir"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1966,6 +1968,7 @@ show_help(char *path)
|
||||||
"ee | Edit entry in EDITOR\n"
|
"ee | Edit entry in EDITOR\n"
|
||||||
"eo | Open DE filemanager\n"
|
"eo | Open DE filemanager\n"
|
||||||
"ep | Open entry in PAGER\n"
|
"ep | Open entry in PAGER\n"
|
||||||
|
"ef | Archive entry\n"
|
||||||
"eF | List archive\n"
|
"eF | List archive\n"
|
||||||
"d^F | Extract archive\n"
|
"d^F | Extract archive\n"
|
||||||
"d^K | Copy file path\n"
|
"d^K | Copy file path\n"
|
||||||
|
@ -3068,8 +3071,9 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
case SEL_OPEN:
|
case SEL_OPEN:
|
||||||
printprompt("open with: "); // fallthrough
|
printprompt("open with: "); // fallthrough
|
||||||
|
case SEL_ARCHIVE: // fallthrough
|
||||||
case SEL_NEW:
|
case SEL_NEW:
|
||||||
if (sel == SEL_NEW)
|
if (sel != SEL_OPEN)
|
||||||
printprompt("name: ");
|
printprompt("name: ");
|
||||||
|
|
||||||
tmp = xreadline(NULL);
|
tmp = xreadline(NULL);
|
||||||
|
@ -3095,7 +3099,15 @@ nochange:
|
||||||
|
|
||||||
mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
||||||
spawn(tmp, newpath, NULL, path, r);
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
nnn.h
3
nnn.h
|
@ -27,6 +27,7 @@ enum action {
|
||||||
SEL_MEDIA,
|
SEL_MEDIA,
|
||||||
SEL_FMEDIA,
|
SEL_FMEDIA,
|
||||||
SEL_DFB,
|
SEL_DFB,
|
||||||
|
SEL_ARCHIVE,
|
||||||
SEL_LIST,
|
SEL_LIST,
|
||||||
SEL_EXTRACT,
|
SEL_EXTRACT,
|
||||||
SEL_FSIZE,
|
SEL_FSIZE,
|
||||||
|
@ -137,6 +138,8 @@ static struct key bindings[] = {
|
||||||
{ 'M', SEL_FMEDIA, "-f", "" },
|
{ 'M', SEL_FMEDIA, "-f", "" },
|
||||||
/* Open dir in desktop file manager */
|
/* Open dir in desktop file manager */
|
||||||
{ 'o', SEL_DFB, "", "" },
|
{ 'o', SEL_DFB, "", "" },
|
||||||
|
/* Create archive */
|
||||||
|
{ 'f', SEL_ARCHIVE, "", "" },
|
||||||
/* List archive */
|
/* List archive */
|
||||||
{ 'F', SEL_LIST, "-l", "" },
|
{ 'F', SEL_LIST, "-l", "" },
|
||||||
/* Extract archive */
|
/* Extract archive */
|
||||||
|
|
Loading…
Reference in a new issue