config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit c7b5d53419a248b16034b3cfe52431eb4a6ac34f
parent 88bf44b115150248250865fdd8915fa0ed032074
Author: Jacob R. Edwards <n/a>
Date:   Thu,  2 Dec 2021 11:41:28 -0800

Add script to view markdown files

Diffstat:
Alocal/bin/bin/mdv | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/local/bin/bin/mdv b/local/bin/bin/mdv @@ -0,0 +1,16 @@ +#!/bin/sh -eu +# Copyright 2021 Jacob R. Edwards +# Markdown Viewer +# +# Converts Markdown to HTML with smu(1) and views it with the user's +# browser. Note that some browsers require a file's name to end +# with .html for it to be treated as HTML. Thus a temporary directory +# is used. + +cleanup() { rm -rf "$tmp"; } + +tmp="$(mktemp -td mdv-XXXXXX)" +trap cleanup 0 +file="$tmp/main.html" +smu "$@" > "$file" +"$BROWSER" "file:$file"