瀏覽代碼

Support specifying target path for xpst()

Alois Mahdal 1 月之前
父節點
當前提交
b39737a0a9
共有 1 個檔案被更改,包括 6 行新增1 行删除
  1. 6
    1
      dotfiles/config/bashum/main.bashrc

+ 6
- 1
dotfiles/config/bashum/main.bashrc 查看文件

@@ -645,6 +645,11 @@ xpst() {
645 645
     #
646 646
     # Paste paths from clipboard
647 647
     #
648
+    local target_path="${1:-.}"
649
+    test -d "$target_path" || {
650
+        echo >&2 "no such directory: $target_path"
651
+        return 2
652
+    }
648 653
     { xop o; echo; } \
649 654
       | while read -r path; do
650 655
             echo "path='$path'" >&2
@@ -652,7 +657,7 @@ xpst() {
652 657
                 echo "does not exist: $path"
653 658
                 continue
654 659
             }
655
-            cp -ar "$path" .
660
+            cp -ar "$path" "$target_path"
656 661
         done
657 662
 }
658 663