Created
January 18, 2020 15:46
-
-
Save austintraver/0d37ecf1655d67837435c0445829c329 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quality program, 10/10 would use again