Quellcode durchsuchen

Fix #143: support copy to clipboard

master
Arun Prakash Jana vor 6 Jahren
Ursprung
Commit
0a21d90ad5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: A75979F35C080412
3 geänderte Dateien mit 10 neuen und 14 gelöschten Zeilen
  1. +4
    -6
      nnn.1
  2. +1
    -3
      scripts/copier/copier.sh
  3. +5
    -5
      src/nnn.c

+ 4
- 6
nnn.1 Datei anzeigen

@@ -283,15 +283,13 @@ files.
.Pp .Pp
\fBNNN_COPIER:\fR set to a clipboard copier script. For example, on Linux: \fBNNN_COPIER:\fR set to a clipboard copier script. For example, on Linux:
.Bd -literal .Bd -literal
------------------------------------- -----------------------------------------
#!/bin/sh #!/bin/sh


# comment the next line to convert newlines to spaces cat /path/to/.nnncp | xargs -0 | xsel -bi
IFS= -----------------------------------------
echo -n $1 | xsel --clipboard --input
-------------------------------------


If it's not set, by default file paths are copied to the tmp file \fBDIR/.nnncp\fR, where 'DIR' (by priority) is: \fI$HOME\fR or, \fI$TMPDIR\fR or, \fI/tmp\fR. Note: By default file paths are copied to the tmp file \fBDIR/.nnncp\fR, where 'DIR' (by priority) is: \fI$HOME\fR or, \fI$TMPDIR\fR or, \fI/tmp\fR.
.Ed .Ed
.Pp .Pp
\fBNNN_SCRIPT:\fR path to a custom script to invoke with currently selected file name as argument 1. \fBNNN_SCRIPT:\fR path to a custom script to invoke with currently selected file name as argument 1.


+ 1
- 3
scripts/copier/copier.sh Datei anzeigen

@@ -1,5 +1,3 @@
#!/bin/sh #!/bin/sh


# comment the next line to convert newlines to spaces cat /path/to/.nnncp | xargs -0 | xsel -bi
IFS=
echo -n $1 | `xsel --clipboard --input`

+ 5
- 5
src/nnn.c Datei anzeigen

@@ -3008,7 +3008,7 @@ nochange:


writecp(newpath, r - 1); /* Truncate NULL from end */ writecp(newpath, r - 1); /* Truncate NULL from end */
if (copier) if (copier)
spawn(copier, newpath, NULL, NULL, F_NOTRACE); spawn(copier, NULL, NULL, NULL, F_NOTRACE);
} }
printmsg(newpath); printmsg(newpath);
goto nochange; goto nochange;
@@ -3047,7 +3047,7 @@ nochange:
if (copybufpos) { /* File path(s) written to the buffer */ if (copybufpos) { /* File path(s) written to the buffer */
writecp(pcopybuf, copybufpos - 1); /* Truncate NULL from end */ writecp(pcopybuf, copybufpos - 1); /* Truncate NULL from end */
if (copier) if (copier)
spawn(copier, pcopybuf, NULL, NULL, F_NOTRACE); spawn(copier, NULL, NULL, NULL, F_NOTRACE);


if (ncp) { /* Some files cherry picked */ if (ncp) { /* Some files cherry picked */
snprintf(newpath, PATH_MAX, "%d files copied", ncp); snprintf(newpath, PATH_MAX, "%d files copied", ncp);
@@ -3085,11 +3085,11 @@ nochange:
} }


if (sel == SEL_CP) if (sel == SEL_CP)
snprintf(g_buf, MAX_CMD_LEN, "cat %s | xargs -0 cp -ir --preserve=all -t .", g_cppath); snprintf(g_buf, MAX_CMD_LEN, "xargs -0 -a %s cp -ir --preserve=all -t .", g_cppath);
else if (sel == SEL_MV) else if (sel == SEL_MV)
snprintf(g_buf, MAX_CMD_LEN, "cat %s | xargs -0 mv -i -t .", g_cppath); snprintf(g_buf, MAX_CMD_LEN, "xargs -0 -a %s mv -i -t .", g_cppath);
else /* SEL_RMMUL */ else /* SEL_RMMUL */
snprintf(g_buf, MAX_CMD_LEN, "cat %s | xargs -0 rm -Ir", g_cppath); snprintf(g_buf, MAX_CMD_LEN, "xargs -0 -a %s rm -Ir", g_cppath);


spawn("sh", "-c", g_buf, path, F_NORMAL | F_SIGINT); spawn("sh", "-c", g_buf, path, F_NORMAL | F_SIGINT);




||||||
x
 
000:0
Laden…
Abbrechen
Speichern