DFile Alias or Commands
dfile() {
if [ $# -eq 0 ]; then
echo -e "No arguments specified. Usage: echo dfile /tmp/test.md cat /tmp/test.md | dfile 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 -F file=@"$1" "https://dfile.herokuapp.com" >> $tmpfile;
else
curl --progress-bar -F file=@"-" "https://dfile.herokuapp.com/$1" >> $tmpfile;
fi;
cat $tmpfile;
rm -f $tmpfile;
}
fish shell
What is the fish shell?
dfile.fish (~/.config/fish/)
function dfile --description "https://dfile.herokuapp.com"
if test (count $argv) -eq 0
echo "No arguments specified. Usage:\necho dfile /tmp/test.md\ncat /tmp/test.md | dfile test.md"
return 1
end
## get temporarily filename, output is written to this file show progress can be showed
set tmpfile ( mktemp -t transferXXX )
## upload stdin or file
set file $argv[1]
set basefile (basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
if test -d $file
# zip directory and transfer
set zipfile ( mktemp -t transferXXX.zip )
# echo (dirname $file)
#cd (dirname $file) and echo (pwd)
zip -r -q - $file >> $zipfile
curl --progress-bar -F file=@"$zipfile" "https://dfile.herokuapp.com" >> $tmpfile
rm -f $zipfile
else
# transfer file
curl --progress-bar -F file=@$file "https://dfile.herokuapp.com" >> $tmpfile
end
## cat output link
cat $tmpfile
## cleanup
rm -f $tmpfile
end
DFile Alias or Commands
zch shell https://ohmyz.sh/
fish shell
What is the fish shell?
dfile.fish (~/.config/fish/)