With transfer-download, download commands can be automatically copied to the clipboard after files are uploaded using transfer.sh.
It was designed for π§ Linux or π macOS.
-
install xclip see https://command-not-found.com/xclip
-
install xsel see https://command-not-found.com/xsel
Install later, add pbcopy and pbpaste to .bashrc or .zshrc or its equivalent.
- If use xclip, paste the following lines:
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
- If use xsel, paste the following lines:
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
-
Open .bashrc or .zshrc or its equivalent.
-
Add the following shell script:
transfer() { curl --progress-bar --upload-file "$1" https://transfer.sh/$(basename "$1") | pbcopy; echo "1) π Download link:" echo "$(pbpaste)" echo "\n2) π§ Linux or π macOS download command:" linux_macos_download_command="wget $(pbpaste)" echo $linux_macos_download_command echo "\n3) π Windows download command:" windows_download_command="Invoke-WebRequest -Uri "$(pbpaste)" -OutFile $(basename $1)" echo $windows_download_command case $2 in l|m) echo $linux_macos_download_command | pbcopy ;; w) echo $windows_download_command | pbcopy ;; esac }
The transfer command has two parameters:
-
The first parameter is the path to upload the file.
-
The second parameter indicates which system's download command is copied. optional:
-
This parameter is empty to copy the download link.
-
l
orm
copy the Linux or macOS command that downloaded the file. -
w
copy the Windows command that downloaded the file.
-
For example, The command to download the file on Windows will be copied:
$ transfer ~/temp/a.log w
######################################################################## 100.0%
1) π Download link:
https://transfer.sh/y0qr2c/a.log
2) π§ Linux or π macOS download command:
wget https://transfer.sh/y0qr2c/a.log
3) π Windows download command:
Invoke-WebRequest -Uri https://transfer.sh/y0qr2c/a.log -OutFile a.log