MCPcopy Index your code
hub / github.com/anomalyco/opencode / getShellConfigFile

Function getShellConfigFile

packages/opencode/src/cli/cmd/uninstall.ts:235–275  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

233}
234
235async 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
277async function cleanShellConfig(file: string) {
278 const content = await Filesystem.readText(file)

Callers 1

collectRemovalTargetsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected