To assign keys to arbitrary non-background cli commands and invoke like
plugins, add \fB!\fR before the command.
.Bd -literal
- export NNN_PLUG='x:!chmod +x $nnn;g:!git log;s:!smplayer $nnn'
+ export NNN_PLUG='x:!chmod +x "$nnn";g:!git log;s:!smplayer "$nnn"'
To pick and run an unassigned plugin, press \fBEnter\fR at the plugin prompt.
To run a plugin at startup, use the option `-P` followed by the plugin key.
NOTES:
- 1. Use single quotes for $NNN_PLUG so $nnn is not interpreted
- 2. $nnn must be the last argument (if used) to run a \fIcommand as plugin\fR
+ 1. Place $nnn in double quotes (\fB"$nnn"\fR)
+ 2. Use single quotes for $NNN_PLUG so "$nnn" is not interpreted
3. (Again) add \fB!\fR before the command
4. To disable directory refresh after running a \fIcommand as plugin\fR,
prefix with \fB-!\fR
export NNN_PLUG='y:-!sync*'
- 6. To run a \fIGUI app as plugin\fR, add a \fB&\fR after \fB!\fR
- \fI$nnn\fR must be the last argument in this case.
+ 6. To run a \fIGUI app as plugin\fR, add a \fB&\fR after \fB!\fR.
- export NNN_PLUG='m:-!&mousepad $nnn'
+ export NNN_PLUG='m:-!&mousepad "$nnn"'
7. To show the output of run-and-exit commands which do not need user input,
add \fB|\fR (pipe) after \fB!\fR
Note: This option is incompatible with \fB&\fR (terminal output is masked
for GUI programs) and ignores \fB*\fR (output is already paged for user).
- \fI$nnn\fR must be the last argument in this case as well.
- export NNN_PLUG='m:-!|mediainfo $nnn;t:-!|tree -ps;l:-!|ls -lah --group-directories-first'
+ export NNN_PLUG='m:-!|mediainfo "$nnn";t:-!|tree -ps;l:-!|ls -lah --group-directories-first'
EXAMPLES:
------------------------------------ + -------------------------------------------------
This option is incompatible with `&` (terminal output is masked for GUI programs) and ignores `*` (output is already paged for user).
Notes:
-
-1. Use single quotes for `$NNN_PLUG` so `"$nnn"` is not interpreted
-2. (_Again_) add `!` before the command
-3. To disable directory refresh after running a _command as plugin_, prefix with `-!`
+1. Place `$nnn` in double quotes (**`"$nnn"`**)
+2. Use single quotes for `$NNN_PLUG` so `"$nnn"` is not interpreted
+3. (_Again_) add `!` before the command
+4. To disable directory refresh after running a _command as plugin_, prefix with `-!`
#### Some useful key-command examples
setenv("NNN_INCLUDE_HIDDEN", xitoa(cfg.showhidden), 1);
}
-static void run_cmd_as_plugin(const char *file, char *runfile, uchar_t flags)
+static void run_cmd_as_plugin(const char *file, uchar_t flags)
{
size_t len;
--len;
}
- /* This is to catch the old way of doing things so we don't break users' configs */
- if ((flags & (F_PAGE | F_NOTRACE)) && is_suffix(g_buf, " $nnn")) {
- g_buf[len - 5] = '\0';
-
- if (flags & F_PAGE)
- get_output(g_buf, runfile, NULL, -1, TRUE);
- else // F_NOTRACE
- spawn(g_buf, runfile, NULL, NULL, flags);
- }
-
if (flags & F_PAGE)
get_output(utils[UTIL_SH_EXEC], g_buf, NULL, -1, TRUE);
else
flags |= F_PAGE;
++file;
} else if (*file == '&') { /* Check if GUI flags are to be used */
- flags = F_NOTRACE | F_NOWAIT;
+ flags = F_MULTI | F_NOTRACE | F_NOWAIT;
++file;
}
return FALSE;
if ((flags & F_NOTRACE) || (flags & F_PAGE)) {
- run_cmd_as_plugin(file, runfile, flags);
+ run_cmd_as_plugin(file, flags);
return TRUE;
}
} else
spawn(g_buf, NULL, *path, sel, 0);
} else
- run_cmd_as_plugin(file, runfile, flags);
+ run_cmd_as_plugin(file, flags);
close(wfd);
_exit(EXIT_SUCCESS);