Option -r to show cp, mv progress on Linux

This commit is contained in:
Arun Prakash Jana 2019-08-23 20:18:17 +05:30
parent 979fadcc7e
commit a4d8d68c7d
No known key found for this signature in database
GPG key ID: A75979F35C080412
6 changed files with 21 additions and 18 deletions

View file

@ -203,13 +203,12 @@ Option completion scripts for Bash, Fish and Zsh can be found in respective subd
| `NNN_IDLE_TIMEOUT=300` | idle seconds before locking terminal [default: disabled] | | `NNN_IDLE_TIMEOUT=300` | idle seconds before locking terminal [default: disabled] |
| `NNN_COPIER=copier` | clipboard copier script [default: none] | | `NNN_COPIER=copier` | clipboard copier script [default: none] |
| `NNN_TRASH=1` | trash files to the desktop Trash [default: delete] | | `NNN_TRASH=1` | trash files to the desktop Trash [default: delete] |
| `NNN_OPS_PROG=1` | show cp, mv progress on Linux (needs advcpmv) |
#### Cmdline options #### Cmdline options
``` ```
usage: nnn [-b key] [-d] [-e] [-H] [-i] [-n] [-o] usage: nnn [-b key] [-d] [-e] [-H] [-i] [-n] [-o]
[-p file] [-s] [-S] [-t] [-v] [-h] [PATH] [-p file] [-r] [-s] [-S] [-t] [-v] [-h] [PATH]
The missing terminal file manager for X. The missing terminal file manager for X.
@ -225,6 +224,7 @@ optional args:
-n version sort -n version sort
-o press Enter to open files -o press Enter to open files
-p file selection file (stdout if '-') -p file selection file (stdout if '-')
-r show cp, mv progress on Linux
-s string filters [default: regex] -s string filters [default: regex]
-S du mode -S du mode
-t disable dir auto-select -t disable dir auto-select

View file

