Browse Source

Add xcp() and xpst() to simulate file copy-pasting ops

Alois Mahdal 4 years ago
parent
commit
7d4bd188f3
1 changed files with 27 additions and 0 deletions
  1. 27
    0
      dotfiles/bash/main.bashrc

+ 27
- 0
dotfiles/bash/main.bashrc View File

446
     xop o | vipe | xop ii
446
     xop o | vipe | xop ii
447
 }
447
 }
448
 
448
 
449
+xcp() {
450
+    #
451
+    # Copy paths of $@ to clipboard
452
+    #
453
+    local path
454
+    find "$@" -maxdepth 0 -mindepth 0 \
455
+      | while read -r path; do
456
+            readlink -e "$path"
457
+        done \
458
+      | xop i
459
+}
460
+
461
+xpst() {
462
+    #
463
+    # Paste paths from clipboard
464
+    #
465
+    { xop o; echo; } \
466
+      | while read -r path; do
467
+            echo "path='$path'" >&2
468
+            test -e "$path" || {
469
+                echo "does not exist: $path"
470
+                continue
471
+            }
472
+            cp -r "$path" .
473
+        done
474
+}
475
+
449
 xvb() {
476
 xvb() {
450
     #
477
     #
451
     # Edit text in primary clipboard and run it using bash
478
     # Edit text in primary clipboard and run it using bash