Last active
August 8, 2023 03:09
-
-
Save naranyala/ec908b294bba9540f04c1d81032f7cf3 to your computer and use it in GitHub Desktop.
respect rendered markdown in terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ]; then | |
echo "Error: No filename provided. Usage: $0 <filename>" | |
exit 1 | |
fi | |
filename="$1" | |
if [ ! -e "$filename" ]; then | |
echo "Error: The specified file '$filename' does not exist." | |
exit 1 | |
fi | |
# Check if the file is a Markdown file | |
if [[ "$filename" == *".md" ]]; then | |
# Use glow to render Markdown files | |
glow "$filename" | |
else | |
# Use bat for other file types | |
bat "$filename" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment