1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-16 02:40:08 +00:00

feat(extract): support obscpio format (#11511)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
This commit is contained in:
Filippo Bonazzi 2023-02-22 10:16:28 +01:00 committed by GitHub
parent 9f9d3b7d24
commit a4f08ad238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View file

@ -1,10 +1,10 @@
# extract plugin # extract plugin
This plugin defines a function called `extract` that extracts the archive file This plugin defines a function called `extract` that extracts the archive file you pass it, and it supports a
you pass it, and it supports a wide variety of archive filetypes. wide variety of archive filetypes.
This way you don't have to know what specific command extracts a file, you just This way you don't have to know what specific command extracts a file, you just do `extract <filename>` and
do `extract <filename>` and the function takes care of the rest. the function takes care of the rest.
To use it, add `extract` to the plugins array in your zshrc file: To use it, add `extract` to the plugins array in your zshrc file:
@ -15,7 +15,7 @@ plugins=(... extract)
## Supported file extensions ## Supported file extensions
| Extension | Description | | Extension | Description |
|:------------------|:-------------------------------------| | :---------------- | :----------------------------------- |
| `7z` | 7zip file | | `7z` | 7zip file |
| `Z` | Z archive (LZW) | | `Z` | Z archive (LZW) |
| `apk` | Android app file | | `apk` | Android app file |
@ -32,6 +32,7 @@ plugins=(... extract)
| `lrz` | LRZ archive | | `lrz` | LRZ archive |
| `lz4` | LZ4 archive | | `lz4` | LZ4 archive |
| `lzma` | LZMA archive | | `lzma` | LZMA archive |
| `obscpio` | cpio archive used on OBS |
| `rar` | WinRAR archive | | `rar` | WinRAR archive |
| `rpm` | RPM package | | `rpm` | RPM package |
| `sublime-package` | Sublime Text package | | `sublime-package` | Sublime Text package |
@ -57,5 +58,5 @@ plugins=(... extract)
| `zst` | Zstandard file (zstd) | | `zst` | Zstandard file (zstd) |
| `zpaq` | Zpaq file | | `zpaq` | Zpaq file |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information
more information regarding archive formats. regarding archive formats.

View file

@ -3,5 +3,5 @@
_arguments \ _arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \ "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|obscpio|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \
&& return 0 && return 0

View file

@ -72,7 +72,7 @@ EOF
builtin cd -q ..; command rm *.tar.* debian-binary ;; builtin cd -q ..; command rm *.tar.* debian-binary ;;
(*.zst) unzstd "$file" ;; (*.zst) unzstd "$file" ;;
(*.cab) cabextract -d "$extract_dir" "$file" ;; (*.cab) cabextract -d "$extract_dir" "$file" ;;
(*.cpio) cpio -idmvF "$file" ;; (*.cpio|*.obscpio) cpio -idmvF "$file" ;;
(*.zpaq) zpaq x "$file" ;; (*.zpaq) zpaq x "$file" ;;
(*) (*)
echo "extract: '$file' cannot be extracted" >&2 echo "extract: '$file' cannot be extracted" >&2