bin/b: fix formatting pagination and exa
This commit is contained in:
parent
4f21a8fb45
commit
0527731dfb
|
@ -52,9 +52,9 @@ for arg; do
|
||||||
then echo "File not found: '$arg'" 1>&2
|
then echo "File not found: '$arg'" 1>&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
grid=$(expr $(tput cols) / \( 25 - \( $# / 2 \) \& $# \< 30 \| 5 \))
|
grid=$(expr $(tput cols) / \( 25 - \( $# / 2 \) \& $# \< 30 \| 5 \)) # TODO reduce grid when many PDFs
|
||||||
# TODO reduce grid when many PDFs
|
|
||||||
tmpfile="$prefix/$(basename "$arg")"
|
tmpfile="$prefix/$(basename "$arg")"
|
||||||
|
mkdir -p "$prefix"
|
||||||
case "$mime" in
|
case "$mime" in
|
||||||
(*\ application/pdf\;*)
|
(*\ application/pdf\;*)
|
||||||
echo Converting "$arg"
|
echo Converting "$arg"
|
||||||
|
@ -75,7 +75,7 @@ for arg; do
|
||||||
(*\ video/*)
|
(*\ video/*)
|
||||||
suffix=_thumbs.jpg
|
suffix=_thumbs.jpg
|
||||||
mtn -i -t -W -r2 -D6 -b 0,6 -c $grid -w $(expr $(tput cols) '*' 20) \
|
mtn -i -t -W -r2 -D6 -b 0,6 -c $grid -w $(expr $(tput cols) '*' 20) \
|
||||||
-O $prefix -o $suffix "$arg" 2>/dev/null
|
-O "$prefix" -o "$suffix" "$arg" 2>/dev/null
|
||||||
timg -W "$prefix/$(basename "${arg%.*}")$suffix"
|
timg -W "$prefix/$(basename "${arg%.*}")$suffix"
|
||||||
;;
|
;;
|
||||||
(*\ image/*)
|
(*\ image/*)
|
||||||
|
@ -147,24 +147,28 @@ if test "$bat" -o "$batplain"; then
|
||||||
test "$(bat --version | cut -d. -f2)" -gt 16 && rule=,rule
|
test "$(bat --version | cut -d. -f2)" -gt 16 && rule=,rule
|
||||||
if test $# -gt ${#bat[@]} -a $# -gt ${#batplain[@]} && test -z "$flags"
|
if test $# -gt ${#bat[@]} -a $# -gt ${#batplain[@]} && test -z "$flags"
|
||||||
then cut="--line-range :7"
|
then cut="--line-range :7"
|
||||||
pager="cut -c-$(echo "$(tput cols)*1.9" | bc | cut -d. -f1)"
|
batpager="cut -c-$(echo "$(tput cols)*1.9" | bc | cut -d. -f1)"
|
||||||
fi
|
fi
|
||||||
batcommand="$elevate bat $cut $flags --pager"
|
batcommand="$elevate bat $cut $flags --pager"
|
||||||
batstyle="--style plain$rule"
|
batstyle="--style plain$rule"
|
||||||
test "$batplain" && $batcommand "$pager" $batstyle "${batplain[@]}"
|
test "$batplain" && $batcommand "${batpager:-$pager}" $batstyle "${batplain[@]}"
|
||||||
test "$bat" && if test "$cut" && ! $inspect
|
test "$bat" && if test "$cut" && ! $inspect
|
||||||
then case $TERM in (*kitty)
|
then case $TERM in (*kitty)
|
||||||
declare -a timgtxt
|
declare -a timgtxt
|
||||||
for file in "${bat[@]}"; do cp "$file" "$prefix/$file.txt"; timgtxt+=("$prefix/$file.txt"); done
|
for file in "${bat[@]}"
|
||||||
|
do txt="$prefix/$(basename "$file").txt"
|
||||||
|
cp "$file" "$txt"
|
||||||
|
timgtxt+=("$txt")
|
||||||
|
done
|
||||||
timg -V --grid="$(expr 4 \& ${#bat[@]} \> 5 \| ${#bat[@]})" --title="%b" --frames=3 "${timgtxt[@]}"
|
timg -V --grid="$(expr 4 \& ${#bat[@]} \> 5 \| ${#bat[@]})" --title="%b" --frames=3 "${timgtxt[@]}"
|
||||||
#fileinfo "${bat[@]}"
|
#fileinfo "${bat[@]}"
|
||||||
;;
|
;;
|
||||||
(*) for file in "${bat[@]}"; do
|
(*) for file in "${bat[@]}"; do
|
||||||
$batcommand "$pager" $batstyle "$file"
|
$batcommand "${batpager:-$pager}" $batstyle "$file"
|
||||||
fileinfo "$file"
|
fileinfo "$file"
|
||||||
done;;
|
done;;
|
||||||
esac
|
esac
|
||||||
else $inspect || $batcommand "$pager" $batstyle,header$(test $# -gt 1 && echo ",numbers") "${bat[@]}"
|
else $inspect || $batcommand "${batpager:-$pager}" $batstyle,header$(test $# -gt 1 && echo ",numbers") "${bat[@]}"
|
||||||
test $# -lt $(expr $(tput lines) / 3) && fileinfo "${bat[@]}"
|
test $# -lt $(expr $(tput lines) / 3) && fileinfo "${bat[@]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -174,7 +178,7 @@ if test "$ls" -o $# -le $(echo "$flags" | wc -w); then
|
||||||
# Alternative: find -exec ls -dl {} +
|
# Alternative: find -exec ls -dl {} +
|
||||||
{
|
{
|
||||||
# TODO don't use * for ls array as spaces go awry
|
# TODO don't use * for ls array as spaces go awry
|
||||||
timeout .1s sh -c "
|
timeout .6s sh -c "
|
||||||
if which exa 2>/dev/null >&2
|
if which exa 2>/dev/null >&2
|
||||||
then exa --color=always --long --group --classify --group-directories-first --all --all $flags ${ls[*]:-.}
|
then exa --color=always --long --group --classify --group-directories-first --all --all $flags ${ls[*]:-.}
|
||||||
else $elevate ls -l $(test $# -gt ${#ls[@]} && echo '-d') --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line-symlink-to-dir --all $flags ${ls[*]:-.}
|
else $elevate ls -l $(test $# -gt ${#ls[@]} && echo '-d') --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line-symlink-to-dir --all $flags ${ls[*]:-.}
|
||||||
|
|
4
.zshenv
4
.zshenv
|
@ -68,8 +68,8 @@ which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim'
|
||||||
export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)"
|
export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)"
|
||||||
# TODO put into config file and use --exclude-from
|
# TODO put into config file and use --exclude-from
|
||||||
export DIRS_GENERATED="-x generated -x .gradle -x cmake_build -x dist-newstyle -x node_modules -x __pycache__"
|
export DIRS_GENERATED="-x generated -x .gradle -x cmake_build -x dist-newstyle -x node_modules -x __pycache__"
|
||||||
export DIRS_IGNORE_SAFE="-x .sync -x .stfolder -x .cache -x .cpan -x *Cache -x .pyenv -x .local/cache -x share/baloo -x share/cabal -x share/cargo -x share/digikam -x share/gem -x share/JetBrains -x share/tldr -x share/syncthing -x share/Steam/ubuntu* -x share/Steam/package -x share/virtualenv -x share/Zeal -x state/gradle -x state/android -x Ferdi/Partitions -x oh-my-zsh -x wine/drive_c/windows $DIRS_GENERATED"
|
export DIRS_IGNORE_SAFE="-x .cache -x .cpan -x *Cache -x .pyenv -x .local/cache -x share/baloo -x share/cabal -x share/cargo -x share/digikam -x share/gem -x share/JetBrains -x share/tldr -x share/syncthing -x share/Steam/ubuntu* -x share/Steam/package -x share/virtualenv -x share/Zeal -x state/gradle -x state/android -x Ferdi/Partitions -x oh-my-zsh -x wine/drive_c/windows $DIRS_GENERATED"
|
||||||
export DIRS_IGNORE="-x *build -x .git -x .idea -x env -x out -x cache -x Partitions $DIRS_IGNORE_SAFE"
|
export DIRS_IGNORE="-x .sync -x .stfolder -x *build -x .git -x .idea -x env -x out -x cache -x Partitions $DIRS_IGNORE_SAFE"
|
||||||
# red stderr
|
# red stderr
|
||||||
test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"
|
test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"
|
||||||
# software config
|
# software config
|
||||||
|
|
Loading…
Reference in New Issue