summaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorEd Zynda <[email protected]>2025-05-16 14:27:28 +0300
committerGitHub <[email protected]>2025-05-16 06:27:28 -0500
commit4a444e9c9b7674c6b07a1a012a6467e45c3af1ec (patch)
treef4c85dbbe33a9edf6a4232fad62d7f6dad64490c /internal
parent623d132772b9c69dd6d99ed4004b26c46dbe43a4 (diff)
downloadopencode-4a444e9c9b7674c6b07a1a012a6467e45c3af1ec.tar.gz
opencode-4a444e9c9b7674c6b07a1a012a6467e45c3af1ec.zip
feat: Make shell configurable via config file (#23)
Diffstat (limited to 'internal')
-rw-r--r--internal/config/config.go7
-rw-r--r--internal/llm/tools/shell/shell.go24
2 files changed, 27 insertions, 4 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 1d741bc91..70c05ac02 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -73,6 +73,12 @@ type TUIConfig struct {
CustomTheme map[string]any `json:"customTheme,omitempty"`
}
+// ShellConfig defines the configuration for the shell used by the bash tool.
+type ShellConfig struct {
+ Path string `json:"path,omitempty"`
+ Args []string `json:"args,omitempty"`
+}
+
// Config is the main configuration structure for the application.
type Config struct {
Data Data `json:"data"`
@@ -85,6 +91,7 @@ type Config struct {
DebugLSP bool `json:"debugLSP,omitempty"`
ContextPaths []string `json:"contextPaths,omitempty"`
TUI TUIConfig `json:"tui"`
+ Shell ShellConfig `json:"shell,omitempty"`
}
// Application constants
diff --git a/internal/llm/tools/shell/shell.go b/internal/llm/tools/shell/shell.go
index efbd5ddb6..a59ee4207 100644
--- a/internal/llm/tools/shell/shell.go
+++ b/internal/llm/tools/shell/shell.go
@@ -12,6 +12,7 @@ import (
"syscall"
"time"
+ "github.com/sst/opencode/internal/config"
"github.com/sst/opencode/internal/status"
)
@@ -59,12 +60,27 @@ func GetPersistentShell(workingDir string) *PersistentShell {
}
func newPersistentShell(cwd string) *PersistentShell {
- shellPath := os.Getenv("SHELL")
- if shellPath == "" {
- shellPath = "/bin/bash"
+ cfg := config.Get()
+
+ // Use shell from config if specified
+ shellPath := ""
+ shellArgs := []string{"-l"}
+
+ if cfg != nil && cfg.Shell.Path != "" {
+ shellPath = cfg.Shell.Path
+ if len(cfg.Shell.Args) > 0 {
+ shellArgs = cfg.Shell.Args
+ }
+ } else {
+ // Fall back to environment variable
+ shellPath = os.Getenv("SHELL")
+ if shellPath == "" {
+ // Default to bash if neither config nor environment variable is set
+ shellPath = "/bin/bash"
+ }
}
- cmd := exec.Command(shellPath, "-l")
+ cmd := exec.Command(shellPath, shellArgs...)
cmd.Dir = cwd
stdinPipe, err := cmd.StdinPipe()