Pager attempts to locate a pager that's appropriate for the environment.
()
| 8 | |
| 9 | // Pager attempts to locate a pager that's appropriate for the environment. |
| 10 | func Pager() string { |
| 11 | |
| 12 | // default to `more` on Windows |
| 13 | if runtime.GOOS == "windows" { |
| 14 | return "more" |
| 15 | } |
| 16 | |
| 17 | // if $PAGER is set, return the corresponding pager |
| 18 | if os.Getenv("PAGER") != "" { |
| 19 | return os.Getenv("PAGER") |
| 20 | } |
| 21 | |
| 22 | // Otherwise, search for `pager`, `less`, and `more` on the `$PATH`. If |
| 23 | // none are found, return an empty pager. |
| 24 | for _, pager := range []string{"pager", "less", "more"} { |
| 25 | if path, err := exec.LookPath(pager); err == nil { |
| 26 | return path |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // default to no pager |
| 31 | return "" |
| 32 | } |
no outgoing calls