Last active
August 29, 2015 14:05
-
-
Save gwash/11ba428e4b6a681b7502 to your computer and use it in GitHub Desktop.
Shell CHM file handler using Archmage
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/sh | |
#by M Rawash <[email protected]> | |
#requires archmage | |
[[ $BROWSER ]] || BROWSER='w3m -F' | |
if test "$1" = "-l"; then | |
shift | |
PORT=$((10000+$RANDOM)) | |
archmage -p $PORT "$@" & | |
sleep 2 | |
$BROWSER "http://localhost:$PORT" | |
wait | |
exit 0 | |
elif test "$1" = "-t"; then | |
shift | |
TMPDIR="/tmp/archmage_${@}" | |
archmage "$@" "${TMPDIR}" | |
$BROWSER "${TMPDIR}/index.html" | |
exit 0 | |
elif test "$1" = "-e"; then | |
shift | |
archmage "$@" | |
exit 0 | |
elif test "$1" = "-ct"; then | |
shift | |
archmage -c text "$@" | |
exit 0 | |
elif test "$1" = "-ch"; then | |
#requires htmldoc | |
#FIXME | |
shift | |
archmage -c html "$@" | |
exit 0 | |
elif test "$1" = "-cp"; then | |
#requires htmldoc | |
#FIXME | |
shift | |
archmage -c pdf "$@" | |
exit 0 | |
elif test "$#" -gt 2; then | |
echo "Invalid argument(s)" | |
exit 1 | |
else | |
#requires w3m | |
archmage -d "$@" | w3m -T text/html | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment