( options?: ShellConfigOptions, )
| 112 | * @param options Optional overrides for testing (env, homedir) |
| 113 | */ |
| 114 | export async function findClaudeAlias( |
| 115 | options?: ShellConfigOptions, |
| 116 | ): Promise<string | null> { |
| 117 | const configs = getShellConfigPaths(options) |
| 118 | |
| 119 | for (const configPath of Object.values(configs)) { |
| 120 | const lines = await readFileLines(configPath) |
| 121 | if (!lines) continue |
| 122 | |
| 123 | for (const line of lines) { |
| 124 | if (CLAUDE_ALIAS_REGEX.test(line)) { |
| 125 | // Extract the alias target |
| 126 | const match = line.match(/alias\s+claude=["']?([^"'\s]+)/) |
| 127 | if (match && match[1]) { |
| 128 | return match[1] |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | return null |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Check if a claude alias exists and points to a valid executable |
no test coverage detected