Skip to content

Instantly share code, notes, and snippets.

@auxesis
Created January 15, 2021 03:11
Show Gist options
  • Save auxesis/479e0b9bd2ccde0801c4e03621fc6f57 to your computer and use it in GitHub Desktop.
Save auxesis/479e0b9bd2ccde0801c4e03621fc6f57 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# == 0 ]; then
echo "Usage: $0 <filename>"
exit 1
fi
source_filename=$1
target_filename="$(mktemp -d)/$(basename $1)-highlight.html"
if [ ! -e "$source_filename" ]; then
echo "File not found: $source_filename"
exit 2
fi
pygmentize -f html -O bg=light,noclasses,style=colorful $source_filename > $target_filename
open $target_filename
echo "Highlights written to $target_filename"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment