MCPcopy Create free account
hub / github.com/Noumena-Network/code / detectShell

Function detectShell

src/utils/completionCache.ts:29–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27}
28
29function detectShell(): ShellInfo | null {
30 const shell = process.env.SHELL || ''
31 const home = homedir()
32 const claudeDir = getCompletionCacheDir()
33
34 if (shell.endsWith('/zsh') || shell.endsWith('/zsh.exe')) {
35 const cacheFile = join(claudeDir, 'completion.zsh')
36 return {
37 name: 'zsh',
38 rcFile: join(home, '.zshrc'),
39 cacheFile,
40 completionLine: `[[ -f "${cacheFile}" ]] && source "${cacheFile}"`,
41 shellFlag: 'zsh',
42 }
43 }
44 if (shell.endsWith('/bash') || shell.endsWith('/bash.exe')) {
45 const cacheFile = join(claudeDir, 'completion.bash')
46 return {
47 name: 'bash',
48 rcFile: join(home, '.bashrc'),
49 cacheFile,
50 completionLine: `[ -f "${cacheFile}" ] && source "${cacheFile}"`,
51 shellFlag: 'bash',
52 }
53 }
54 if (shell.endsWith('/fish') || shell.endsWith('/fish.exe')) {
55 const xdg = process.env.XDG_CONFIG_HOME || join(home, '.config')
56 const cacheFile = join(claudeDir, 'completion.fish')
57 return {
58 name: 'fish',
59 rcFile: join(xdg, 'fish', 'config.fish'),
60 cacheFile,
61 completionLine: `[ -f "${cacheFile}" ] && source "${cacheFile}"`,
62 shellFlag: 'fish',
63 }
64 }
65 return null
66}
67
68function formatPathLink(filePath: string): string {
69 if (!supportsHyperlinks()) {

Callers 2

setupShellCompletionFunction · 0.85

Calls 1

getCompletionCacheDirFunction · 0.85

Tested by

no test coverage detected