bin: adjustments in help and b

This commit is contained in:
xeruf 2021-12-08 11:37:18 +01:00
parent 76d07db42b
commit 849818efca
2 changed files with 36 additions and 29 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# [b]rowse - overview of given files or current directory # [b]rowse - overview of given files or current directory
# depends: tput stat bat checkaccess(in dotfiles) # depends: tput stat bat checkaccess(in my dotfiles)
# optdepends: timg, neovim (compressed files), pdftoppm (PDF), mtn (video) # optdepends: timg, neovim (compressed files), pdftoppm (PDF), mtn (video), audiowaveform
# args: files to inspect # args: files to inspect
# #
# Supports: # Supports:
@ -26,8 +26,9 @@ fileinfo() {
tput setaf 6 tput setaf 6
for arg for arg
do case "$arg" in (-*) continue;; esac 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 file -E "$arg" &&
$elevate stat --format '%A size %sB, birth %.10w mod %.10y' "$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 done
} }
@ -57,12 +58,15 @@ for arg; do
case "$(file "$arg")" in case "$(file "$arg")" in
(*\ ?udio*) (*\ ?udio*)
img="$tmpfile.png" 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 \ audiowaveform --quiet --pixels-per-second 2 --height 36 --width 2000 --amplitude-scale auto \
--background-color 000000 --waveform-color 99BBFF --axis-label-color 000000 \ --background-color 000000 --waveform-color 99BBFF --axis-label-color 000000 \
--input-filename "$arg" --output-format png >"$img" --input-filename "$arg" --output-format png >"$img" && {
timg -g $(tput cols)x2 "$arg" && printf "\\033[2A " timg -g $(tput cols)x2 "$arg" && printf "\\033[2A "
timg -g $(tput cols)x2 --auto-crop --upscale "$img" timg -g $(tput cols)x2 --auto-crop --upscale "$img"
}
fi
;; ;;
(*:\ *compress*|*tar\ archive) (*:\ *compress*|*tar\ archive)
if test $# = 1 if test $# = 1

View File

@ -6,11 +6,14 @@ case $1 in
(zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages (zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages
for last; do true; done for last; do true; done
# need to install zsh-doc package for info pages # 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;; info --vi-keys "$(test "$last" != zsh && echo "--index-search=$last")" zsh ||
LESS="$LESS +/^ *$last *\\[" man zshall;;
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;; (vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
(gh|chordpro) $@ --help | $paginate;; (gh|chordpro) "$@" --help | $paginate;;
(caddy|stretchly|go) $1 help ${@:2} | $paginate;; (caddy|stretchly|go) "$1" help "${@:2}" | $paginate;;
(*) man "$@" || { info "$1" -w | grep -v "manpages" && pinfo "$@"; } || { "$@" --help || "$@" -help; } 2>&1 | ${PAGER:-less} || which "$@";; (*) man "$@" ||
{ info "$1" -w | grep -v "manpages" && pinfo "$@"; } ||
if which "$1" >/dev/null; then "$@" --help || "$@" -help 2>&1 | $paginate; fi;;
esac esac
docs="/usr/share/doc/$1" docs="/usr/share/doc/$1"
if test -d "$docs"; then if test -d "$docs"; then