Skip to content

Instantly share code, notes, and snippets.

@minhaz1
Created March 30, 2015 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minhaz1/59402d36a2a5fb6b4e51 to your computer and use it in GitHub Desktop.
Save minhaz1/59402d36a2a5fb6b4e51 to your computer and use it in GitHub Desktop.
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