^F | Extract archive
^K | Invoke file path copier
^Y | Toggle multi-copy mode
+ ^T | Toggle path quote
^L | Redraw, clear prompt
? | Help, settings
Q | Quit and cd
Pressing <kbd>^Y</kbd> again copies the paths to clipboard and exits the multi-copy mode.
+To wrap each file path within single quotes, export `NNN_QUOTE_ON`:
+
+ export NNN_QUOTE_ON=1
+This is particularly useful if you are planning to copy the whole string to the shell to run a command. Quotes can be toggled at runtime using <kbd>^T</kbd>.
+
#### change dir color
The default color for directories is blue. Option `-c` accepts color codes from 0 to 7 to use a different color:
ushort showcolor : 1; /* Set to show dirs in blue */
ushort dircolor : 1; /* Current status of dir color */
ushort metaviewer : 1; /* Index of metadata viewer in utils[] */
+ ushort quote : 1; /* Copy paths within quotes */
ushort color : 3; /* Color code for directories */
} settings;
/* GLOBALS */
/* Configuration */
-static settings cfg = {0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 4};
+static settings cfg = {0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 4};
static struct entry *dents;
static char *pnamebuf, *pcopybuf;
static bool
appendfilepath(const char *path, const size_t len)
{
- if ((copybufpos >= copybuflen) || (len > (copybuflen - (copybufpos + 1)))) {
+ if ((copybufpos >= copybuflen) || (len > (copybuflen - (copybufpos + 3)))) {
copybuflen += PATH_MAX;
pcopybuf = xrealloc(pcopybuf, copybuflen);
if (!pcopybuf) {
}
}
- if (copybufpos)
+ if (copybufpos) {
pcopybuf[copybufpos - 1] = '\n';
+ if (cfg.quote) {
+ pcopybuf[copybufpos] = '\'';
+ ++copybufpos;
+ }
+ } else if (cfg.quote) {
+ pcopybuf[copybufpos] = '\'';
+ ++copybufpos;
+ }
copybufpos += xstrlcpy(pcopybuf + copybufpos, path, len);
+ if (cfg.quote) {
+ pcopybuf[copybufpos - 1] = '\'';
+ pcopybuf[copybufpos] = '\0';
+ ++copybufpos;
+ }
+
return TRUE;
}
"d^F | Extract archive\n"
"d^K | Invoke file path copier\n"
"d^Y | Toggle multi-copy mode\n"
+ "d^T | Toggle path quote\n"
"d^L | Redraw, clear prompt\n"
"e? | Help, settings\n"
"eQ | Quit and cd\n"
}
}
goto nochange;
+ case SEL_QUOTE:
+ cfg.quote ^= 1;
+ DPRINTF_D(cfg.quote);
+ if (cfg.quote)
+ printmsg("quotes on");
+ else
+ printmsg("quotes off");
+ goto nochange;
case SEL_OPEN:
printprompt("open with: "); // fallthrough
case SEL_NEW:
/* Get nowait flag */
nowait |= getenv("NNN_NOWAIT") ? F_NOWAIT : 0;
+ /* Enable quotes if opted */
+ if (getenv("NNN_QUOTE_ON"))
+ cfg.quote = 1;
+
signal(SIGINT, SIG_IGN);
/* Test initial path */
SEL_REDRAW,
SEL_COPY,
SEL_COPYMUL,
+ SEL_QUOTE,
SEL_OPEN,
SEL_NEW,
SEL_RENAME,
{ CONTROL('K'), SEL_COPY, "", "" },
/* Toggle copy multiple file paths */
{ CONTROL('Y'), SEL_COPYMUL, "", "" },
+ /* Toggle quote on while copy */
+ { CONTROL('T'), SEL_QUOTE, "", "" },
/* Open in a custom application */
{ CONTROL('O'), SEL_OPEN, "", "" },
/* Create a new file */