@ -19,6 +19,7 @@ _nnn () {
-n -n
-o -o
-p -p
-r
-s -s
-S -S
-t -t

View file

@ -13,6 +13,7 @@ complete -c nnn -s i -d 'start in navigate-as-you-type mode'
complete -c nnn -s n -d 'use version compare to sort files' complete -c nnn -s n -d 'use version compare to sort files'
complete -c nnn -s o -d 'open files only on Enter' complete -c nnn -s o -d 'open files only on Enter'
complete -c nnn -s p -r -d 'copy selection to file' complete -c nnn -s p -r -d 'copy selection to file'
complete -c nnn -s r -d 'show cp, mv progress (Linux-only)'
complete -c nnn -s s -d 'use substring match for filters' complete -c nnn -s s -d 'use substring match for filters'
complete -c nnn -s S -d 'start in disk usage analyzer mode' complete -c nnn -s S -d 'start in disk usage analyzer mode'
complete -c nnn -s t -d 'disable dir auto-select' complete -c nnn -s t -d 'disable dir auto-select'

View file

@ -17,6 +17,7 @@ args=(
'(-n)-n[use version compare to sort files]' '(-n)-n[use version compare to sort files]'
'(-o)-o[open files only on Enter]' '(-o)-o[open files only on Enter]'
'(-p)-p[copy selection to file]:file name' '(-p)-p[copy selection to file]:file name'
'(-r)-r[show cp, mv progress (Linux-only)]'
'(-s)-s[use substring match for filters]' '(-s)-s[use substring match for filters]'
'(-S)-S[start in disk usage analyzer mode]' '(-S)-S[start in disk usage analyzer mode]'
'(-t)-t[disable dir auto-select]' '(-t)-t[disable dir auto-select]'

11
nnn.1
View file

@ -13,6 +13,7 @@
.Op Ar -i .Op Ar -i
.Op Ar -n .Op Ar -n
.Op Ar -p file .Op Ar -p file
.Op Ar -r
.Op Ar -s .Op Ar -s
.Op Ar -S .Op Ar -S
.Op Ar -v .Op Ar -v
@ -60,6 +61,9 @@ supports the following options:
.Fl "p file" .Fl "p file"
copy (or \fIpick\fR) selection to file, or stdout if file='-' copy (or \fIpick\fR) selection to file, or stdout if file='-'
.Pp .Pp
.Fl r
show cp, mv progress (Linux-only, needs advcpmv; '^T' shows the progress on BSD/macOS)
.Pp
.Fl s .Fl s
use substring match for filters instead of regex use substring match for filters instead of regex
.Pp .Pp
@ -191,13 +195,6 @@ files.
.Bd -literal .Bd -literal
export NNN_TRASH=1 export NNN_TRASH=1
.Ed .Ed
.Pp
\fBNNN_OPS_PROG:\fR show progress of copy, move operations (Linux-only, needs advcpmv).
.Bd -literal
export NNN_OPS_PROG=1
NOTE: BSD and macOS users can press '^T' to check the progress.
.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

@ -403,9 +403,6 @@ static const char * const messages[] = {
#define NNNLVL 6 /* strings end here */ #define NNNLVL 6 /* strings end here */
#define NNN_USE_EDITOR 7 /* flags begin here */ #define NNN_USE_EDITOR 7 /* flags begin here */
#define NNN_TRASH 8 #define NNN_TRASH 8
#ifdef __linux__
#define NNN_OPS_PROG 9
#endif
static const char * const env_cfg[] = { static const char * const env_cfg[] = {
"NNN_BMS", "NNN_BMS",
@ -417,9 +414,6 @@ static const char * const env_cfg[] = {
"NNNLVL", "NNNLVL",
"NNN_USE_EDITOR", "NNN_USE_EDITOR",
"NNN_TRASH", "NNN_TRASH",
#ifdef __linux__
"NNN_OPS_PROG",
#endif
}; };
/* Required environment variables */ /* Required environment variables */
@ -4565,7 +4559,7 @@ static void usage(void)
{ {
fprintf(stdout, fprintf(stdout,
"%s: nnn [-b key] [-d] [-e] [-H] [-i] [-n] [-o]\n" "%s: nnn [-b key] [-d] [-e] [-H] [-i] [-n] [-o]\n"
" [-p file] [-s] [-S] [-t] [-v] [-h] [PATH]\n\n" " [-p file] [-r] [-s] [-S] [-t] [-v] [-h] [PATH]\n\n"
"The missing terminal file manager for X.\n\n" "The missing terminal file manager for X.\n\n"
"positional args:\n" "positional args:\n"
" PATH start dir [default: current dir]\n\n" " PATH start dir [default: current dir]\n\n"
@ -4578,6 +4572,7 @@ static void usage(void)
" -n version sort\n" " -n version sort\n"
" -o press Enter to open files\n" " -o press Enter to open files\n"
" -p file selection file (stdout if '-')\n" " -p file selection file (stdout if '-')\n"
" -r show cp, mv progress on Linux\n"
" -s string filters [default: regex]\n" " -s string filters [default: regex]\n"
" -S du mode\n" " -S du mode\n"
" -t disable dir auto-select\n" " -t disable dir auto-select\n"
@ -4711,8 +4706,11 @@ int main(int argc, char *argv[])
{ {
char *arg = NULL; char *arg = NULL;
int opt; int opt;
#ifdef __linux__
bool progress = FALSE;
#endif
while ((opt = getopt(argc, argv, "HSib:denop:stvh")) != -1) { while ((opt = getopt(argc, argv, "HSib:denop:rstvh")) != -1) {
switch (opt) { switch (opt) {
case 'S': case 'S':
cfg.blkorder = 1; cfg.blkorder = 1;
@ -4758,6 +4756,11 @@ int main(int argc, char *argv[])
unlink(g_cppath); unlink(g_cppath);
} }
break; break;
case 'r':
#ifdef __linux__
progress = TRUE;
#endif
break;
case 's': case 's':
cfg.filter_re = 0; cfg.filter_re = 0;
filterfn = &visible_str; filterfn = &visible_str;
@ -4925,7 +4928,7 @@ int main(int argc, char *argv[])
copier = getenv(env_cfg[NNN_COPIER]); copier = getenv(env_cfg[NNN_COPIER]);
#ifdef __linux__ #ifdef __linux__
if (!xgetenv_set(env_cfg[NNN_OPS_PROG])) { if (!progress) {
cp[5] = cp[4]; cp[5] = cp[4];
cp[2] = cp[4] = ' '; cp[2] = cp[4] = ' ';