Created
June 21, 2018 17:15
-
-
Save brandonkrull/7ae4247dbfe13677df18897b3291ea56 to your computer and use it in GitHub Desktop.
transfer.fish: fish function wrapper to transfer.sh
This file contains hidden or 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
function transfer | |
if test (count $argv) -eq 0 | |
echo "No arguments specified. Usage:" | |
echo "transfer /tmp/test.md" | |
echo "cat /tmp/test.md | transfer test.md" | |
return 0 | |
end | |
set tmpfile (mktemp -t transferXXX) | |
if tty -s | |
set basefile (basename "$argv[1]" | sed -e 's/[^a-zA-Z0-9._-]/-/g') | |
curl --progress-bar --upload-file "$argv[1]" "https://transfer.sh/$basefile" >> $tmpfile | |
else | |
curl --progress-bar --upload-file "-" "https://transfer.sh/$argv[1]" >> $tmpfile | |
end | |
cat $tmpfile | |
rm -f $tmpfile | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment