How to hide terminal warning when Oh-my-ZSH plugin can't access external app
Asked Answered
D

5

6

I've been using oh-my-zsh for a while and it's working great. I'd like to use the command-line fuzzy finder plugin so I enabled it in .zshrc:

plugins=(fzf)

However if "fzf" is not installed I get a warning when opening my terminal window:

[oh-my-zsh] fzf plugin: Cannot find fzf installation directory. Please add export FZF_BASE=/path/to/fzf/install/dir to your .zshrc

Is there a way to hide that warning message? When I install fzf with "sudo dnf install fzf" the warning dissapears, but maybe I want to clone my dotfiles on a different computer where it is not available and it's not that important to be there.

Dartboard answered 24/9, 2018 at 13:53 Comment(0)
V
3

you should first install fzf, in Mac and i use the following command to install brew install fzf

Vespers answered 18/2, 2019 at 9:5 Comment(1)
yes, that works for my M1 MacTundra
E
1

You need to have fzf installed to use this plugin; otherwise remove it. It won't do anything without first installing fzf. Sudo apt install fzf

Eniwetok answered 9/5, 2021 at 16:9 Comment(0)
I
0

You can put the plugins= line inside an if statement that checks for the presence of fzf in your path. For example:

if [[ -n $(command -v fzf) ]] ; then
    echo "fzf found, loading oh-my-zsh fzf plugin"
    plugins=(vi-mode fzf)
else
    echo "no fzf was found in the path"
    plugins=(vi-mode)
fi

command -v is similar to which, but is superior for this context as explained in this answer. The -n makes the [[ ]] evaluate as true whenever the $() produces a non-empty output.

Intertexture answered 2/6, 2019 at 12:56 Comment(0)
T
0

For me, it was also very important that brew itself was in Path of ~/.zshenv like so:

export PATH=/opt/homebrew/bin:$PATH 

Installed FZF with brew on an M1 Mac.

Otherwise, the error occurs:

[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc
Tem answered 3/3, 2022 at 11:38 Comment(0)
R
0

When you install fzf by using brew, it needs to be set brew env.
You can solve to set PATH for fzf before the line of plugins=(fzf) in .zshrc file.

But, I recommand creating "$HOME/.zprofile" as following.

For m1 Mac.

# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"

For, intel Mac

# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/usr/local/bin/brew shellenv)"
Respirable answered 19/10, 2022 at 14:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.