27 lines
405 B
Plaintext
Raw Normal View History

2026-02-19 20:27:50 +01:00
#!/bin/bash
# Check if at least 2 arguments are passed
if [ $# -lt 1 ]; then
echo "Usage: open [file]"
exit 1
fi
FILE="$1"
file_types=$(file -b "$FILE")
if echo "$file_types" | grep -q "text"; then
# Open .md file with glow
if [[ "$FILE" == *.md ]]; then
glow -t "$FILE"
exit $?
fi
#Open other files with bat
bat "$FILE"
exit $?
fi
echo "Opening this file type is not supported!"