Created
March 29, 2016 12:42
-
-
Save Hodgy/562a7480cffaa7a4b4e6 to your computer and use it in GitHub Desktop.
Modified version of the example for alias to https://transfer.sh/
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:\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