News for hackers. Stuff that matters.
Re:Mcfly – neural-network powered directory and context-awar... by antihero on Wednesday July 08, 2020 @08:11AM (#23769088)
Or as a compromise, `export BREW_PREFIX=$(brew --prefix)` somewhere nearer startup.
Re:Mcfly – neural-network powered directory and context-awar... by smichel17 on Wednesday July 08, 2020 @09:05AM (#23769466)
Optimization on that:

    if [[ -d /usr/local/opt/mcfly ]]; then
        export BREW_PREFIX=/usr/local
    else
        export BREW_PREFIX=$(brew --prefix)
    fi
Re:Mcfly – neural-network powered directory and context-awar... by rovr138 on Wednesday July 08, 2020 @10:21AM (#23770117)
I 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)
Re:Mcfly – neural-network powered directory and context-awar... by oefrha on Wednesday July 08, 2020 @10:31AM (#23770233)
If 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.
Re:Mcfly – neural-network powered directory and context-awar... by rovr138 on Thursday July 09, 2020 @01:42AM (#23777265)
Of 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.