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

Function filterClaudeAliases

src/utils/shellConfig.ts:45–75  ·  view source on GitHub ↗
(lines: string[])

Source from the content-addressed store, hash-verified

43 * Returns the filtered lines and whether our default installer alias was found
44 */
45export function filterClaudeAliases(lines: string[]): {
46 filtered: string[]
47 hadAlias: boolean
48} {
49 let hadAlias = false
50 const filtered = lines.filter(line => {
51 // Check if this is a claude alias
52 if (CLAUDE_ALIAS_REGEX.test(line)) {
53 // Extract the alias target - handle spaces, quotes, and various formats
54 // First try with quotes
55 let match = line.match(/alias\s+claude\s*=\s*["']([^"']+)["']/)
56 if (!match) {
57 // Try without quotes (capturing until end of line or comment)
58 match = line.match(/alias\s+claude\s*=\s*([^#\n]+)/)
59 }
60
61 if (match && match[1]) {
62 const target = match[1].trim()
63 // Only remove if it points to the installer location
64 // The installer always creates aliases with the full expanded path
65 if (target === getLocalClaudePath()) {
66 hadAlias = true
67 return false // Remove this line
68 }
69 }
70 // Keep custom aliases that don't point to the installer location
71 }
72 return true
73 })
74 return { filtered, hadAlias }
75}
76
77/**
78 * Read a file and split it into lines

Callers 2

cleanupShellAliasesFunction · 0.85

Calls 1

getLocalClaudePathFunction · 0.85

Tested by

no test coverage detected