Created
March 30, 2015 22:14
-
-
Save minhaz1/59402d36a2a5fb6b4e51 to your computer and use it in GitHub Desktop.
alias for srtr.me transfer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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