2020-10-23 12:00:41 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Show type & contents of given files or PWD
|
2020-12-10 16:34:56 +00:00
|
|
|
|
|
|
|
# gets the last arg or current dir
|
2020-11-16 11:29:31 +00:00
|
|
|
for last; do true; done
|
|
|
|
last=${last:-.}
|
2020-12-10 16:34:56 +00:00
|
|
|
|
2021-07-06 22:48:35 +00:00
|
|
|
tput setaf 4 && file "$last" | grep -v --color=never 'directory$'
|
2020-12-10 16:34:56 +00:00
|
|
|
test -e "$last" || exit 1
|
|
|
|
|
2020-11-16 11:29:31 +00:00
|
|
|
case "$(file --dereference --mime "$last")" in
|
2021-07-03 18:59:33 +00:00
|
|
|
*inode/directory*) ls -l --color=always --human-readable --group-directories-first --file-type --dereference-command-line --all "$@";;
|
2020-11-16 11:29:31 +00:00
|
|
|
*binary) ;;
|
2021-07-06 22:48:35 +00:00
|
|
|
*) $(test -f "$last" -a ! -r "$last" && echo "sudo") bat --style header "$@"
|
2021-07-02 16:33:30 +00:00
|
|
|
tput setaf 3 && stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
|
|
|
|
;;
|
2020-11-16 11:29:31 +00:00
|
|
|
esac
|