elvish_config/aliases/transfer.elv

22 lines
697 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var domain = https://transfer.hostux.net/
edit:add-var transfer~ {|@argv|
use path
if (not-eq (count $argv) 0) {
fail('Usage: transfer <fichier_ou_repertoire>')
}
var file = $argv[0]
var filename = (basename $file)
var is_dir = (path:is-dir &follow-symlink=$true $file)
var is_regular = (path:is-regular &follow-symlink=$true $file)
if (not (and is_dir is_regular)) {
fail("'"$file"' nexiste pas")
}
if is_dir {
set filename = $filename'.tar.gz'
cd $file
tar -c . | e:curl --progress-bar --upload-file - $domain$filename | tee /dev/null
} else {
cat $file | e:curl --progress-bar --upload-file - $domain$filename | teee /dev/null
}
}