complete -c nnn -s n -d 'start in type-to-nav mode'
complete -c nnn -s o -d 'open files only on Enter'
complete -c nnn -s p -r -d 'copy selection to file' -a '-\tstdout'
+complete -c nnn -s P -r -d 'plugin key to run' -x -a '(echo $NNN_PLUG | awk -F: -v RS=\; \'{print $1"\t"$2}\')'
complete -c nnn -s Q -d 'disable quit confirmation'
complete -c nnn -s r -d 'show cp, mv progress (Linux-only)'
complete -c nnn -s R -d 'disable rollover at edges'
return cfg.filtermode;
}
-static bool browse(char *ipath, const char *session)
+static bool browse(char *ipath, const char *session, int pkey)
{
char newpath[PATH_MAX] __attribute__ ((aligned));
char rundir[PATH_MAX] __attribute__ ((aligned));
newpath[0] = rundir[0] = runfile[0] = '\0';
- presel = cfg.filtermode ? FILTER : 0;
+ presel = pkey ? ';' : (cfg.filtermode ? FILTER : 0);
dents = xrealloc(dents, total_dents * sizeof(struct entry));
if (!dents)
goto nochange;
}
- r = xstrsncpy(g_buf, messages[MSG_PLUGIN_KEYS], CMD_LEN_MAX);
- printkeys(plug, g_buf + r - 1, maxplug);
- printmsg(g_buf);
- r = get_input(NULL);
+ if (!pkey) {
+ r = xstrsncpy(g_buf, messages[MSG_PLUGIN_KEYS], CMD_LEN_MAX);
+ printkeys(plug, g_buf + r - 1, maxplug);
+ printmsg(g_buf);
+ r = get_input(NULL);
+ } else {
+ r = pkey;
+ pkey = '\0';
+ }
+
if (r != '\r') {
endselection();
tmp = get_kv_val(plug, NULL, r, maxplug, NNN_PLUG);
" -n type-to-nav mode\n"
" -o open files only on Enter\n"
" -p file selection file [stdout if '-']\n"
+ " -P key run plugin key\n"
" -Q no quit confirmation\n"
" -r use advcpmv patched cp, mv\n"
" -R no rollover at edges\n"
{
char *arg = NULL;
char *session = NULL;
- int fd, opt, sort = 0;
+ int fd, opt, sort = 0, pkey = '\0'; /* Plugin key */
#ifndef NOMOUSE
mmask_t mask;
char *middle_click_env = xgetenv(env_cfg[NNN_MCLICK], "\0");
while ((opt = (env_opts_id > 0
? env_opts[--env_opts_id]
- : getopt(argc, argv, "Ab:cdeEfFgHKl:nop:QrRs:St:T:Vxh"))) != -1) {
+ : getopt(argc, argv, "Ab:cdeEfFgHKl:nop:P:QrRs:St:T:Vxh"))) != -1) {
switch (opt) {
case 'A':
cfg.autoselect = 0;
break;
case 'b':
- arg = optarg;
+ if (env_opts_id < 0)
+ arg = optarg;
break;
case 'c':
cfg.cliopener = 1;
unlink(selpath);
}
break;
+ case 'P':
+ if (env_opts_id < 0 && !optarg[1])
+ pkey = optarg[0];
+ break;
case 'Q':
g_states |= STATE_FORCEQUIT;
break;
if (sort)
set_sort_flags(sort);
- opt = browse(initpath, session);
+ opt = browse(initpath, session, pkey);
#ifndef NOMOUSE
mousemask(mask, NULL);