Skip to content

Instantly share code, notes, and snippets.

@minhaz1 minhaz1/transfer.sh
Created Mar 30, 2015

Embed
What would you like to do?
alias for srtr.me transfer
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" "http://srtr.cloudapp.net/$basefile" >> $tmpfile;
else
curl --progress-bar --upload-file "-" "http://srtr.cloudapp.net/$1"
fi
cat $tmpfile;
cat $tmpfile | xargs echo -n | pbcopy;
rm -f $tmpfile;
}
alias transfer=transfer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.