style: format single-line.zsh to zinit convention (#325)

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
This commit is contained in:
vladislav doster 2022-07-04 02:29:25 -05:00 committed by GitHub
parent 99a41e36a6
commit c3529c8270
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,19 +1,27 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors
# Copyright (c) 2021-2022 zdharma-continuum and contributors
emulate -R zsh
setopt extendedglob warncreateglobal typesetsilent rcquotes noshortloops
setopt extendedglob noshortloops rcquotes typesetsilent warncreateglobal
local zero=$'\0' r=$'\r' n=$'\n' IFS=
{ command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r\n/\n\0/' || \
gstdbuf -o0 gtr '\r\n' '\n\0' || \
stdbuf -o0 tr '\r\n' '\n\0'; print } 2>/dev/null | \
while read -r line; do
local IFS= n=$'\n' r=$'\r' zero=$'\0'
{
command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r\n/\n\0/' \
|| gstdbuf -o0 gtr '\r\n' '\n\0' \
|| stdbuf -o0 tr '\r\n' '\n\0';
print
} 2>/dev/null | while read -r line;
do
if [[ $line == *$zero* ]]; then
# Unused by cURL (there's no newline after the previous progress bar)
#print -nr -- $r${(l:COLUMNS:: :):-}$r${line##*$zero}
print -nr -- $r${(l:COLUMNS:: :):-}$r${line%$zero}
# cURL doesn't add a newline to progress bars
# print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${line##*${zero}}"
print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${line%${zero}}"
else
print -nr -- $r${(l:COLUMNS:: :):-}$r${${line//[$r$n]/}%\%*}${${(M)line%\%}:+%}
print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${${line//[${r}${n}]/}%\%*}${${(M)line%\%}:+%}"
fi
done
print