bin/b: support compressed files

This commit is contained in:
xeruf 2021-10-15 13:41:05 +02:00
parent 7e26731781
commit db35fe2286
1 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#!/bin/bash
# [b]rowse - custom ls or bat depending on file type
# Show type & contents of given files or PWD
# depends: tput stat bat neovim
set -eo pipefail
# gets the last arg or current dir
@ -15,8 +16,8 @@ tput setaf 4 && $elevate file -E "$last" | ( grep -v --color=never 'directory$'
case "$($elevate file --dereference --mime "$last")" in
*inode/directory*) tput sgr0 && $(test -x "$last" || echo "sudo") ls -l --color=always --human-readable --group-directories-first --file-type --dereference-command-line --all "$@" | less -XF;;
*binary) ;;
*) $elevate bat --style header --color always "$@" | less -XF
*binary) expr "$(file "$last")" : ".*compressed" >/dev/null && /usr/share/nvim/runtime/macros/less.sh "$@";;
*) $elevate bat --style header "$@" --pager='less -XF'
tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
;;
esac