Skip to content

Instantly share code, notes, and snippets.

@Hodgy
Created March 29, 2016 12:42
Show Gist options
  • Save Hodgy/562a7480cffaa7a4b4e6 to your computer and use it in GitHub Desktop.
Save Hodgy/562a7480cffaa7a4b4e6 to your computer and use it in GitHub Desktop.
Modified version of the example for alias to https://transfer.sh/
transfer() {
if [ $# -eq 0 ]; then
echo "No arguments specified. Usage:\n\ttransfer /tmp/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" >> $tmpfile ;
fi;
cat $tmpfile | pbcopy;
link=$(cat $tmpfile);
echo "Link copied to clipboard: ${link}"
rm -f $tmpfile;
}
alias transfer=transfer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment