Skip to content

Instantly share code, notes, and snippets.

@naranyala
Last active August 8, 2023 03:09
Show Gist options
  • Save naranyala/ec908b294bba9540f04c1d81032f7cf3 to your computer and use it in GitHub Desktop.
Save naranyala/ec908b294bba9540f04c1d81032f7cf3 to your computer and use it in GitHub Desktop.
respect rendered markdown in terminal
#!/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