Uploading and copy download command for transfer.sh
本文是我给 transfer.sh
提的一个 PR 的内容。
Download commands can be automatically copied to the clipboard after files are uploaded using transfer.sh.
It was designed for 🐧 Linux or 🍎 macOS.
1. Install xclip or xsel for Linux, macOS skips this step
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:
1 | alias pbcopy='xclip -selection clipboard' |
- If use xsel, paste the following lines:
1 | alias pbcopy='xsel --clipboard --input' |
2. Add Uploading and copy download command shell function
Open .bashrc or .zshrc or its equivalent.
Add the following shell script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20transfer() {
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
}
3. Test
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:
1 | $ transfer ~/temp/a.log w |
Uploading and copy download command for transfer.sh