mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-08 04:34:00 +02:00
Merge 9f807012b7 into 291e96dcd0
This commit is contained in:
commit
d38bffaa39
2 changed files with 62 additions and 0 deletions
34
plugins/archive/README.md
Normal file
34
plugins/archive/README.md
Normal file
|
|
@ -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 <filename>` 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
|
||||
28
plugins/archive/archive.plugin.zsh
Normal file
28
plugins/archive/archive.plugin.zsh
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue