浏览代码

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

Alois Mahdal 4 年前
父节点
当前提交
7d4bd188f3
共有 1 个文件被更改,包括 27 次插入0 次删除
  1. 27
    0
      dotfiles/bash/main.bashrc

+ 27
- 0
dotfiles/bash/main.bashrc 查看文件

@@ -446,6 +446,33 @@ xvxx() {
446 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 476
 xvb() {
450 477
     #
451 478
     # Edit text in primary clipboard and run it using bash