4 ms·
Optimization on that: if [[ -d /usr/local/opt/mcfly ]]; then export BREW_PREFIX=/usr/local else export BREW_PREFIX=$(brew --prefix)
by smichel17 6y ago
Optimization on that:
if [[ -d /usr/local/opt/mcfly ]]; then
export BREW_PREFIX=/usr/local
else
export BREW_PREFIX=$(brew --prefix)
fi
- rovr138 6y agoI like what pyenv does when you do pyenv init It prints the command for you. They could add the check there, generate the static path and then just print what they need to add hardcoded. Edit, For reference, this is what it prints on the different shells, On ZSH, # Load pyenv automatically by appending # the following to ~/.zshrc: eval "$(pyenv init -)" On Bash, # Load pyenv automatically by appending # the following to ~/.bash_profile: eval "$(pyenv init -)" On Fish, # Load pyenv automatically by appending # the following to ~/.config/fish/config.fish: status --is-interactive; and source (pyenv init -|psub)
- oefrha 6y agoIf every module you load does their own 30ms check, it might cut 60ms to 30ms at each call site but they add up just the same.
- rovr138 6y agoOf course. I’m saying they print what you should add. I’m not saying have an init command that you run on your shell script on startup. I’m saying have an init command that tell you what to put. I think the hardcoded approach by smichel17 with a fallback is a good one. Except that if you ran this command, it might print a different hardcoded path based on where it found the prefix to be at.