ソースを参照

Support copy buffer listing in multi-copy mode

master
Arun Prakash Jana 6年前
コミット
1562939325
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: A75979F35C080412
4個のファイルの変更53行の追加4行の削除
  1. +10
    -4
      README.md
  2. +2
    -0
      nnn.1
  3. +38
    -0
      nnn.c
  4. +3
    -0
      nnn.h

+ 10
- 4
README.md ファイルの表示

@@ -59,8 +59,9 @@ Have fun with it! Missing a feature? Want to contribute? Head to the rolling [To
- [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)
@@ -248,6 +249,7 @@ optional args:
^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
@@ -359,7 +361,11 @@ Pick the appropriate file for your shell from [`scripts/quitcd`](scripts/quitcd)

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.

@@ -392,7 +398,7 @@ This is particularly useful if you are planning to copy the whole string to the

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:



+ 2
- 0
nnn.1 ファイルの表示

@@ -111,6 +111,8 @@ Extract archive in current directory
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


+ 38
- 0
nnn.c ファイルの表示

@@ -351,6 +351,7 @@ static const char messages[][16] = {

/* 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 */

@@ -674,6 +675,36 @@ appendfpath(const char *path, const size_t len)
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
*/
@@ -1992,6 +2023,7 @@ show_help(char *path)
"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"
@@ -3104,6 +3136,12 @@ nochange:
} 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);


+ 3
- 0
nnn.h ファイルの表示

@@ -66,6 +66,7 @@ enum action {
SEL_REDRAW,
SEL_COPY,
SEL_COPYMUL,
SEL_COPYLIST,
SEL_QUOTE,
SEL_OPEN,
SEL_NEW,
@@ -188,6 +189,8 @@ static struct key bindings[] = {
{ ' ', 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 */


読み込み中…
キャンセル
保存