| 15 | import { which } from "@opencode-ai/core/util/which" |
| 16 | |
| 17 | function pagerCmd(): string[] { |
| 18 | const lessOptions = ["-R", "-S"] |
| 19 | if (process.platform !== "win32") { |
| 20 | return ["less", ...lessOptions] |
| 21 | } |
| 22 | |
| 23 | // user could have less installed via other options |
| 24 | const lessOnPath = which("less") |
| 25 | if (lessOnPath) { |
| 26 | if (Filesystem.stat(lessOnPath)?.size) return [lessOnPath, ...lessOptions] |
| 27 | } |
| 28 | |
| 29 | if (Flag.OPENCODE_GIT_BASH_PATH) { |
| 30 | const less = path.join(Flag.OPENCODE_GIT_BASH_PATH, "..", "..", "usr", "bin", "less.exe") |
| 31 | if (Filesystem.stat(less)?.size) return [less, ...lessOptions] |
| 32 | } |
| 33 | |
| 34 | const git = which("git") |
| 35 | if (git) { |
| 36 | const less = path.join(git, "..", "..", "usr", "bin", "less.exe") |
| 37 | if (Filesystem.stat(less)?.size) return [less, ...lessOptions] |
| 38 | } |
| 39 | |
| 40 | // Fall back to Windows built-in more (via cmd.exe) |
| 41 | return ["cmd", "/c", "more"] |
| 42 | } |
| 43 | |
| 44 | export const SessionCommand = cmd({ |
| 45 | command: "session", |