summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/opencode/src/cli/cmd/session.ts31
1 files changed, 30 insertions, 1 deletions
diff --git a/packages/opencode/src/cli/cmd/session.ts b/packages/opencode/src/cli/cmd/session.ts
index c8b5b0336..c6a1fd413 100644
--- a/packages/opencode/src/cli/cmd/session.ts
+++ b/packages/opencode/src/cli/cmd/session.ts
@@ -4,7 +4,36 @@ import { Session } from "../../session"
import { bootstrap } from "../bootstrap"
import { UI } from "../ui"
import { Locale } from "../../util/locale"
+import { Flag } from "../../flag/flag"
import { EOL } from "os"
+import path from "path"
+
+function pagerCmd(): string[] {
+ const lessOptions = ["-R", "-S"]
+ if (process.platform !== "win32") {
+ return ["less", ...lessOptions]
+ }
+
+ // user could have less installed via other options
+ const lessOnPath = Bun.which("less")
+ if (lessOnPath) {
+ if (Bun.file(lessOnPath).size) return [lessOnPath, ...lessOptions]
+ }
+
+ if (Flag.OPENCODE_GIT_BASH_PATH) {
+ const less = path.join(Flag.OPENCODE_GIT_BASH_PATH, "..", "..", "usr", "bin", "less.exe")
+ if (Bun.file(less).size) return [less, ...lessOptions]
+ }
+
+ const git = Bun.which("git")
+ if (git) {
+ const less = path.join(git, "..", "..", "usr", "bin", "less.exe")
+ if (Bun.file(less).size) return [less, ...lessOptions]
+ }
+
+ // Fall back to Windows built-in more (via cmd.exe)
+ return ["cmd", "/c", "more"]
+}
export const SessionCommand = cmd({
command: "session",
@@ -58,7 +87,7 @@ export const SessionListCommand = cmd({
if (shouldPaginate) {
const proc = Bun.spawn({
- cmd: ["less", "-R", "-S"],
+ cmd: pagerCmd(),
stdin: "pipe",
stdout: "inherit",
stderr: "inherit",