-
-
Save averyrobinson/8d5d6f95d477712102b3 to your computer and use it in GitHub Desktop.
pman
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/bash | |
# pman -- view a typeset man page | |
PATH=/bin:/usr/bin:/usr/local/bin | |
cachedir=/tmp/${USER}/pman-cache/ | |
# display error if no arguments | |
if [[ $# -eq 0 ]] | |
then | |
echo "What manual page do you want?" | |
exit 1 | |
fi | |
# create cache directory if necessary | |
if [[ ! -d ${cachedir} ]] | |
then | |
mkdir -p ${cachedir} | |
fi | |
# name cache file | |
command="$*" | |
source=$(man -w ${command}) | |
target=${cachedir}/${command// /-}.pdf | |
# typeset and cache man page if it doesn't yet exist, or is out of date | |
if [[ ! -f ${target} || ${source} -nt ${target} ]] | |
then | |
man -t "$@" | ps2pdf - ${target} | |
fi | |
# view cached man page | |
evince ${target} &> /dev/null & | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment