Skip to content

Instantly share code, notes, and snippets.

@stefan-matic
Last active October 18, 2023 14:59
Show Gist options
  • Save stefan-matic/ff6d217836fdfcebfe3d083a4d12f5a6 to your computer and use it in GitHub Desktop.
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
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