]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix #143: support copy to clipboard
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 27 Nov 2018 17:07:06 +0000 (22:37 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 27 Nov 2018 17:07:06 +0000 (22:37 +0530)
nnn.1
scripts/copier/copier.sh
src/nnn.c

diff --git a/nnn.1 b/nnn.1
index 998529c54cda4a80789d928ec2b71aa51ea45e2d..6886211289658306f51251fb56ed9bb3cfa9f281 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -283,15 +283,13 @@ files.
 .Pp
 \fBNNN_COPIER:\fR set to a clipboard copier script. For example, on Linux:
 .Bd -literal
-    -------------------------------------
+    -----------------------------------------
     #!/bin/sh
 
-    # comment the next line to convert newlines to spaces
-    IFS=
-    echo -n $1 | xsel --clipboard --input
-    -------------------------------------
+    cat /path/to/.nnncp | xargs -0 | xsel -bi
+    -----------------------------------------
 
-    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
 .Pp
 \fBNNN_SCRIPT:\fR path to a custom script to invoke with currently selected file name as argument 1.
index 5629301d4a909b2d35ff84ace67fa2b8e5db1fcf..0f5a195738277e08302d28bef2f51c2d9345c0ab 100755 (executable)
@@ -1,5 +1,3 @@
 #!/bin/sh
 
-# comment the next line to convert newlines to spaces
-IFS=
-echo -n $1 | `xsel --clipboard --input`
+cat /path/to/.nnncp | xargs -0 | xsel -bi
index d48ce6e3d7eb12779565507d4190bbb9c6ab9f89..c673c55d95a71e1353f0197f7e95b0363a38903e 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3008,7 +3008,7 @@ nochange:
 
                                writecp(newpath, r - 1); /* Truncate NULL from end */
                                if (copier)
-                                       spawn(copier, newpath, NULL, NULL, F_NOTRACE);
+                                       spawn(copier, NULL, NULL, NULL, F_NOTRACE);
                        }
                        printmsg(newpath);
                        goto nochange;
@@ -3047,7 +3047,7 @@ nochange:
                        if (copybufpos) { /* File path(s) written to the buffer */
                                writecp(pcopybuf, copybufpos - 1); /* Truncate NULL from end */
                                if (copier)
-                                       spawn(copier, pcopybuf, NULL, NULL, F_NOTRACE);
+                                       spawn(copier, NULL, NULL, NULL, F_NOTRACE);
 
                                if (ncp) { /* Some files cherry picked */
                                        snprintf(newpath, PATH_MAX, "%d files copied", ncp);
@@ -3085,11 +3085,11 @@ nochange:
                        }
 
                        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)
-                               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 */
-                               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);