Last active
November 17, 2022 13:38
-
-
Save kjoonlee/b216f754f40382d250f63be1d1538254 to your computer and use it in GitHub Desktop.
Read WSL man pages as PDF files on Windows
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
pman() | |
{ | |
pman_args=("$@") | |
pman_section="$1" | |
pman_manpage="${*: -1}" | |
if [ "${pman_args[*]}" = "$pman_manpage" ]; then | |
pman_file="$pman_manpage.pdf" | |
else | |
pman_file="$pman_manpage.$pman_section.pdf" | |
fi | |
man -t "${pman_args[@]}" > /dev/null && man -t "${pman_args[@]}" \ | |
| ps2pdf - "/mnt/c/Users/kyungjoon.lee/man/$pman_file" \ | |
&& explorer.exe "C:\\Users\\kyungjoon.lee\\man\\$pman_file" | |
} |
On macOS Ventura, man no longer supports a custom GROFF_FONT_PATH and Preview no longer accepts PostScript from stdin:
pman ()
{
pman_args=("$@");
gman -t "${pman_args[@]}" > /dev/null && \
gman -t "${pman_args[@]}" | ps2pdf - - | open -fa Preview
}
Ventura uses mandoc now instead of groff.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
man -t "${pman_args[@]}" | open -f -a Preview