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 #!/bin/bash
# [b]rowse - custom ls or bat depending on file type # [b]rowse - custom ls or bat depending on file type
# Show type & contents of given files or PWD # Show type & contents of given files or PWD
# depends: tput stat bat neovim
set -eo pipefail set -eo pipefail
# gets the last arg or current dir # 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 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;; *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) ;; *binary) expr "$(file "$last")" : ".*compressed" >/dev/null && /usr/share/nvim/runtime/macros/less.sh "$@";;
*) $elevate bat --style header --color always "$@" | less -XF *) $elevate bat --style header "$@" --pager='less -XF'
tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last" tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
;; ;;
esac esac