Skip to content

Instantly share code, notes, and snippets.

@krzyzanowskim
Last active November 8, 2024 14:46
Show Gist options
  • Save krzyzanowskim/c15905757afc1ae3d1bec61c6a2faf82 to your computer and use it in GitHub Desktop.
Save krzyzanowskim/c15905757afc1ae3d1bec61c6a2faf82 to your computer and use it in GitHub Desktop.
less command with markdown highlighting
#!/bin/sh
# SETUP
#
# create executable file ~/.lessfilter with the content of this file
# chmod u+x ~/.lessfilter
#
# setup less by adding lines below to ~/.zshrc
# ```
# export LESSOPEN="| ~/.lessfilter %s"
# export LESS='-F -R -S -X'
# ```
#
# DEPENDENCY
# brew install glow
#
case "$1" in
*.md)
CLICOLOR_FORCE=1 glow --style dark "$1"
;;
*)
# We don't handle this format.
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment