oh-my-fish / plugin-brew

Oh My Fish plugin to integrate Homebrew paths into shell.
MIT License
16 stars 10 forks source link

set environment with `brew shellenv` #9

Open simonrouse9461 opened 5 years ago

simonrouse9461 commented 5 years ago

See issue #8 brew shellenv already generates all the necessary codes for setting up shell environment. Using its output is the best approach.

Homebrew install its brew binary as /usr/local/bin/brew by default. User can provide custom installation location by setting $HOMEBREW_BIN in before.init.fish.

m0nhawk commented 4 years ago

Is there any change getting this merged? It's a nice edition and actualization for the plugins.

metawave commented 3 years ago

@simonrouse9461 I like the your PR.... especially not setting the PATH but rather $fish_user_paths but I hesitate on the set $HOMEBREW_BIN path in before.init.fish part..... there are only a few recommended installation locations for brew... you could try to add a simple discovery mechanism to detect and configure the location of brew, of course a user could provide further locations... I do something similar in my attempt to make brew work for multiple plattforms linux (wsl at work) and macOS at home (couldn't test the apple silicon location so far):

# search in recomended installation locations (macOS, macOS M1, Linux (global/default), Linux alternative method)
set -l possible_brew_paths /usr/local/bin/brew /opt/homebrew/bin/brew /home/linuxbrew/.linuxbrew/bin/brew ~/.linuxbrew/bin/brew 
for possible_brew_path in $possible_brew_paths
    if test -f $possible_brew_path
        eval ($possible_brew_path shellenv)
    end
end

this supports all default locations for brew on macOS (including Apple Silicon) and Linux default/global and user-based location, thus making even https://github.com/oh-my-fish/plugin-linuxbrew obsolete

created a fork https://github.com/metawave/plugin-brew based on your work and I'm currently testing it....