()
| 233 | } |
| 234 | |
| 235 | async function getShellConfigFile(): Promise<string | null> { |
| 236 | const shell = path.basename(process.env.SHELL || "bash") |
| 237 | const home = os.homedir() |
| 238 | const xdgConfig = process.env.XDG_CONFIG_HOME || path.join(home, ".config") |
| 239 | |
| 240 | const configFiles: Record<string, string[]> = { |
| 241 | fish: [path.join(xdgConfig, "fish", "config.fish")], |
| 242 | zsh: [ |
| 243 | path.join(home, ".zshrc"), |
| 244 | path.join(home, ".zshenv"), |
| 245 | path.join(xdgConfig, "zsh", ".zshrc"), |
| 246 | path.join(xdgConfig, "zsh", ".zshenv"), |
| 247 | ], |
| 248 | bash: [ |
| 249 | path.join(home, ".bashrc"), |
| 250 | path.join(home, ".bash_profile"), |
| 251 | path.join(home, ".profile"), |
| 252 | path.join(xdgConfig, "bash", ".bashrc"), |
| 253 | path.join(xdgConfig, "bash", ".bash_profile"), |
| 254 | ], |
| 255 | ash: [path.join(home, ".ashrc"), path.join(home, ".profile")], |
| 256 | sh: [path.join(home, ".profile")], |
| 257 | } |
| 258 | |
| 259 | const candidates = configFiles[shell] || configFiles.bash |
| 260 | |
| 261 | for (const file of candidates) { |
| 262 | const exists = await fs |
| 263 | .access(file) |
| 264 | .then(() => true) |
| 265 | .catch(() => false) |
| 266 | if (!exists) continue |
| 267 | |
| 268 | const content = await Filesystem.readText(file).catch(() => "") |
| 269 | if (content.includes("# opencode") || content.includes(".opencode/bin")) { |
| 270 | return file |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | return null |
| 275 | } |
| 276 | |
| 277 | async function cleanShellConfig(file: string) { |
| 278 | const content = await Filesystem.readText(file) |
no outgoing calls
no test coverage detected