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