From db35fe2286202c333c80445284b5de7685772099 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Fri, 15 Oct 2021 13:41:05 +0200 Subject: [PATCH] bin/b: support compressed files --- .local/bin/scripts/b | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 3ec0ca9..c69ead0 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -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