Last active
October 18, 2023 14:59
-
-
Save stefan-matic/ff6d217836fdfcebfe3d083a4d12f5a6 to your computer and use it in GitHub Desktop.
Easy file sharing from the command line using http://transfer.sh through fish shell
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 --description 'Easy file sharing from the command line using http://transfer.sh' | |
if test (count $argv) -eq 0 | |
echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; | |
return 1; | |
end | |
set tmpfile ( mktemp -t transferXXX ); | |
if tty -s | |
set basefile (basename $argv[1] | sed -e 's/[^a-zA-Z0-9._-]/-/g'); | |
curl -v --progress-bar --upload-file $argv[1] "https://transfer.sh/$basefile" 2>&1 | grep -i 'https://transfer.sh' >> $tmpfile; | |
else | |
curl -v --progress-bar --upload-file "-" "https://transfer.sh/$argv[1]" 2>&1 | grep 'https://transfer.sh' >> $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