elvish_config/aliases/arc.elv

54 lines
890 B
Plaintext
Raw Normal View History

cmd = $e:arc~
edit:add-var archiver~ [@argv]{
use str
2020-03-13 14:03:36 +00:00
help = {
echo "Usage : archiver [(-zlxgb)] <file to compress>"
return
}
if (or (== (count $argv) 0) (eq $argv[0] -h)) {
2020-03-13 14:03:36 +00:00
$help
}
var format o = zst $argv[0]
if (and (str:has-prefix $o -) (> (count $o) 1)) {
2020-03-13 14:03:36 +00:00
o = $o[1]
var m = [
2020-03-13 14:03:36 +00:00
&z=zst
&l=lz4
&x=xz
&g=gz
2020-03-13 14:03:36 +00:00
&b=bz2
]
if (not (has-key $m $o)) {
$help
}
format argv = $m[$o] $argv[1..]
2020-03-13 14:03:36 +00:00
}
if (== (count $argv) 0) {
2020-03-13 14:03:36 +00:00
$help
}
peach [f]{
var f = $f
2020-03-13 14:03:36 +00:00
if (eq $f[-1] /) {
f = $f[..-1]
2020-03-13 14:03:36 +00:00
}
$cmd archive $f'.tar.'$format $f
2020-03-13 14:03:36 +00:00
echo "'"$f"'" archivé
} $argv
2020-03-13 14:03:36 +00:00
}
edit:add-var desarchiver~ [@argv]{
peach [f]{
var f = $f
$cmd unarchive $f
echo "'"$f"'" désarchivé
} $argv
}
edit:add-var listarchiver~ [@argv]{
peach [f]{
local f = $f
$cmd ls $f
} $argv
}