33 lines
406 B
Bash
Executable File

#!/bin/sh
path=$1
if [ -z "$path" ]; then
path="."
fi
if [ -d "$path" ]; then
ls -lh --color=tty "$path"
else
if [ ! -f "$path" ]; then
echo "No such file: $path"
exit 0
fi
format="$(file -i "$path" | cut -d' ' -f2)"
format="${format%%/*}"
case "$format" in
"text")
batcat "$path" --paging=never
;;
"image")
kitty +kitten icat "$path"
;;
*)
xdg-open "$path"
esac
fi