feat(macos): allow multiple man pages in `man-preview` (#11365)
Diff
1diff --git a/plugins/macos/README.md b/plugins/macos/README.md
2index 1bc4244a4d5e48028547a34330863a58ac02f241..1cb9b395d13ce19be090d67dba20bc9e6edfc7aa 100644
3--- a/plugins/macos/README.md
4+++ b/plugins/macos/README.md
5@@ -25,7 +25,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
6 | `pxd` | Return the current Xcode project directory |
7 | `cdx` | `cd` to the current Xcode project directory |
8 | `quick-look` | Quick-Look a specified file |
9-| `man-preview` | Open a specified man page in Preview app |
10+| `man-preview` | Open man pages in Preview app |
11 | `showfiles` | Show hidden files in Finder |
12 | `hidefiles` | Hide the hidden files in Finder |
13 | `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
14diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh
15index e4d759dcfaa0cd5c13ceea9a05575872318100dd..e27d412c822ac899ae64425ef5390e524a97dc3d 100644
16--- a/plugins/macos/macos.plugin.zsh
17+++ b/plugins/macos/macos.plugin.zsh
18@@ -224,9 +224,10 @@ function quick-look() {
19 }
2021 function man-preview() {
22- local location
23- # Don't let Preview.app steal focus if the man page doesn't exist
24- location=$(man -w "$@") && mandoc -Tpdf $location | open -f -a Preview
25+ local page
26+ for page in "${(@f)"$(man -w $@)"}"; do
27+ command mandoc -Tpdf $page | open -f -a Preview
28+ done
29 }
30 compdef _man man-preview
31