Skip to content

Instantly share code, notes, and snippets.

@austintraver
Created January 18, 2020 15:46
Show Gist options
  • Save austintraver/0d37ecf1655d67837435c0445829c329 to your computer and use it in GitHub Desktop.
Save austintraver/0d37ecf1655d67837435c0445829c329 to your computer and use it in GitHub Desktop.
#!/bin/zsh
# Check that the manpage exists
man -w $1 &> /dev/null
if [[ $? -ne 0 ]]; then
echo "No manual entry for $1" >&2
exit 1
fi
# base_folder='<base href="~/"\>'
style_path="http://austin.jp/style.css"
# style_path="file://${HOME}/hooman/style.css"
# style_path='style.css'
file=$(mktemp --suffix='.html')
# file=manpage.html
endpoint='root@castle:~/website/public/manpage.html'
# Convert the manpage into html
injection="<link rel=\"stylesheet\" type=\"text/css\" href=\"${style_path}\" title=\"style\">"
injection+='<meta property="og:title" content="austin.jp">'
injection+='<meta property="og:image" content="http://austin.jp/teddy.png">'
man -Thtml $1 2> /dev/null | \
sed \
-e "s#<head[^>]*>#&${injection}#" \
-e '/^<a href="#[^>]*>.*<br>$/d' \
1> ${file}
scp ${file} ${endpoint}
open -a 'Safari' 'http://austin.jp'
@arieltraver
Copy link

Quality program, 10/10 would use again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment