19 lines
747 B
Bash
Executable File
19 lines
747 B
Bash
Executable File
#!/bin/sh
|
|
# Show type & contents of given files or PWD
|
|
|
|
set -eo pipefail
|
|
# gets the last arg or current dir
|
|
for last; do true; done
|
|
last=${last:-.}
|
|
|
|
tput setaf 4 && $(test -r "$last" || echo "sudo") file -E "$last" | ( grep -v --color=never 'directory$' || true )
|
|
|
|
elevate="$(test -r "$last" || echo "sudo")"
|
|
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 --force-colorization "$@" | less -XF
|
|
tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
|
|
;;
|
|
esac
|