mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-27 03:14:56 +01:00
Updates transfer.sh plugin: no longer uses a temp file ; fixes issue with filenames with special characters ; starts using omz_urlencode() ;
This commit is contained in:
parent
2514dbf1d0
commit
7828042726
1 changed files with 14 additions and 9 deletions
|
|
@ -1,20 +1,25 @@
|
||||||
|
# From https://transfer.sh/
|
||||||
|
# Modified by Gabriel Kaam <gabriel@kaam.fr>
|
||||||
|
|
||||||
function transfer() {
|
function transfer() {
|
||||||
if [ $# -eq 0 ]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
|
cat<<EOF
|
||||||
|
No arguments specified. Usage:
|
||||||
|
transfer /tmp/test.md
|
||||||
|
cat /tmp/test.md | transfer test.md
|
||||||
|
EOF
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmpfile=$( mktemp -t transferXXX )
|
basefile=$(omz_urlencode "${1:t}")
|
||||||
|
|
||||||
if tty -s; then
|
if tty -s; then
|
||||||
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
|
url=$(curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile")
|
||||||
curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile
|
|
||||||
else
|
else
|
||||||
curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile
|
url=$(curl --progress-bar --upload-file "-" "https://transfer.sh/$basefile")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat $tmpfile
|
echo $url
|
||||||
rm -f $tmpfile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
alias transfer=transfer
|
alias transfer=transfer
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue