Fix #214: show cp, mv progress with advcpmv

This commit is contained in:
Arun Prakash Jana 2019-02-25 19:37:23 +05:30
parent 04e5d644db
commit 963252fcc7
No known key found for this signature in database
GPG key ID: A75979F35C080412
3 changed files with 35 additions and 4 deletions

View file

@ -103,6 +103,7 @@ It runs on Linux, macOS, Raspberry Pi, BSD, Cygwin, Linux subsystem for Windows
- Create, rename files and directories - Create, rename files and directories
- Select files across dirs; all/range selection - Select files across dirs; all/range selection
- Copy, move, delete, archive selection - Copy, move, delete, archive selection
- Show copy, move progress on Linux (needs avdcpmv)
- Create sym/hard link(s) to selection - Create sym/hard link(s) to selection
- Transfer files using lftp - Transfer files using lftp
- Batch rename/move/delete (needs vidir) - Batch rename/move/delete (needs vidir)
@ -154,6 +155,7 @@ Intrigued? Find out [HOW](https://github.com/jarun/nnn/wiki/performance-factors)
| atool, patool ([integration](https://github.com/jarun/nnn/wiki/How-to#integrate-patool)) | create, list and extract archives | | atool, patool ([integration](https://github.com/jarun/nnn/wiki/How-to#integrate-patool)) | 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), bashlock (macOS), lock(1) (BSD) | terminal locker | | vlock (Linux), bashlock (macOS), lock(1) (BSD) | terminal locker |
| advcpmv (Linux-only) ([integration](https://github.com/jarun/nnn/wiki/How-to#show-cp-mv-progress)) | copy, move progress |
| $EDITOR (overridden by $VISUAL, if defined) | edit files (fallback vi) | | $EDITOR (overridden by $VISUAL, if defined) | edit files (fallback vi) |
| $PAGER (less, most) | page through files (fallback less) | | $PAGER (less, most) | page through files (fallback less) |
| $SHELL (single coombined argument) | spawn a shell, run script (fallback sh) | | $SHELL (single coombined argument) | spawn a shell, run script (fallback sh) |
@ -389,6 +391,7 @@ The following indicators are used in the detail view:
| `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type` mode | | `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type` mode |
| `NNN_RESTRICT_NAV_OPEN=1` | open files on <kbd></kbd>, not <kbd></kbd> or <kbd>l</kbd> | | `NNN_RESTRICT_NAV_OPEN=1` | open files on <kbd></kbd>, not <kbd></kbd> or <kbd>l</kbd> |
| `NNN_RESTRICT_0B=1` | do not open 0-byte files | | `NNN_RESTRICT_0B=1` | do not open 0-byte files |
| `NNN_CP_MV_PROG=1` | show copy, move progress (Linux-only) |
#### Help #### Help

5
nnn.1
View file

@ -340,6 +340,11 @@ files.
.Bd -literal .Bd -literal
export NNN_RESTRICT_0B=1 export NNN_RESTRICT_0B=1
.Ed .Ed
.Pp
\fBNNN_CP_MV_PROG:\fR show progress of copy, move operations (Linux-only, needs advcpmv).
.Bd -literal
export NNN_CP_MV_PROG=1
.Ed
.Sh KNOWN ISSUES .Sh KNOWN ISSUES
If you are using urxvt you might have to set backspace key to DEC. If you are using urxvt you might have to set backspace key to DEC.
.Sh AUTHORS .Sh AUTHORS

View file

@ -404,6 +404,11 @@ static char * const utils[] = {
"UNKNOWN" "UNKNOWN"
}; };
#ifdef __linux__
static char cp[] = "cpg -giRp";
static char mv[] = "mvg -gi";
#endif
/* Common strings */ /* Common strings */
#define STR_NFTWFAIL_ID 0 #define STR_NFTWFAIL_ID 0
#define STR_NOHOME_ID 1 #define STR_NOHOME_ID 1
@ -438,6 +443,9 @@ static const char * const messages[] = {
#define NNN_NO_AUTOSELECT 11 #define NNN_NO_AUTOSELECT 11
#define NNN_RESTRICT_NAV_OPEN 12 #define NNN_RESTRICT_NAV_OPEN 12
#define NNN_RESTRICT_0B 13 #define NNN_RESTRICT_0B 13
#ifdef __linux__
#define NNN_CP_MV_PROG 14
#endif
static const char * const env_cfg[] = { static const char * const env_cfg[] = {
"NNN_BMS", "NNN_BMS",
@ -454,6 +462,9 @@ static const char * const env_cfg[] = {
"NNN_NO_AUTOSELECT", "NNN_NO_AUTOSELECT",
"NNN_RESTRICT_NAV_OPEN", "NNN_RESTRICT_NAV_OPEN",
"NNN_RESTRICT_0B", "NNN_RESTRICT_0B",
#ifdef __linux__
"NNN_CP_MV_PROG",
#endif
}; };
/* Required env vars */ /* Required env vars */
@ -3574,19 +3585,21 @@ nochange:
if (sel == SEL_CP) { if (sel == SEL_CP) {
snprintf(g_buf, CMD_LEN_MAX, snprintf(g_buf, CMD_LEN_MAX,
#ifdef __linux__ #ifdef __linux__
"xargs -0 -a %s -%c src cp -iRp src .", "xargs -0 -a %s -%c src %s src .",
g_cppath, REPLACE_STR, cp);
#else #else
"cat %s | xargs -0 -o -%c src cp -iRp src .", "cat %s | xargs -0 -o -%c src cp -iRp src .",
#endif
g_cppath, REPLACE_STR); g_cppath, REPLACE_STR);
#endif
} else if (sel == SEL_MV) { } else if (sel == SEL_MV) {
snprintf(g_buf, CMD_LEN_MAX, snprintf(g_buf, CMD_LEN_MAX,
#ifdef __linux__ #ifdef __linux__
"xargs -0 -a %s -%c src mv -i src .", "xargs -0 -a %s -%c src %s src .",
g_cppath, REPLACE_STR, mv);
#else #else
"cat %s | xargs -0 -o -%c src mv -i src .", "cat %s | xargs -0 -o -%c src mv -i src .",
#endif
g_cppath, REPLACE_STR); g_cppath, REPLACE_STR);
#endif
} else { /* SEL_RMMUL */ } else { /* SEL_RMMUL */
snprintf(g_buf, CMD_LEN_MAX, snprintf(g_buf, CMD_LEN_MAX,
#ifdef __linux__ #ifdef __linux__
@ -4215,6 +4228,16 @@ int main(int argc, char *argv[])
if (getenv(env_cfg[NNN_RESTRICT_0B])) if (getenv(env_cfg[NNN_RESTRICT_0B]))
cfg.restrict0b = 1; cfg.restrict0b = 1;
#ifdef __linux__
if (!getenv(env_cfg[NNN_CP_MV_PROG])) {
cp[5] = cp[4];
cp[2] = cp[4] = ' ';
mv[5] = mv[4];
mv[2] = mv[4] = ' ';
}
#endif
/* Ignore/handle certain signals */ /* Ignore/handle certain signals */
struct sigaction act; struct sigaction act;