From ee733a39b1f82088d607d72b0ab492770a723845 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sat, 24 Feb 2018 19:46:58 +0530 Subject: Support batch file rename in vidir --- nnn.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'nnn.c') diff --git a/nnn.c b/nnn.c index 1161de7..32a7d27 100644 --- a/nnn.c +++ b/nnn.c @@ -281,7 +281,8 @@ static char * const utils[] = { "xdg-open", #endif "nlay", - "atool" + "atool", + "vidir" }; /* Common strings */ @@ -641,7 +642,7 @@ appendfilepath(const char *path, const size_t len) copybuflen += PATH_MAX; pcopybuf = xrealloc(pcopybuf, copybuflen); if (!pcopybuf) { - printmsg("no memory!\n"); + printmsg("no memory!"); return FALSE; } } @@ -1867,6 +1868,7 @@ show_help(char *path) "eM | Full media info\n" "en | Create new\n" "d^R | Rename entry\n" + "eR | Rename dir entries\n" "es | Toggle sort by size\n" "aS, ^J | Toggle du mode\n" "et | Toggle sort by mtime\n" @@ -3070,6 +3072,35 @@ nochange: close(fd); xstrlcpy(oldname, tmp, NAME_MAX + 1); 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: show_help(path); break; -- cgit v1.2.3-70-g09d2