aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-10-24 12:39:31 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-10-24 12:44:01 +0530
commit5bebd4ac67c760a846e0b6ff4e49dc338aeed50e (patch)
tree477cb04f914f82b1cc68c1bf7c8efc462195432d /src
parentcb916661c8a7defbdbd579ac14c30d0c679f8fea (diff)
downloadnnn-5bebd4ac67c760a846e0b6ff4e49dc338aeed50e.tar.gz
Extend plugin mechanism to arbitrary commands
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/nnn.c b/src/nnn.c
index aa4c513..c5a59c7 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -128,7 +128,7 @@
#define MSGWAIT '$'
#define REGEX_MAX 48
#define BM_MAX 10
-#define PLUGIN_MAX 10
+#define PLUGIN_MAX 15
#define ENTRY_INCR 64 /* Number of dir 'entry' structures to allocate per shot */
#define NAMEBUF_INCR 0x800 /* 64 dir entries at once, avg. 32 chars per filename = 64*32B = 2KB */
#define DESCRIPTOR_LEN 32
@@ -4941,13 +4941,21 @@ nochange:
}
if (sel == SEL_PLUGKEY) {
+ uchar flag = F_NORMAL;
+
r = get_input("");
tmp = get_kv_val(plug, NULL, r, PLUGIN_MAX, FALSE);
if (!tmp)
goto nochange;
- mkpath(plugindir, tmp, newpath);
- spawn(newpath, (ndents ? dents[cur].name : NULL), path, path, F_NORMAL);
+ if (tmp[0] == '_' && tmp[1]) {
+ xstrlcpy(newpath, ++tmp, PATH_MAX);
+ flag = F_CLI | F_CONFIRM;
+ } else
+ mkpath(plugindir, tmp, newpath);
+
+ spawn(newpath, (ndents ? dents[cur].name : NULL),
+ path, path, flag);
if (cfg.filtermode)
presel = FILTER;