dotfiles/.local/bin/scripts/b

18 lines
637 B
Bash
Executable File

#!/bin/sh
# Show type & contents of given files or PWD
# gets the last arg or current dir
for last; do true; done
last=${last:-.}
file "$last" | grep -v --color=never 'directory$'
test -e "$last" || exit 1
case "$(file --dereference --mime "$last")" in
*inode/directory*) ls -l --color=always --human-readable --group-directories-first --file-type --dereference-command-line --almost-all "$@";;
*binary) ;;
*) $(test -f "$last" -a ! -r "$last" && echo "sudo") bat --style header --pager "less --LONG-PROMPT --quit-if-one-screen" "$@"
tput setaf 3 && stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
;;
esac