aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-09-11 19:53:20 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-09-11 19:53:20 +0530
commit684a90a0fbe89ba2039685e25dacefe94e03dea6 (patch)
tree2948a2661df466c5411c2531155fbb38a8bf430f /src
parentc3ce5bc705e2918cd21815611c21cd1d2c15b19e (diff)
downloadnnn-684a90a0fbe89ba2039685e25dacefe94e03dea6.tar.gz
Batch rename: prompt if selection exists
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 666b920..54a014a 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1220,21 +1220,27 @@ static bool batch_rename(const char *path)
return ret;
}
- if (!selbufpos) {
- if (!ndents)
- return TRUE;
+ if (selbufpos) {
+ i = get_input("rename selection? [y/Y confirms]");
+ if (i != 'y' && i != 'Y') {
+ if (!ndents)
+ return TRUE;
+
+ selbufpos = 0; /* Clear the selection */
+ dir = TRUE;
+ }
+ } else
+ dir = TRUE; /* Rename entries in dir */
+ if (dir)
for (i = 0; i < ndents; ++i)
appendfpath(dents[i].name, NAME_MAX);
- dir = TRUE;
- }
-
selectiontofd(fd1, &count);
selectiontofd(fd2, NULL);
close(fd2);
- if (dir)
+ if (dir) /* Don't retain dir entries in selection */
selbufpos = 0;
spawn(editor, g_tmpfpath, NULL, path, F_CLI);
@@ -1243,10 +1249,9 @@ static bool batch_rename(const char *path)
if ((fd2 = open(g_tmpfpath, O_RDONLY)) == -1)
goto finish;
- while ((i = read(fd2, buf, sizeof(buf))) > 0) {
+ while ((i = read(fd2, buf, sizeof(buf))) > 0)
while (i)
lines += (buf[--i] == '\n');
- }
if (i < 0)
goto finish;