bin: adjustments in help and b
This commit is contained in:
parent
76d07db42b
commit
849818efca
|
@ -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
|
||||||
|
|
|
@ -3,28 +3,31 @@
|
||||||
paginate="${PAGER:-less} +Gg"
|
paginate="${PAGER:-less} +Gg"
|
||||||
test "$1" = "-d" && browse=1 && shift
|
test "$1" = "-d" && browse=1 && shift
|
||||||
case $1 in
|
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 ||
|
||||||
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
LESS="$LESS +/^ *$last *\\[" man zshall;;
|
||||||
(gh|chordpro) $@ --help | $paginate;;
|
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
||||||
(caddy|stretchly|go) $1 help ${@:2} | $paginate;;
|
(gh|chordpro) "$@" --help | $paginate;;
|
||||||
(*) man "$@" || { info "$1" -w | grep -v "manpages" && pinfo "$@"; } || { "$@" --help || "$@" -help; } 2>&1 | ${PAGER:-less} || which "$@";;
|
(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
|
esac
|
||||||
docs="/usr/share/doc/$1"
|
docs="/usr/share/doc/$1"
|
||||||
if test -d "$docs"; then
|
if test -d "$docs"; then
|
||||||
if test -z "$browse"
|
if test -z "$browse"
|
||||||
then echo "Find more in $docs"
|
then echo "Find more in $docs"
|
||||||
else
|
else
|
||||||
len() { echo $1 | wc -c; }
|
len() { echo $1 | wc -c; }
|
||||||
shortest() {
|
shortest() {
|
||||||
read shortest
|
read shortest
|
||||||
while read in
|
while read in
|
||||||
do test $(len $shortest) -gt $(len $in) && shortest=$in
|
do test $(len $shortest) -gt $(len $in) && shortest=$in
|
||||||
done
|
done
|
||||||
echo $shortest
|
echo $shortest
|
||||||
}
|
}
|
||||||
firefox "file://$(find $docs -name index.html | shortest | grep . || find $docs -name $1*.html | shortest)"
|
firefox "file://$(find $docs -name index.html | shortest | grep . || find $docs -name $1*.html | shortest)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue