From c7ea4166927b694cf4b4b71a40917ffcc2711b59 Mon Sep 17 00:00:00 2001 From: Diki Andriansyah Date: Sun, 18 Dec 2016 14:14:53 +0700 Subject: [PATCH 1/2] Add archive.plugin.zsh --- plugins/archive/archive.plugin.zsh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 plugins/archive/archive.plugin.zsh diff --git a/plugins/archive/archive.plugin.zsh b/plugins/archive/archive.plugin.zsh new file mode 100644 index 000000000..dabcd4e33 --- /dev/null +++ b/plugins/archive/archive.plugin.zsh @@ -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 +} From 9f807012b7bf0530986e2c527cc415498375aeed Mon Sep 17 00:00:00 2001 From: Diki Andriansyah Date: Sun, 18 Dec 2016 14:16:33 +0700 Subject: [PATCH 2/2] Add readme to archive plugin --- plugins/archive/README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plugins/archive/README.md diff --git a/plugins/archive/README.md b/plugins/archive/README.md new file mode 100644 index 000000000..db068bd4d --- /dev/null +++ b/plugins/archive/README.md @@ -0,0 +1,34 @@ +# archive plugin + +This plugin was copied from `extract plugin` and that guy is awesome. Thanks! + +Defines a function called `archive` that get list the archive file +you pass it, and it supports a wide variety of archive filetypes. + +This way you don't have to know what specific command list archive a file, you just +do `archive ` and the function takes care of the rest. + +To use it, add `archive` to the plugins array in your zshrc file: + +```zsh +plugins=(... archive) +``` + +## Supported file extensions + +| Extension | Description | +|:------------------|:-------------------------------------| +| `7z` | 7zip file | +| `rar` | WinRAR archive | +| `tar` | Tarball | +| `tar.bz2` | Tarball with bzip2 compression | +| `tar.gz` | Tarball with gzip compression | +| `tar.lzma` | Tarball with lzma compression | +| `tar.xz` | Tarball with lzma2 compression | +| `zip` | Zip archive | + +See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for +more information regarding archive formats. + +## Contributors +- Diki Andriansyah - diki1aap@gmail.com