MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getCompletionsForShell

Function getCompletionsForShell

src/utils/bash/shellCompletion.ts:184–215  ·  view source on GitHub ↗

* Get completions for the given shell type

(
  shellType: 'bash' | 'zsh',
  prefix: string,
  completionType: ShellCompletionType,
  abortSignal: AbortSignal,
)

Source from the content-addressed store, hash-verified

182 * Get completions for the given shell type
183 */
184async function getCompletionsForShell(
185 shellType: 'bash' | 'zsh',
186 prefix: string,
187 completionType: ShellCompletionType,
188 abortSignal: AbortSignal,
189): Promise<SuggestionItem[]> {
190 let command: string
191
192 if (shellType === 'bash') {
193 command = getBashCompletionCommand(prefix, completionType)
194 } else if (shellType === 'zsh') {
195 command = getZshCompletionCommand(prefix, completionType)
196 } else {
197 // Unsupported shell type
198 return []
199 }
200
201 const shellCommand = await Shell.exec(command, abortSignal, 'bash', {
202 timeout: SHELL_COMPLETION_TIMEOUT_MS,
203 })
204 const result = await shellCommand.result
205 return result.stdout
206 .split('\n')
207 .filter((line: string) => line.trim())
208 .slice(0, MAX_SHELL_COMPLETIONS)
209 .map((text: string) => ({
210 id: text,
211 displayText: text,
212 description: undefined,
213 metadata: { completionType },
214 }))
215}
216
217/**
218 * Get shell completions for the given input

Callers 1

getShellCompletionsFunction · 0.85

Calls 2

getBashCompletionCommandFunction · 0.85
getZshCompletionCommandFunction · 0.85

Tested by

no test coverage detected