Skip to content

Commit 8860b07

Browse files
authored
Make brew path configurable in BrewInfo (#358)
Co-authored-by: doiken <doiken@users.noreply.github.com>
1 parent e5b8712 commit 8860b07

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Source/BrewInfo.spoon/init.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ mod.author = "Diego Zamboni <diego@zzamboni.org>"
2222
mod.homepage = "https://github.com/Hammerspoon/Spoons"
2323
mod.license = "MIT - https://opensource.org/licenses/MIT"
2424

25+
--- BrewInfo.brew_path
26+
--- Variable
27+
--- A string specifying the path to the `brew` executable. Defaults to `/usr/local/bin/brew`
28+
mod.brew_path = "/usr/local/bin/brew"
29+
2530
--- BrewInfo.brew_info_delay_sec
2631
--- Variable
2732
--- An integer specifying how long the alerts generated by BrewInfo will stay onscreen
@@ -95,7 +100,7 @@ function mod:showBrewInfo(pkg, subcommand)
95100
local info = "No package selected"
96101
local st = nil
97102
if pkg and pkg ~= "" then
98-
local cmd=string.format("/usr/local/bin/brew %s info %s", subcommand or "", pkg)
103+
local cmd=string.format("%s %s info %s", self.brew_path, subcommand or "", pkg)
99104
info, st=hs.execute(cmd)
100105
if st == nil then
101106
info = "No information found about formula '" .. pkg .. "'!"
@@ -131,7 +136,7 @@ end
131136
function mod:openBrewURL(pkg, subcommand)
132137
local msg = "No package selected"
133138
if pkg and pkg ~= "" then
134-
local j, st, t, rc=hs.execute(string.format("/usr/local/bin/brew %s cat %s",(subcommand or ""), pkg ))
139+
local j, st, t, rc=hs.execute(string.format("%s %s cat %s", self.brew_path, (subcommand or ""), pkg ))
135140
if st ~= nil then
136141
local url=string.match(j, "\n%s*homepage%s+['\"](.-)['\"]%s*\n")
137142
if url and url ~= "" then

0 commit comments

Comments
 (0)