- [add bookmarks](#add-bookmarks)
- [use cd .....](#use-cd-)
- [cd on quit](#cd-on-quit)
- - [copy file paths to clipboard](#copy-file-paths-to-clipboard)
- - [copy file paths when X is missing](#copy-file-paths-when-x-is-missing)
+ - [copy file paths](#copy-file-paths)
+ - [to clipboard](#to-clipboard)
+ - [when X is missing](#when-x-is-missing)
- [run custom scripts](#run-custom-scripts)
- [sample scripts](#sample-scripts)
- [dual-pane or multi-pane](#dual-pane-or-multi-pane)
^F Extract archive
Space, ^K Copy file path
^Y Toggle multi-copy
+ y Show copy buffer
^T Toggle path quote
^L Redraw, clear prompt
L Lock terminal
As you might notice, `nnn` uses the environment variable `NNN_TMPFILE` to write the last visited directory path. You can change it.
-#### copy file paths to clipboard
+#### copy file paths
+
+File paths can be copied to the clipboard or to a specific temporary file (if X is unavailable, for example). When in multi-copy mode, currently copied file paths can be listed by pressing `y`.
+
+##### to clipboard
`nnn` can pipe the absolute path of the current file or multiple files to a copier script. For example, you can use `xsel` on Linux or `pbcopy` on OS X.
Note that the filename is not escaped. So copying may still fail for filenames having quote(s) in them.
-#### copy file paths when X is missing
+##### when X is missing
A very common scenario on headless remote servers connected via SSH. As the clipboard is missing, `nnn` copies the path names to the tmp file `DIR/.nnncp`, where `DIR` (by priority) is:
Invoke file path copier
.It Ic ^Y
Toggle multiple file path copy mode
+.It Ic y
+Show copy buffer
.It Ic ^T
Toggle path quote
.It Ic ^L
/* Forward declarations */
static void redraw(char *path);
+static char * get_output(char *buf, size_t bytes, char *file, char *arg1, char *arg2, int pager);
/* Functions */
return TRUE;
}
+static bool
+showcplist()
+{
+ ssize_t len;
+
+ if (!copybufpos)
+ return FALSE;
+
+ if (g_tmpfpath[0])
+ xstrlcpy(g_tmpfpath + g_tmpfplen - 1, "/.nnnXXXXXX", MAX_HOME_LEN - g_tmpfplen);
+ else {
+ printmsg(messages[STR_NOHOME_ID]);
+ return -1;
+ }
+
+ int fd = mkstemp(g_tmpfpath);
+ if (fd == -1)
+ return FALSE;
+
+ len = write(fd, pcopybuf, copybufpos - 1);
+ close(fd);
+
+ exitcurses();
+ if (len == copybufpos - 1)
+ get_output(NULL, 0, "cat", g_tmpfpath, NULL, 1);
+ unlink(g_tmpfpath);
+ refresh();
+ return TRUE;
+}
+
/*
* Return number of dots if all chars in a string are dots, else 0
*/
"d^F Extract archive\n"
"6Space, ^K Copy file path\n"
"d^Y Toggle multi-copy\n"
+ "ey Show copy buffer\n"
"d^T Toggle path quote\n"
"d^L Redraw, clear prompt\n"
"eL Lock terminal\n"
} else
printmsg("multi-copy off");
goto nochange;
+ case SEL_COPYLIST:
+ if (cfg.copymode)
+ showcplist();
+ else
+ printmsg("multi-copy off");
+ goto nochange;
case SEL_QUOTE:
cfg.quote ^= 1;
DPRINTF_D(cfg.quote);
SEL_REDRAW,
SEL_COPY,
SEL_COPYMUL,
+ SEL_COPYLIST,
SEL_QUOTE,
SEL_OPEN,
SEL_NEW,
{ ' ', SEL_COPY, "", "" },
/* Toggle copy multiple file paths */
{ CONTROL('Y'), SEL_COPYMUL, "", "" },
+ /* Show list of copied files */
+ { 'y', SEL_COPYLIST, "", "" },
/* Toggle quote on while copy */
{ CONTROL('T'), SEL_QUOTE, "", "" },
/* Open in a custom application */