MCPcopy Index your code
hub / github.com/codeaashu/claude-code / detectShell

Function detectShell

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

Source from the content-addressed store, hash-verified

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

Callers 2

setupShellCompletionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected