1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-07 21:18:01 +08:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Marc Cornellà
86f805280f fix(changelog): display scope in breaking change messages 2021-01-05 19:17:27 +01:00
Marc Cornellà
6b57839292 fix(CLI): show symlinked themes in omz theme list 2021-01-05 19:09:57 +01:00
Marc Cornellà
64cb153084 chore: add Konfekt as universalarchive maintainer 2021-01-05 18:58:23 +01:00
Konfekt
492f712df2
feat(plugins): add universalarchive plugin to conveniently compress files (#6846)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
2021-01-05 18:53:29 +01:00
6 changed files with 126 additions and 3 deletions

1
.github/CODEOWNERS vendored
View File

@ -4,4 +4,5 @@ plugins/genpass/ @atoponce
plugins/git-lfs/ @hellovietduc
plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg
plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski

View File

@ -359,8 +359,8 @@ EOF
function _omz::theme::list {
local -a custom_themes builtin_themes
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r))
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
builtin_themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r))
# If the command is being piped, print all found line by line
if [[ ! -t 1 ]]; then

View File

@ -0,0 +1,46 @@
# universalarchive plugin
Lets you compress files by a command `ua <format> <files>`, supporting various
compression formats (e.g. 7z, tar.gz, lzma, ...).
To enable it, add `universalarchive` to the plugins array in your zshrc file:
```zsh
plugins=(... universalarchive)
```
## Usage
Run `ua <format> <files>` to compress `<files>` into an archive file using `<format>`.
For example:
```sh
ua xz *.html
```
this command will compress all `.html` files in directory `folder` into `folder.xz`.
This plugin saves you from having to remember which command line arguments compress a file.
## Supported compression formats
| Extension | Description |
|:-----------------|:-------------------------------|
| `7z` | 7zip file |
| `bz2` | Bzip2 file |
| `gz` | Gzip file |
| `lzma` | LZMA archive |
| `lzo` | LZO archive |
| `rar` | WinRAR archive |
| `tar` | Tarball |
| `tbz`/`tar.bz2` | Tarball with bzip2 compression |
| `tgz`/`tar.gz` | Tarball with gzip compression |
| `tlz`/`tar.lzma` | Tarball with lzma compression |
| `txz`/`tar.xz` | Tarball with lzma2 compression |
| `tZ`/`tar.Z` | Tarball with LZW compression |
| `xz` | LZMA2 archive |
| `Z` | Z archive (LZW) |
| `zip` | Zip archive |
| `zst` | Zstd archive |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information regarding the archive formats.

View File

@ -0,0 +1,6 @@
#compdef ua
_arguments \
"1:archive format:(7z bz2 gz lzma lzo rar tar tar.bz2 tar.gz tar.lzma tar.xz tar.Z tbz tgz tlz txz tZ xz Z zip zst)" \
"*:input files:_files" \
&& return 0

View File

@ -0,0 +1,70 @@
function ua() {
local usage=\
"Archive files and directories using a given compression algorithm.
Usage: $0 <format> <files>
Example: $0 tbz PKGBUILD
Supported archive formats are:
7z, bz2, gz, lzma, lzo, rar, tar, tbz (tar.bz2), tgz (tar.gz),
tlz (tar.lzma), txz (tar.xz), tZ (tar.Z), xz, Z, zip, and zst."
if [[ $# -lt 2 ]]; then
echo >&2 "$usage"
return 1
fi
local ext="$1"
local input="$(realpath "$2")"
shift
if [[ ! -e "$input" ]]; then
echo >&2 "$input not found"
return 1
fi
# generate output file name
local output
if [[ $# -gt 1 ]]; then
output="$(basename "${input%/*}")"
elif [[ -f "$input" ]]; then
output="$(basename "${input%.[^.]*}")"
elif [[ -d "$input" ]]; then
output="$(basename "${input}")"
fi
# if output file exists, generate a random name
if [[ -f "${output}.${ext}" ]]; then
output=$(mktemp "${output}_XXX") && rm "$output" || return 1
fi
# add extension
output="${output}.${ext}"
# safety check
if [[ -f "$output" ]]; then
echo >&2 "output file '$output' already exists. Aborting"
return 1
fi
case "$ext" in
7z) 7z u "${output}" "${@}" ;;
bz2) bzip2 -vcf "${@}" > "${output}" ;;
gz) gzip -vcf "${@}" > "${output}" ;;
lzma) lzma -vc -T0 "${@}" > "${output}" ;;
lzo) lzop -vc "${@}" > "${output}" ;;
rar) rar a "${output}" "${@}" ;;
tar) tar -cvf "${output}" "${@}" ;;
tbz|tar.bz2) tar -cvjf "${output}" "${@}" ;;
tgz|tar.gz) tar -cvzf "${output}" "${@}" ;;
tlz|tar.lzma) XZ_OPT=-T0 tar --lzma -cvf "${output}" "${@}" ;;
txz|tar.xz) XZ_OPT=-T0 tar -cvJf "${output}" "${@}" ;;
tZ|tar.Z) tar -cvZf "${output}" "${@}" ;;
xz) xz -vc -T0 "${@}" > "${output}" ;;
Z) compress -vcf "${@}" > "${output}" ;;
zip) zip -rull "${output}" "${@}" ;;
zst) zstd -c -T0 "${@}" > "${output}" ;;
*) echo >&2 "$usage"; return 1 ;;
esac
}

View File

@ -286,7 +286,7 @@ function display-release {
local hash subject
for hash message in ${(kv)breaking}; do
echo " - $(fmt:hash) $(fmt:subject "${message}")"
echo " - $(fmt:hash) $(fmt:scope) $(fmt:subject "${message}")"
done | sort
echo
}