updated transfer alias

This commit is contained in:
Remco 2014-12-08 14:13:40 +01:00
parent 339b516f50
commit d541bd5206
2 changed files with 3 additions and 40 deletions

View file

@ -145,28 +145,7 @@ include "includes/head.html"
<div class="terminal">
<code>
<span class="code-title"># Add this to .bashrc or its equivalent</span>
<br/>transfer() {
<br/> if [ $# -eq 0 ]; then
<br/> echo "No arguments specified. Usage:"
<br/> echo "$ transfer /tmp/test.md"
<br/> echo "$ cat /tmp/test.md | transfer test.md"
<br/> return 1
<br/> fi
<br/>
<br/> # write to output to tmpfile because of progress bar
<br/> tmpfile=$( mktemp -t transferXXX );
<br/>
<br/> if tty -s; then
<br/> basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g');
<br/> curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile;
<br/> else
<br/> curl --progress-bar --upload-file "-" "https://transfer.sh/$1"
<br/> fi
<br/>
<br/> cat $tmpfile; rm -f $tmpfile;
<br/>}
<br/>
<br/>alias transfer=transfer
<br/>transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi <br/>tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }; alias transfer=transfer
<br/>
<br/>
<span class="code-title"># Now you can use transfer command</span>

View file

@ -30,24 +30,8 @@ $ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/scan
Add alias to .bashrc or .zshrc:
===
transfer() {
if [ $# -eq 0 ]; then
echo "No arguments specified. Usage:"
echo "$ transfer /tmp/test.md"
echo "$ cat /tmp/test.md | transfer test.md"
return 1
fi
# write to output to tmpfile because of progress bar
tmpfile=$( mktemp -t transferXXX );
if tty -s; then
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g');
curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile;
else
curl --progress-bar --upload-file "-" "https://transfer.sh/$1"
fi
cat $tmpfile; rm -f $tmpfile;
if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1"; fi; cat $tmpfile; rm -f $tmpfile; }; alias transfer=transfer
}
alias transfer=transfer