bin/b: properly integrate exa and flags for it
This commit is contained in:
parent
81a3e2c293
commit
092909e705
|
@ -46,7 +46,7 @@ prefix=/tmp/b
|
||||||
mkdir -p "$prefix"
|
mkdir -p "$prefix"
|
||||||
declare -a timg timga bat batplain ls
|
declare -a timg timga bat batplain ls
|
||||||
for arg; do
|
for arg; do
|
||||||
case "$arg" in (-*) args="$args $arg"; continue;; esac
|
case "$arg" in (-*) flags="$flags $arg"; continue;; esac
|
||||||
checkperm "$arg"
|
checkperm "$arg"
|
||||||
if ! $elevate test -e "$arg"
|
if ! $elevate test -e "$arg"
|
||||||
then echo "File not found: '$arg'" 1>&2
|
then echo "File not found: '$arg'" 1>&2
|
||||||
|
@ -138,16 +138,16 @@ if test "$timg"; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
pager="${PAGER:-'less -RF'}"
|
||||||
# bat: unknown files
|
# bat: unknown files
|
||||||
# batplain: files to print without header
|
# batplain: files to print without header
|
||||||
if test "$bat" -o "$batplain"; then
|
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 "$args"
|
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)"
|
pager="cut -c-$(echo "$(tput cols)*1.9" | bc | cut -d. -f1)"
|
||||||
else pager="less -RF"
|
|
||||||
fi
|
fi
|
||||||
batcommand="$elevate bat $cut $args --pager"
|
batcommand="$elevate bat $cut $flags --pager"
|
||||||
batstyle="--style plain$rule"
|
batstyle="--style plain$rule"
|
||||||
test "$batplain" && $batcommand "$pager" $batstyle "${batplain[@]}"
|
test "$batplain" && $batcommand "$pager" $batstyle "${batplain[@]}"
|
||||||
test "$bat" && if test "$cut" && ! $inspect
|
test "$bat" && if test "$cut" && ! $inspect
|
||||||
|
@ -167,13 +167,15 @@ if test "$bat" -o "$batplain"; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$ls" -o $# -eq 0; then
|
if test "$ls" -o $# -le $(echo "$flags" | wc -w); then
|
||||||
checkperm .
|
checkperm .
|
||||||
if type exa >/dev/null
|
|
||||||
then exa --long --group --classify --group-directories-first --all --all "${ls[@]:-.}"
|
|
||||||
# Alternative: find -exec ls -dl {} +
|
# Alternative: find -exec ls -dl {} +
|
||||||
else { timeout .1s $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 "${ls[@]:-.}" ||
|
{
|
||||||
$elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none "${ls[@]:-.}"
|
timeout .1s sh -c "
|
||||||
} | less -RF
|
if which exa 2>/dev/null >&2
|
||||||
fi
|
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[@]:-.}'
|
||||||
|
fi
|
||||||
|
" || $elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none $flags "${ls[@]:-.}"
|
||||||
|
} | $pager
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue