Back to Ohmyzsh

universalarchive plugin

plugins/universalarchive/README.md

latest3.1 KB
Original Source

universalarchive plugin

The universalarchive plugin provides a convenient command-line interface for archiving files and directories using a wide variety of compression formats - without having to remember the exact syntax for each tool.

To enable it, add universalarchive to the plugins array in your .zshrc file:

zsh
plugins=(... universalarchive)

Features

  • Compress files and directories using a simple, unified command: ua <format> <files>
  • Automatically detects file/directory names to generate appropriate output names
  • Supports fallback naming if an output file already exists
  • Works with many common and advanced compression formats
  • Designed for simplicity and quick use in the terminal

Usage

Basic command format:

sh
ua <format> <files...>
  • <format>: the archive format to use (e.g., zip, tar.gz, xz, 7z, etc.)
  • <files...>: one or more files or directories to compress

Examples:

Compresses notes.txt and images into notes.zip

sh
ua zip notes.txt images/

Creates myproject.tar.gz

sh
ua tar.gz myproject/

Compresses all .log files into current_folder.xz

sh
ua xz *.log

The plugin will generate a default archive filename based on the input:

  • For a file, the output is derived from the file name without its extension.
  • For a directory, it uses the directory name.
  • For multiple files, it uses the name of the common parent directory.

If the output file already exists, a unique filename is generated using mktemp.

Supported Archive Formats

FormatDescriptionTool Used
7z7zip archive7z
bz2Bzip2-compressed filebzip2
gzGzip-compressed filegzip
lzmaLZMA-compressed filelzma
lzoLZO-compressed filelzop
rarWinRAR archiverar
tarUncompressed tarballtar
tbz,tar.bz2Tarball compressed with Bzip2tar + bzip2
tgz,tar.gzTarball compressed with Gziptar + gzip
tlz,tar.lzmaTarball compressed with LZMAtar + lzma
txz,tar.xzTarball compressed with LZMA2tar + xz
tZ,tar.ZTarball compressed with LZWtar + compress
xzXZ-compressed filexz
ZLZW-compressed filecompress
zipStandard Zip archivezip
zstZstandard-compressed filezstd

Note: Some formats may require specific tools to be installed on your system (e.g. 7z, rar, lzop, zstd). Make sure these tools are available in your $PATH.

Auto-Completion

The plugin provides tab-completion for supported formats and input files. Type ua <TAB> to see available formats, and ua <format> <TAB> to browse files.