diff --git a/src/index.html b/src/index.html index 7352755..fc8525d 100644 --- a/src/index.html +++ b/src/index.html @@ -44,7 +44,7 @@ include "includes/head.html"
$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt https://transfer.sh/66nb8/hello.txt

- # Using the alias + # Using the shell function
$ transfer hello.txt
##################################################### 100.0% https://transfer.sh/eibhM/hello.txt @@ -151,16 +151,17 @@ include "includes/head.html"
-

Add an alias to .bashrc or .zshrc [gist]

+

Add shell function to .bashrc or .zshrc

- # Add this to .bashrc or its equivalent -
transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer 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; rm -f $tmpfile; } + # Add this to .bashrc or .zshrc or its equivalent
+ transfer(){ if [ $# -eq 0 ];then echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2;return 1;fi;if tty -s;then file="$1";file_name=$(basename "$file");if [ ! -e "$file" ];then echo "$file: No such file or directory">&2;return 1;fi;if [ -d "$file" ];then file_name="$file_name.zip" ,;(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,;;else cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;}
- # Now you can use transfer command +
+ # Now you can use transfer function
$ transfer hello.txt
@@ -237,12 +238,12 @@ include "includes/head.html"
-

Send email with transfer link (uses alias)

+

Send email with transfer link (uses shell function)

- # Transfer and send email with link (uses alias) + # Transfer and send email with link (uses shell function)
$ transfer /tmp/hello.txt | mail -s "Hello World" user@yourmaildomain.com
diff --git a/src/index.txt b/src/index.txt index 2d66142..64b3bb2 100644 --- a/src/index.txt +++ b/src/index.txt @@ -30,11 +30,8 @@ $ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal Virusscan: $ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/scan -Add alias to .bashrc or .zshrc: +Add shell function to .bashrc or .zshrc or its equivalent: === -transfer() { -if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer 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"; fi; cat $tmpfile; rm -f $tmpfile; } -} +transfer(){ if [ $# -eq 0 ];then echo "No arguments specified.\nUsage:\n transfer \n ... | transfer ">&2;return 1;fi;if tty -s;then file="$1";file_name=$(basename "$file");if [ ! -e "$file" ];then echo "$file: No such file or directory">&2;return 1;fi;if [ -d "$file" ];then file_name="$file_name.zip" ,;(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,;;else cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;} === $ transfer test.txt