Skip to content

Commit 1c04cd2

Browse files
rsteubersteube
authored andcommitted
fix: scan Homebrew bash completions on Apple Silicon
Add /opt/homebrew/etc/bash_completion.d to hardcoded fallback locations and use HOMEBREW_PREFIX (set by `brew shellenv`) to resolve both etc/bash_completion.d and share/bash-completion/completions under the actual install prefix, so Apple Silicon Macs no longer miss brew-installed completions. Closes #325. 💘 Generated with Crush Assisted-by: Crush:glm-5.2
1 parent f41cf07 commit 1c04cd2

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

pkg/bridges/bash.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func bashCompletionLocations() []string {
8181
} else {
8282
locations = append(locations,
8383
"/data/data/com.termux/files/usr/share/bash-completion/completions", // termux
84-
"/usr/local/share/bash-completion/completions", // osx
84+
"/usr/local/share/bash-completion/completions", // osx (Intel)
8585
"/usr/share/bash-completion/completions", // linux
8686
)
8787
}
@@ -90,8 +90,18 @@ func bashCompletionLocations() []string {
9090
locations = append(locations,
9191
"/data/data/com.termux/files/etc/bash_completion.d", // termux
9292
"/etc/bash_completion.d", // linux
93-
"/usr/local/etc/bash_completion.d", // osx
93+
"/opt/homebrew/etc/bash_completion.d", // osx (Apple Silicon)
94+
"/usr/local/etc/bash_completion.d", // osx (Intel)
9495
)
9596

97+
// 6) Homebrew prefix (covers both /usr/local and /opt/homebrew, or custom).
98+
// `brew shellenv` sets HOMEBREW_PREFIX; use it when XDG_DATA_DIRS didn't already cover the share dir.
99+
if prefix, ok := os.LookupEnv("HOMEBREW_PREFIX"); ok {
100+
locations = append(locations,
101+
fmt.Sprintf("%v/etc/bash_completion.d", prefix),
102+
fmt.Sprintf("%v/share/bash-completion/completions", prefix),
103+
)
104+
}
105+
96106
return locations
97107
}

0 commit comments

Comments
 (0)