summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMani Sundararajan <[email protected]>2026-01-01 19:53:29 -0500
committerGitHub <[email protected]>2026-01-01 18:53:29 -0600
commit154c52c4d94f18ebeaf96b53d4eab60e09c85127 (patch)
treee6976090b82a727037443a0eb8f53d1927d007c1
parent680db7b9e4a9dbcaadbd25cf2220fb5d7f538c05 (diff)
downloadopencode-154c52c4d94f18ebeaf96b53d4eab60e09c85127.tar.gz
opencode-154c52c4d94f18ebeaf96b53d4eab60e09c85127.zip
fix: windows fallback for "less" cmd in `session list` (#6515)
-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",