Browse Source

Add xdl() and xxdl() for quick downloading files

Alois Mahdal 9 months ago
parent
commit
054629317d
1 changed files with 33 additions and 0 deletions
  1. 33
    0
      dotfiles/config/bashum/main.bashrc

+ 33
- 0
dotfiles/config/bashum/main.bashrc View File

@@ -507,6 +507,39 @@ xop() {
507 507
         ii) fixnl -c | xclip -selection clipboard -i ;;
508 508
         i)  fixnl -c | xclip -i                      ;;
509 509
     esac <"$file"
510
+xdl() {
511
+    #
512
+    # Download URL from primary clipboard to path $1
513
+    #
514
+    local dest=$1
515
+    local url
516
+    url=$(xo)
517
+    _xdl "$dest" "$url"
518
+}
519
+
520
+xxdl() {
521
+    #
522
+    # Download URL from C-C clipboard to path $1
523
+    #
524
+    local dest=$1
525
+    local url
526
+    url=$(xoo)
527
+    _xdl "$dest" "$url"
528
+}
529
+
530
+_xdl() {
531
+    #
532
+    # Download URL from primary clipboard to path $1
533
+    #
534
+    local dest=$1
535
+    local url=$2
536
+    local es
537
+    test -n "$dest" || return 2
538
+    test -f "$dest" && return 2
539
+    test -n "$url" || return 2
540
+    curl -fsSL "$url" >"$dest"; es=$?
541
+    bb
542
+    return $es
510 543
 }
511 544
 
512 545
 xod() {