1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-26 02:08:37 +08:00
ohmyzsh/plugins/extract
Marc Cornellà 49d34d00cd
fix(extract): fix conflict if compressed file has a folder of the same name
This change fixes the case where the compressed file (e.g. tools.tgz) only
contains a folder with the same name (e.g. tools) in its root folder.

tools.tgz:
|- tools
   |- fileA.txt
   |- fileB.txt
   \- fileC.txt

In that case, the "smart" folder creation mechanism will extract the files in
a folder "tools", and this extraction folder will contain a single folder with
the same name.

Before this fix, the tool would try to move out the inside folder to the parent
one, but there would already be a folder named "tools", so it would generate a
conflict.

This change first renames the inside folder to a random string, and only then
it is moved outside and the old extraction folder is deleted.
2023-04-06 21:06:16 +02:00
..
_extract feat(extract): support obscpio format (#11511) 2023-02-22 10:16:28 +01:00
extract.plugin.zsh fix(extract): fix conflict if compressed file has a folder of the same name 2023-04-06 21:06:16 +02:00
README.md feat(extract): support obscpio format (#11511) 2023-02-22 10:16:28 +01:00

extract plugin

This plugin defines a function called extract that extracts 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 extracts a file, you just do extract <filename> and
the function takes care of the rest.

To use it, add extract to the plugins array in your zshrc file:

plugins=(... extract)

Supported file extensions

Extension Description
7z 7zip file
Z Z archive (LZW)
apk Android app file
aar Android library file
bz2 Bzip2 file
cab Microsoft cabinet archive
cpio Cpio archive
deb Debian package
ear Enterprise Application aRchive
gz Gzip file
ipa iOS app package
ipsw iOS firmware file
jar Java Archive
lrz LRZ archive
lz4 LZ4 archive
lzma LZMA archive
obscpio cpio archive used on OBS
rar WinRAR archive
rpm RPM package
sublime-package Sublime Text package
tar Tarball
tar.bz2 Tarball with bzip2 compression
tar.gz Tarball with gzip compression
tar.lrz Tarball with lrzip compression
tar.lz Tarball with lzip compression
tar.lz4 Tarball with lz4 compression
tar.xz Tarball with lzma2 compression
tar.zma Tarball with lzma compression
tar.zst Tarball with zstd compression
tbz Tarball with bzip compression
tbz2 Tarball with bzip2 compression
tgz Tarball with gzip compression
tlz Tarball with lzma compression
txz Tarball with lzma2 compression
tzst Tarball with zstd compression
war Web Application archive (Java-based)
xpi Mozilla XPI module file
xz LZMA2 archive
zip Zip archive
zst Zstandard file (zstd)
zpaq Zpaq file

See list of archive formats for more information
regarding archive formats.