Add archive.plugin.zsh

This commit is contained in:
Diki Andriansyah 2016-12-18 14:14:53 +07:00 committed by GitHub
commit c7ea416692

View file

@ -0,0 +1,28 @@
alias a=archive
archive() {
if (( $# == 0 )); then
cat <<-'EOF' >&2
Usage: archive [file ...]
EOF
fi
while (( $# > 0 )); do
if [[ ! -f "$1" ]]; then
echo "archive: '$1' is not a valid file" >&2
shift
continue
fi
case "$1" in
(*.7z) 7z l "$1" ;;
(*.rar) unrar l "$1" ;;
(*.tar|*.tar.bz2|*.tar.gz|*.tar.lzma|*.tar.xz) tar tf "$1" ;;
(*.zip) unzip -l "$1" ;;
(*)
echo "archive: '$1' cannot be listed" >&2
;;
esac
shift
done
}