bin: adjustments in help and b
This commit is contained in:
parent
76d07db42b
commit
849818efca
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# [b]rowse - overview of given files or current directory
|
||||
# depends: tput stat bat checkaccess(in dotfiles)
|
||||
# optdepends: timg, neovim (compressed files), pdftoppm (PDF), mtn (video)
|
||||
# depends: tput stat bat checkaccess(in my dotfiles)
|
||||
# optdepends: timg, neovim (compressed files), pdftoppm (PDF), mtn (video), audiowaveform
|
||||
# args: files to inspect
|
||||
#
|
||||
# Supports:
|
||||
|
@ -26,8 +26,9 @@ fileinfo() {
|
|||
tput setaf 6
|
||||
for arg
|
||||
do case "$arg" in (-*) continue;; esac
|
||||
$elevate file -E "$arg" && ffprobe "$arg" 2>&1 | grep Duration | grep -v '00:00:00.04' | sed 's/, start:[^,]\+,/,/'
|
||||
$elevate stat --format '%A size %sB, birth %.10w mod %.10y' "$arg"
|
||||
$elevate file -E "$arg" &&
|
||||
ffprobe "$arg" 2>&1 | grep Duration | grep -v '00:00:00.04' | sed 's/, start:[^,]\+,/,/' ||
|
||||
stat --format '%A %s - birth %.10w mod %.10y' "$arg" | numfmt --field=3 --to=iec-i --padding=6 --suffix=B
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -57,12 +58,15 @@ for arg; do
|
|||
case "$(file "$arg")" in
|
||||
(*\ ?udio*)
|
||||
img="$tmpfile.png"
|
||||
find "$img" -not -empty 2>/dev/null | grep --quiet . ||
|
||||
if which audiowaveform 2>/dev/null >&2
|
||||
then find "$img" -not -empty 2>/dev/null | grep --quiet . ||
|
||||
audiowaveform --quiet --pixels-per-second 2 --height 36 --width 2000 --amplitude-scale auto \
|
||||
--background-color 000000 --waveform-color 99BBFF --axis-label-color 000000 \
|
||||
--input-filename "$arg" --output-format png >"$img"
|
||||
timg -g $(tput cols)x2 "$arg" && printf "\\033[2A "
|
||||
timg -g $(tput cols)x2 --auto-crop --upscale "$img"
|
||||
--input-filename "$arg" --output-format png >"$img" && {
|
||||
timg -g $(tput cols)x2 "$arg" && printf "\\033[2A "
|
||||
timg -g $(tput cols)x2 --auto-crop --upscale "$img"
|
||||
}
|
||||
fi
|
||||
;;
|
||||
(*:\ *compress*|*tar\ archive)
|
||||
if test $# = 1
|
||||
|
|
|
@ -3,28 +3,31 @@
|
|||
paginate="${PAGER:-less} +Gg"
|
||||
test "$1" = "-d" && browse=1 && shift
|
||||
case $1 in
|
||||
(zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages
|
||||
for last; do true; done
|
||||
# need to install zsh-doc package for info pages
|
||||
info --vi-keys $(test $last != zsh && echo --index-search=$last) zsh || LESS="$LESS +/^ *$last *\\[" man zshall;;
|
||||
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
||||
(gh|chordpro) $@ --help | $paginate;;
|
||||
(caddy|stretchly|go) $1 help ${@:2} | $paginate;;
|
||||
(*) man "$@" || { info "$1" -w | grep -v "manpages" && pinfo "$@"; } || { "$@" --help || "$@" -help; } 2>&1 | ${PAGER:-less} || which "$@";;
|
||||
(zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages
|
||||
for last; do true; done
|
||||
# need to install zsh-doc package for info pages
|
||||
info --vi-keys "$(test "$last" != zsh && echo "--index-search=$last")" zsh ||
|
||||
LESS="$LESS +/^ *$last *\\[" man zshall;;
|
||||
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
||||
(gh|chordpro) "$@" --help | $paginate;;
|
||||
(caddy|stretchly|go) "$1" help "${@:2}" | $paginate;;
|
||||
(*) man "$@" ||
|
||||
{ info "$1" -w | grep -v "manpages" && pinfo "$@"; } ||
|
||||
if which "$1" >/dev/null; then "$@" --help || "$@" -help 2>&1 | $paginate; fi;;
|
||||
esac
|
||||
docs="/usr/share/doc/$1"
|
||||
if test -d "$docs"; then
|
||||
if test -z "$browse"
|
||||
then echo "Find more in $docs"
|
||||
else
|
||||
len() { echo $1 | wc -c; }
|
||||
shortest() {
|
||||
read shortest
|
||||
while read in
|
||||
do test $(len $shortest) -gt $(len $in) && shortest=$in
|
||||
done
|
||||
echo $shortest
|
||||
}
|
||||
firefox "file://$(find $docs -name index.html | shortest | grep . || find $docs -name $1*.html | shortest)"
|
||||
fi
|
||||
if test -z "$browse"
|
||||
then echo "Find more in $docs"
|
||||
else
|
||||
len() { echo $1 | wc -c; }
|
||||
shortest() {
|
||||
read shortest
|
||||
while read in
|
||||
do test $(len $shortest) -gt $(len $in) && shortest=$in
|
||||
done
|
||||
echo $shortest
|
||||
}
|
||||
firefox "file://$(find $docs -name index.html | shortest | grep . || find $docs -name $1*.html | shortest)"
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue