mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Support batch file rename in vidir
This commit is contained in:
parent
63512152df
commit
ee733a39b1
|
@ -5,6 +5,7 @@ What's in?
|
||||||
- Copy multiple file paths
|
- Copy multiple file paths
|
||||||
- Copy file paths when X is unavailable
|
- Copy file paths when X is unavailable
|
||||||
- Optionally quote individual file paths with single quotes on copy
|
- Optionally quote individual file paths with single quotes on copy
|
||||||
|
- Batch rename files in vidir from [moreutils](https://joeyh.name/code/moreutils/)
|
||||||
- Use ISO 8601 date format in file details
|
- Use ISO 8601 date format in file details
|
||||||
- New/changed/remapped shortcuts:
|
- New/changed/remapped shortcuts:
|
||||||
- <kbd>^B</kbd> - show bookmark prompt (replaces <kbd>b</kbd>)
|
- <kbd>^B</kbd> - show bookmark prompt (replaces <kbd>b</kbd>)
|
||||||
|
|
|
@ -109,6 +109,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
|
||||||
- Sort by file name, modification time, size
|
- Sort by file name, modification time, size
|
||||||
- Convenience
|
- Convenience
|
||||||
- Create, rename files and directories
|
- Create, rename files and directories
|
||||||
|
- Batch rename current directory entries in vidir (from moreutils)
|
||||||
- Spawn SHELL (fallback sh) in the current directory
|
- Spawn SHELL (fallback sh) in the current directory
|
||||||
- Copy absolute file paths with/without X (*easy* shell integration)
|
- Copy absolute file paths with/without X (*easy* shell integration)
|
||||||
- Change directory at exit (*easy* shell integration)
|
- Change directory at exit (*easy* shell integration)
|
||||||
|
@ -238,6 +239,7 @@ optional arguments:
|
||||||
M | Full media info
|
M | Full media info
|
||||||
n | Create new
|
n | Create new
|
||||||
^R | Rename entry
|
^R | Rename entry
|
||||||
|
R | Rename dir entries
|
||||||
s | Toggle sort by size
|
s | Toggle sort by size
|
||||||
S, ^J | Toggle du mode
|
S, ^J | Toggle du mode
|
||||||
t | Toggle sort by mtime
|
t | Toggle sort by mtime
|
||||||
|
@ -303,6 +305,7 @@ The following abbreviations are used in the detail view:
|
||||||
export NNN_DE_FILE_MANAGER=nautilus
|
export NNN_DE_FILE_MANAGER=nautilus
|
||||||
- [mediainfo](https://mediaarea.net/en/MediaInfo) (or [exiftool](https://sno.phy.queensu.ca/~phil/exiftool/), if specified) is required to view media information
|
- [mediainfo](https://mediaarea.net/en/MediaInfo) (or [exiftool](https://sno.phy.queensu.ca/~phil/exiftool/), if specified) is required to view media information
|
||||||
- [atool](http://www.nongnu.org/atool/) is required to list and extract archives
|
- [atool](http://www.nongnu.org/atool/) is required to list and extract archives
|
||||||
|
- vidir from [moreutils](https://joeyh.name/code/moreutils/) is used to batch rename entries in current directory
|
||||||
|
|
||||||
#### Help
|
#### Help
|
||||||
|
|
||||||
|
|
2
nnn.1
2
nnn.1
|
@ -82,6 +82,8 @@ Show full media info
|
||||||
Create a new file or directory
|
Create a new file or directory
|
||||||
.It Ic ^R
|
.It Ic ^R
|
||||||
Rename selected entry
|
Rename selected entry
|
||||||
|
.It Ic R
|
||||||
|
Rename directory entries
|
||||||
.It Ic s
|
.It Ic s
|
||||||
Toggle sort by file size
|
Toggle sort by file size
|
||||||
.It Ic S, ^J
|
.It Ic S, ^J
|
||||||
|
|
35
nnn.c
35
nnn.c
|
@ -281,7 +281,8 @@ static char * const utils[] = {
|
||||||
"xdg-open",
|
"xdg-open",
|
||||||
#endif
|
#endif
|
||||||
"nlay",
|
"nlay",
|
||||||
"atool"
|
"atool",
|
||||||
|
"vidir"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Common strings */
|
/* Common strings */
|
||||||
|
@ -641,7 +642,7 @@ appendfilepath(const char *path, const size_t len)
|
||||||
copybuflen += PATH_MAX;
|
copybuflen += PATH_MAX;
|
||||||
pcopybuf = xrealloc(pcopybuf, copybuflen);
|
pcopybuf = xrealloc(pcopybuf, copybuflen);
|
||||||
if (!pcopybuf) {
|
if (!pcopybuf) {
|
||||||
printmsg("no memory!\n");
|
printmsg("no memory!");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1867,6 +1868,7 @@ show_help(char *path)
|
||||||
"eM | Full media info\n"
|
"eM | Full media info\n"
|
||||||
"en | Create new\n"
|
"en | Create new\n"
|
||||||
"d^R | Rename entry\n"
|
"d^R | Rename entry\n"
|
||||||
|
"eR | Rename dir entries\n"
|
||||||
"es | Toggle sort by size\n"
|
"es | Toggle sort by size\n"
|
||||||
"aS, ^J | Toggle du mode\n"
|
"aS, ^J | Toggle du mode\n"
|
||||||
"et | Toggle sort by mtime\n"
|
"et | Toggle sort by mtime\n"
|
||||||
|
@ -3070,6 +3072,35 @@ nochange:
|
||||||
close(fd);
|
close(fd);
|
||||||
xstrlcpy(oldname, tmp, NAME_MAX + 1);
|
xstrlcpy(oldname, tmp, NAME_MAX + 1);
|
||||||
goto begin;
|
goto begin;
|
||||||
|
case SEL_RENAMEALL:
|
||||||
|
if (!get_output(g_buf, MAX_CMD_LEN, "which", utils[5], NULL, 0)) {
|
||||||
|
printmsg("vidir missing");
|
||||||
|
goto nochange;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save the program start dir */
|
||||||
|
tmp = getcwd(newpath, PATH_MAX);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
printwarn();
|
||||||
|
goto nochange;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Switch to current path for readline(3) */
|
||||||
|
if (chdir(path) == -1) {
|
||||||
|
printwarn();
|
||||||
|
goto nochange;
|
||||||
|
}
|
||||||
|
|
||||||
|
spawn(utils[5], ".", NULL, NULL, F_NORMAL);
|
||||||
|
|
||||||
|
/* Change back to program start dir */
|
||||||
|
if (chdir(newpath) == -1)
|
||||||
|
printwarn();
|
||||||
|
|
||||||
|
/* Save current */
|
||||||
|
if (ndents > 0)
|
||||||
|
copycurname();
|
||||||
|
goto begin;
|
||||||
case SEL_HELP:
|
case SEL_HELP:
|
||||||
show_help(path);
|
show_help(path);
|
||||||
break;
|
break;
|
||||||
|
|
3
nnn.h
3
nnn.h
|
@ -39,6 +39,7 @@ enum action {
|
||||||
SEL_OPEN,
|
SEL_OPEN,
|
||||||
SEL_NEW,
|
SEL_NEW,
|
||||||
SEL_RENAME,
|
SEL_RENAME,
|
||||||
|
SEL_RENAMEALL,
|
||||||
SEL_HELP,
|
SEL_HELP,
|
||||||
SEL_RUN,
|
SEL_RUN,
|
||||||
SEL_RUNARG,
|
SEL_RUNARG,
|
||||||
|
@ -158,6 +159,8 @@ static struct key bindings[] = {
|
||||||
/* Show rename prompt */
|
/* Show rename prompt */
|
||||||
{ CONTROL('R'), SEL_RENAME, "", "" },
|
{ CONTROL('R'), SEL_RENAME, "", "" },
|
||||||
{ KEY_F(2), SEL_RENAME, "", "" }, /* Undocumented */
|
{ KEY_F(2), SEL_RENAME, "", "" }, /* Undocumented */
|
||||||
|
/* Rename contents of current dir */
|
||||||
|
{ 'R', SEL_RENAMEALL, "", "" },
|
||||||
/* Show help */
|
/* Show help */
|
||||||
{ '?', SEL_HELP, "", "" },
|
{ '?', SEL_HELP, "", "" },
|
||||||
/* Run command */
|
/* Run command */
|
||||||
|
|
Loading…
Reference in a new issue