mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Support trash-cli to trash
This commit is contained in:
parent
090e55c74a
commit
5dd5710b31
|
@ -101,7 +101,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
|
||||||
- Freedeskp compliant trash (needs trash-cli)
|
- FreeDesktop compliant trash (needs trash-cli)
|
||||||
- Show copy, move progress on Linux (needs avdcpmv)
|
- 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
|
||||||
|
@ -136,7 +136,7 @@ It runs on Linux, macOS, Raspberry Pi, BSD, Cygwin, Linux subsystem for Windows
|
||||||
| xdg-open (Linux), open(1) (macOS), cygstart (Cygwin) | desktop opener |
|
| xdg-open (Linux), open(1) (macOS), cygstart (Cygwin) | desktop opener |
|
||||||
| file | determine file type |
|
| file | determine file type |
|
||||||
| coreutils (cp, mv, rm), findutils (xargs) | copy, move and remove files |
|
| coreutils (cp, mv, rm), findutils (xargs) | copy, move and remove files |
|
||||||
| trash-cli | trash files instead of delete |
|
| trash-cli | trash files (instead of delete) |
|
||||||
| mediainfo or exiftool | multimedia file details |
|
| mediainfo or exiftool | multimedia file details |
|
||||||
| 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 dir entries |
|
| vidir (from moreutils) | batch rename dir entries |
|
||||||
|
@ -378,7 +378,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_TRASH=1` | trash (instead of _delete_) files to desktop Trash |
|
| `NNN_TRASH=1` | trash files to the desktop Trash [default: delete] |
|
||||||
| `NNN_CP_MV_PROG=1` | show copy, move progress on Linux |
|
| `NNN_CP_MV_PROG=1` | show copy, move progress on Linux |
|
||||||
|
|
||||||
#### Help
|
#### Help
|
||||||
|
|
24
src/nnn.c
24
src/nnn.c
|
@ -1141,20 +1141,32 @@ static void mvstr(char *buf)
|
||||||
|
|
||||||
static void rmmulstr(char *buf)
|
static void rmmulstr(char *buf)
|
||||||
{
|
{
|
||||||
snprintf(buf, CMD_LEN_MAX,
|
if (cfg.trash) {
|
||||||
|
snprintf(buf, CMD_LEN_MAX,
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
"xargs -0 -a %s rm -%cr",
|
"xargs -0 -a %s trash-put", g_cppath);
|
||||||
#else
|
#else
|
||||||
"cat %s | xargs -0 -o rm -%cr",
|
"cat %s | xargs -0 trash-put", g_cppath);
|
||||||
#endif
|
#endif
|
||||||
g_cppath, confirm_force());
|
} else {
|
||||||
|
snprintf(buf, CMD_LEN_MAX,
|
||||||
|
#ifdef __linux__
|
||||||
|
"xargs -0 -a %s rm -%cr", g_cppath, confirm_force());
|
||||||
|
#else
|
||||||
|
"cat %s | xargs -0 -o rm -%cr", g_cppath, confirm_force());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xrm(char *path)
|
static void xrm(char *path)
|
||||||
{
|
{
|
||||||
char rm_opts[] = {'-', confirm_force(), 'r'};
|
if (cfg.trash)
|
||||||
|
spawn("trash-put", path, NULL, NULL, F_NORMAL | F_SIGINT);
|
||||||
|
else {
|
||||||
|
char rm_opts[] = {'-', confirm_force(), 'r'};
|
||||||
|
|
||||||
spawn("rm", rm_opts, path, NULL, F_NORMAL | F_SIGINT);
|
spawn("rm", rm_opts, path, NULL, F_NORMAL | F_SIGINT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void archive_selection(const char *archive, const char *curpath)
|
static void archive_selection(const char *archive, const char *curpath)
|
||||||
|
|
Loading…
Reference in a new issue