bin: improve zip inspection in b
This commit is contained in:
parent
e976a88ca0
commit
c92d34463a
|
@ -16,9 +16,14 @@ test "$1" = "-v" &&
|
||||||
set -eo xtrace &&
|
set -eo xtrace &&
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
inspect=false
|
||||||
|
test "$1" = "-i" &&
|
||||||
|
inspect=true &&
|
||||||
|
shift
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
for last; do true; done
|
for last; do true; done
|
||||||
last=${last:-.}
|
last="${last:-.}"
|
||||||
|
|
||||||
checkperm() {
|
checkperm() {
|
||||||
checkaccess -r "$@" || elevate=sudo
|
checkaccess -r "$@" || elevate=sudo
|
||||||
|
@ -34,14 +39,17 @@ fileinfo() {
|
||||||
#probe="$($elevate ffprobe "$arg" 2>&1)"
|
#probe="$($elevate ffprobe "$arg" 2>&1)"
|
||||||
#echo $probe | grep -v -e '00:00:00.04' -e 'ansi' &&
|
#echo $probe | grep -v -e '00:00:00.04' -e 'ansi' &&
|
||||||
$elevate ffprobe "$arg" 2>&1 | grep "bitrate: ....\? " | sed 's/, start:[^,]\+,/,/' ||
|
$elevate ffprobe "$arg" 2>&1 | grep "bitrate: ....\? " | sed 's/, start:[^,]\+,/,/' ||
|
||||||
stat --format '%A %s - birth %.10w mod %.10y' "$arg" | numfmt --field=2 --to=iec-i --padding=6 --suffix=B
|
stat --format "%A %s $(
|
||||||
|
size="$($elevate unzip -l "$arg" 2>/dev/null | tail -1)" &&
|
||||||
|
echo "(uncompressed $(echo $size | cut -d' ' -f1 | numfmt --to=iec-i --suffix=B))"
|
||||||
|
) - birth %.10w mod %.10y" "$arg" | numfmt --field=2 --to=iec-i --padding=6 --suffix=B
|
||||||
done
|
done
|
||||||
tput sgr0
|
tput sgr0
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix=/tmp/b
|
prefix=/tmp/b
|
||||||
mkdir -p "$prefix"
|
mkdir -p "$prefix"
|
||||||
declare -a timg timga bat ls
|
declare -a timg timga bat batl ls
|
||||||
for arg; do
|
for arg; do
|
||||||
case "$arg" in (-*) args="$args $arg"; continue;; esac
|
case "$arg" in (-*) args="$args $arg"; continue;; esac
|
||||||
checkperm "$arg"
|
checkperm "$arg"
|
||||||
|
@ -78,11 +86,12 @@ for arg; do
|
||||||
timga+=("$arg")
|
timga+=("$arg")
|
||||||
;;
|
;;
|
||||||
(*:\ *compress*|*\ archive*)
|
(*:\ *compress*|*\ archive*)
|
||||||
|
list="$tmpfile-list.txt"
|
||||||
if test $# = 1
|
if test $# = 1
|
||||||
then nvim "$arg"
|
then nvim "$arg"
|
||||||
else case "$arg" in (*.part);; (*)
|
else case "$arg" in (*.part);; (*)
|
||||||
nvim -es "+2w$tmpfile|5,w>>$tmpfile" "$arg"
|
nvim -es "+2w$list|5,w>>$list" "$arg"
|
||||||
bat+=("$tmpfile");;
|
batl+=("$list");;
|
||||||
esac; fi
|
esac; fi
|
||||||
;;
|
;;
|
||||||
(*:\ *database*) sqlite3 "$arg" ".tables";;
|
(*:\ *database*) sqlite3 "$arg" ".tables";;
|
||||||
|
@ -95,6 +104,8 @@ for arg; do
|
||||||
fileinfo "$arg"
|
fileinfo "$arg"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if $inspect; then exit $?; fi
|
||||||
|
|
||||||
if test "$timg"; then
|
if test "$timg"; then
|
||||||
$elevate timg -V --rotate=exif -g $(tput cols)x$(expr $(tput lines) / 2) \
|
$elevate timg -V --rotate=exif -g $(tput cols)x$(expr $(tput lines) / 2) \
|
||||||
$(test $# -gt 1 && echo "-t0.2 --center --title --grid=$(expr $(tput cols) / \( 30 - $# \& $# \< 20 \| 10 \))x2") \
|
$(test $# -gt 1 && echo "-t0.2 --center --title --grid=$(expr $(tput cols) / \( 30 - $# \& $# \< 20 \| 10 \))x2") \
|
||||||
|
@ -109,10 +120,12 @@ if test "$timg"; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$bat"; then
|
if test "$bat" -o "$batl"; then
|
||||||
test $# -gt ${#bat[@]} && test -z "$args" &&
|
if test $# -gt ${#bat[@]} -a $# -gt ${#batl[@]} && test -z "$args"
|
||||||
$elevate head "${bat[@]}" | cut -c-$(echo "$(tput cols)*1.9" | bc | cut -d. -f1) ||
|
then $elevate head "${batl[@]}" "${bat[@]}" | cut -c-$(echo "$(tput cols)*1.9" | bc | cut -d. -f1)
|
||||||
$elevate bat --style header --pager 'less -RF' $args "${bat[@]}"
|
else test "$bat" && $elevate bat --style header,rule --pager 'less -RF' $args "${bat[@]}"
|
||||||
|
test "$batl" && $elevate bat --style rule --pager 'less -RF' $args "${batl[@]}"
|
||||||
|
fi
|
||||||
fileinfo "${bat[@]}"
|
fileinfo "${bat[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ df --output="source,avail" -h $(test -n "$local" && echo ".") "$dir"
|
||||||
highlight "home"
|
highlight "home"
|
||||||
for f in ${_clean_folders[@]}
|
for f in ${_clean_folders[@]}
|
||||||
do "$local" >/dev/null 2>&1 && f="$(echo "$f" | sed "s|$HOME|$($loc)|")"
|
do "$local" >/dev/null 2>&1 && f="$(echo "$f" | sed "s|$HOME|$($loc)|")"
|
||||||
test -f $f || test -d $f && echo $f && rm -rf $i $f
|
test -f $f || test -d $f && echo "Removing empty $f" && rm -rf $i $f
|
||||||
done
|
done
|
||||||
find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue